Embedded
A chat placed inside your page layout.
Embedded places the chat directly inside your page, in an element you choose. There is no chat bubble: the conversation is part of your layout, for example on a help center page or in a support panel of your app. Texts and design come from your Configuration. You can override some of them in code and control the chat with a JavaScript API.
Before you start
- Save your Conversation SDK configuration.
- In Automate → Channels, turn on Embedded on the Conversation SDK card.
If Embedded is turned off on the card, the snippet loads nothing.
Install Embedded
- On the Conversation SDK card, click Snippet next to Embedded.
- Copy the code and paste it on your page where the chat should appear.
The snippet looks like this. Always copy yours from the card, because the script address depends on your account:
<div id="zowie-embedded" style="width:100%;height:650px;"></div>
<script type="text/javascript">
(function(cb) {
var js = document.createElement("script");
if (js.readyState) {js.onreadystatechange = function() {if (js.readyState === "loaded" || js.readyState === "complete") {js.onreadystatechange = null; cb();}};
} else {js.onload = function(){cb();};}
js.type = "module";
js.defer = true;
js.src = "https://<your-chat-host>/zowie-embedded-entry.js";
document.body.appendChild(js);
})(function() {
ZowieEmbedded.init("<your-instance-id>", "zowie-embedded", {});
});
</script>The snippet has two parts:
- The container: the
<div>the chat is placed in. The chat fills the whole container, so set its size to fit your layout. You can change theid, as long as you pass the same value toinit. - The script: it loads Embedded and calls
ZowieEmbedded.initwith your Instance ID and theidof the container.
Customize Embedded in code
The third argument of ZowieEmbedded.init is a configuration object. Values you pass there take priority over the values from your configuration in Zowie.
ZowieEmbedded.init("<your-instance-id>", "zowie-embedded", {
headerVisible: false,
primaryColor: "#2563EB",
styles: {
chat: { border: "1px solid #E5E7EB", borderRadius: "12px" },
},
onStartChat: (conversationId) => {
console.log("Conversation started", conversationId);
},
});Call init once per page. Later calls are ignored.
Init options
Behavior
| Option | Type | Default | Description |
|---|---|---|---|
headerVisible | boolean | true | Show the chat header with the title and logo. |
allowEndChat | boolean | true | Let customers end the conversation themselves. |
showVisualAid | boolean | true | Show visual aids in the conversation. |
resetSession | boolean | false | Discard the stored conversation and start a new one. |
versionType | "PRODUCTION" | "STAGING" | "PRODUCTION" | Run conversations against the published or the staging version of your AI Agent. Use "STAGING" to test changes before you publish them. Never use it on your live website. |
context | string | None | ID of a context set up by your TAM. It routes the conversation to the AI Agent assigned to that context. |
Customer data and authentication
| Option | Type | Description |
|---|---|---|
metadata | Metadata | Customer details: name, email, phone number, locale and your own attributes. See Customer data. |
externalAccessToken | string | JWT that identifies a logged-in customer. See Authentication. |
Branding
| Option | Type | Description |
|---|---|---|
title | string | Title in the chat header. |
logoUrl | string | URL of the logo in the chat header. |
primaryColor | string | Primary color, used in both light and dark theme. |
fontColor | "white" | "black" | Text color on top of the primary color. |
fontUrls | { regular?: string, medium?: string } | URLs of font files to use instead of the default font. regular is used for normal text, medium for emphasized text. |
avatarImageUrls | { aiAgent?: string, humanAgent?: string } | URLs of avatar images shown next to messages from the AI Agent and from human agents. |
styles | CustomStyles | Borders, corners, backgrounds and spacing of the chat and its messages, so the chat matches your page. |
Hello (voice)
| Option | Type | Default | Description |
|---|---|---|---|
voiceExperienceEnabled | boolean | From configuration | Turn Hello on or off on this page. Hello must first be enabled for your account. Consult your TAM before you turn it on. |
initialConversationMode | "text" | "voice" | "text" | Mode the chat opens in. "voice" works only when Hello is on. |
voiceBlobColor | string | From configuration | Color of the voice animation. |
Callbacks
Pass these functions in the configuration object to react to what happens in the chat.
| Callback | Arguments | Called when |
|---|---|---|
onLoaded | None | Embedded has loaded. |
onStartChat | conversationId: string | A conversation started. |
onEndChat | None | The conversation ended. |
onSessionExpired | None | The conversation session expired. |
onMessageSent | message: string | The customer sent a message. |
onMessageReceived | message: object | A message arrived in the conversation. |
onCartItemsModified | items: CartModifiedItem[] | The AI Agent added products to or removed them from the cart in the conversation. It works the same way as in the Widget. See Sync the cart from the conversation. |
Control Embedded
After Embedded has loaded, you can control it through the global ZowieEmbedded object. Calls made before it has loaded are ignored, so call these methods from onLoaded or later. The exception is on(), which you can call at any time.
ZowieEmbedded.init("<your-instance-id>", "zowie-embedded", {
onLoaded: () => {
ZowieEmbedded.updateMetadata({
firstName: "Ada",
email: "[email protected]",
});
},
});| Method | Description |
|---|---|
getConversationId() | Return the ID of the current conversation, or undefined when there is none. |
sendMessage(message) | Send a message as the customer. |
sendReferral(referralId) | Send a referral to the conversation to trigger a specific scenario. |
updateMetadata(metadata) | Update the customer details. See Customer data. |
setExternalAccessTokenCallback(callback) | Provide the JWT on demand, when the customer starts a conversation. See Authentication. |
on(eventName, handler) | Listen for a custom event sent by your processes. See Custom events. |
Types
CustomStyles
Every field is optional. Values are CSS values, for example "1px solid #E5E7EB" for a border or "12px" for a radius or padding.
| Field | Applies to |
|---|---|
chat.border | Border of the whole chat. |
chat.borderRadius | Corner radius of the whole chat. |
chat.background | Background of the whole chat. |
messageComposer.border | Border of the field where the customer types. |
messageComposer.borderRadius | Corner radius of the field where the customer types. |
humanAgentMessage.border | Border of messages from human agents. |
humanAgentMessage.borderRadius | Corner radius of messages from human agents. |
humanAgentMessage.background | Background of messages from human agents. |
humanAgentMessage.horizontalPadding | Left and right padding of messages from human agents. |
humanAgentMessage.verticalPadding | Top and bottom padding of messages from human agents. |
userMessage.border | Border of the customer's messages. |
userMessage.borderRadius | Corner radius of the customer's messages. |
userMessage.horizontalPadding | Left and right padding of the customer's messages. |
userMessage.verticalPadding | Top and bottom padding of the customer's messages. |
Updated 34 minutes ago