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

  1. Save your Conversation SDK configuration.
  2. 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

  1. On the Conversation SDK card, click Snippet next to Embedded.
  2. 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 the id, as long as you pass the same value to init.
  • The script: it loads Embedded and calls ZowieEmbedded.init with your Instance ID and the id of 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

OptionTypeDefaultDescription
headerVisiblebooleantrueShow the chat header with the title and logo.
allowEndChatbooleantrueLet customers end the conversation themselves.
showVisualAidbooleantrueShow visual aids in the conversation.
resetSessionbooleanfalseDiscard 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.
contextstringNoneID of a context set up by your TAM. It routes the conversation to the AI Agent assigned to that context.

Customer data and authentication

OptionTypeDescription
metadataMetadataCustomer details: name, email, phone number, locale and your own attributes. See Customer data.
externalAccessTokenstringJWT that identifies a logged-in customer. See Authentication.

Branding

OptionTypeDescription
titlestringTitle in the chat header.
logoUrlstringURL of the logo in the chat header.
primaryColorstringPrimary 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.
stylesCustomStylesBorders, corners, backgrounds and spacing of the chat and its messages, so the chat matches your page.

Hello (voice)

OptionTypeDefaultDescription
voiceExperienceEnabledbooleanFrom configurationTurn 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.
voiceBlobColorstringFrom configurationColor of the voice animation.

Callbacks

Pass these functions in the configuration object to react to what happens in the chat.

CallbackArgumentsCalled when
onLoadedNoneEmbedded has loaded.
onStartChatconversationId: stringA conversation started.
onEndChatNoneThe conversation ended.
onSessionExpiredNoneThe conversation session expired.
onMessageSentmessage: stringThe customer sent a message.
onMessageReceivedmessage: objectA message arrived in the conversation.
onCartItemsModifieditems: 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]",
    });
  },
});
MethodDescription
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.

FieldApplies to
chat.borderBorder of the whole chat.
chat.borderRadiusCorner radius of the whole chat.
chat.backgroundBackground of the whole chat.
messageComposer.borderBorder of the field where the customer types.
messageComposer.borderRadiusCorner radius of the field where the customer types.
humanAgentMessage.borderBorder of messages from human agents.
humanAgentMessage.borderRadiusCorner radius of messages from human agents.
humanAgentMessage.backgroundBackground of messages from human agents.
humanAgentMessage.horizontalPaddingLeft and right padding of messages from human agents.
humanAgentMessage.verticalPaddingTop and bottom padding of messages from human agents.
userMessage.borderBorder of the customer's messages.
userMessage.borderRadiusCorner radius of the customer's messages.
userMessage.horizontalPaddingLeft and right padding of the customer's messages.
userMessage.verticalPaddingTop and bottom padding of the customer's messages.

Did this page help you?