Setup Webchat Interface
Build Your Own Webchat Interface
Explains headless Webchat integration for custom chat interfaces. Useful for developers building their own frontend on top of Stubber Webchat APIs.
Headless mode lets you use the core webchat functionality with your own custom UI, giving complete control over the appearance and behavior of the chat interface.
Note: This example demonstrates only text messaging functionality. Advanced features like file uploads and voice notes are not covered in this basic implementation.
Getting Started
Include the webchat core script in your HTML:
This makes the StubberWebchatCore object available globally, providing the methods for connecting to and interacting with the webchat service.
Accessing the Webchat Core Object
Once the script is loaded, access the webchat core object from the global window object:
This is typically done inside the window.onload handler to ensure the script has loaded:
Configuration Options
Provide these options when configuring the webchat connection:
Connecting
Call webchat.webchat_connect() to connect to the webchat service:
To switch to a previous session, call webchat.webchat_connection_config with your sessionuuid, then call webchat.webchat_connect() again.
Sending Messages
To send a text message:
Receiving Messages
Messages arrive through the payload_callback function provided during configuration. Each message has the following structure:
Complete Example
A complete example with a simple UI for sending and receiving messages:
API Reference
webchat_connection_config(config)
Configures the webchat connection.
webchat_connect()
Connects to the webchat service using the current configuration.
webchat_send_payload(payload)
Sends a message to the webchat service.