Learn how to programmatically open the chat widget and send a message.
openChat
API allows you to programmatically open the chat window and send a message on behalf of the user. This is useful for:
false
(default), the
message will only be prefilled in the input field for the user to review and
send manually. When true
, the message is sent immediately.openChat()
- Opens chat without any messageopenChat({ message: "Hello" })
- Opens chat with pre-filled message (not sent)openChat({ message: "Hello", autoSend: true })
- Opens chat and sends message immediatelyopenChat
method is only available after the widget script has loaded. Always check that the widget is available before calling methods. You can use either approach:
Method 1: Check window.Molin