sendMessage( )


Sends a chat message from the backend.

The sendMessage() function sends a text message to a specific channel from the backend. The message can be from the business to a visitor, or from a visitor to the business.

Method Declaration
Copy
function sendMessage(messageInfo: MessageInfo): Promise<void>;
Method Parameters
messageInfoMessageInfoRequired

An object representing the message to be sent.

JavaScript
import wixChatBackend from "wix-chat-backend"; export function sendChatMessage( messageText, channelId, metadata, sendAsVisitor, ) { wixChatBackend .sendMessage({ messageText: messageText, channelId: channelId, metadata: { metadata }, sendAsVisitor: sendAsVisitor, }) .then(() => { console.log("Chat message sent"); }) .catch((error) => { console.log(error); }); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?