Embedded
Initiating chat via event
Explains starting an embedded Webchat conversation from your webpage with a browser event, optionally sending the user's first message. Useful for hero input bars, prompt chips, and guided entry points.
Overview
Dispatch a stubber_webchat_initiate_chat event on the window to enable the widget, open it, connect, and send a first message on the user's behalf. Unlike opening the chat, this seeds the conversation with a message the visitor has already given you (hero input bars, prompt chips, guided entry points).
Usage
Dispatch a CustomEvent named stubber_webchat_initiate_chat. Pass the first message in detail.data.message:
On this event, the webchat widget will:
- Enable the webchat if it is not already enabled
- Open the chat window and establish a connection
- Send
detail.data.messageas the first message
Each dispatch starts a new chat — if a conversation is already open, it is replaced.
Example
Send the visitor's input from a hero bar into an already-started chat: