Installation
You can create a web widget via the API, or through the dashboard. Once you’ve created your widget, you should have an ID which you can pass into the following code snippet:<head> of your website, you should see the chat widget load. You can customize the widgets appearance via the config property, or by using our visual editor on the platform.
Here is a quick video tutorial of how to create and configure a new web widget on the platform:
Passing Additional Data (Optional)
You can pass custom data to your widget at initialization using the request_data setting. This is useful for personalizing conversations with user information:
Advanced: Custom Components
When using pathways in your widget, you can create custom components that display at specific points in the conversation. These components are embedded as iframes within the widget window.Passing data to custom components
You can send agent variables to your custom components to personalize the user experience. These variables are passed as query parameters to your iframe URL. Setting up variables: Define which variables to pass in one of two ways:- Through the platform UI in the custom component settings
- Via the
variablesfield in the widget custom components API
Creating Interactive Custom Components
Your custom component can send messages back to the widget using window events. Example: Creating a button that sends a messageNote: All messages must be prefixed withwidget-message:. The text after this prefix becomes the user message content. For example, an eventwidget-message:Hello World!will create a user message with the content “Hello World!”.widget-message:Option A selectedwill create a user message with the content “Option A selected”.
Widget Bland Settings Options
The chat widget can be customized using the following configuration options:Keeping the widget open across pages
By default, the chat panel closes when a visitor goes to another page on your site. The conversation carries over, but the visitor has to open the widget again. Setpersist_open to keep the panel open instead:
persist_open on:
- The open state is saved per browser tab. Opening your site in a new tab starts with the widget closed.
- Following a link or submitting a form keeps the widget open. Any other click on the page closes it. It then stays closed on the next page.
- Text chat reopens where the visitor left off. A voice call does not carry over. The widget reopens on the channel menu instead.
- The conversation can end while the visitor is on another page, for example after the inactivity timeout. The widget tells the visitor when they send their next message. They can then start a new chat.
- After a page change, the inactivity warning is not shown until the visitor sends a message on the new page. The timeout still applies.
- If
enable_widget_state_eventsis on, reopening on page load emitsbland_widget_state_change, the same event as a manual open.
Escalate to Live Agents
This feature only works on pathways.
Setup
1
Configure the Pathway Transfer Node
In your pathway, add a Pathway Transfer Node and select Live Agent Transfer as the transfer type. Enter the webhook URL where Bland should send conversation data.
2
Enable Webhook Signing
Webhook signing is required for this integration. Bland signs all webhook payloads with HMAC, sent via the
X-Bland-Signature header. Use your signing secret to verify requests originate from Bland and haven’t been tampered with.See Webhook Signing for implementation details.3
Handle Incoming Webhooks
Your endpoint will receive two types of payloads from Bland: the initial conversation handoff, and subsequent user messages.
4
Send Messages Back to the User
Use the Send Live Agent Message endpoint to send responses from your live agent to the user. When the conversation is complete, send an
END_CONVERSATION payload to close the session.Webhook Payloads
INITIAL_CONVERSATION
Sent when the transfer is triggered. Contains the full conversation history and all agent variables.
MESSAGE
Sent for each message the user sends after the initial handoff.
Post-Conversation Webhooks
Receive a webhook notification when a widget conversation ends. This is useful for logging conversations, triggering follow-up workflows, or syncing conversation data to your CRM. Post-conversation webhooks are signed using HMAC. The signature is included in theX-Webhook-Signature header. See Webhook Signing for verification details.
Configuration
Configure post-conversation webhooks in two ways:- Dashboard: Set the webhook URL in your widget settings on the platform
- API: Pass
webhook_urlwhen creating or updating your widget
config.timeoutSeconds:
Webhook Payload
When a conversation ends, Bland sends a POST request to your configured webhook URL with the following payload:Docs for agents: llms.txt