WhatsApp API Platform

Team Chat

Embed the team-chat workspace and react to message lifecycle events.

Mounts the team-chat workspace as an iframe and relays message lifecycle events back to your page. Optionally scope it to a single agent.

Quick start

<div id="embed" style="height: 600px"></div>
<script src="https://new.theultimate.io/embed.js" defer></script>
<script>
  Embed.render("teamChat", {
    target: "#embed",
    authToken: "<jwt>", // or apiKey: "pm_xxx"
    agentId: "agent_123", // optional
    theme: "system",
    on: {
      ready: function (m) {},
      messageSent: function (m) {},
      messageDelivered: function (m) {},
      messageIncoming: function (m) {},
      conversationChanged: function (m) {},
    },
  });
</script>

Options

All common options apply, plus:

OptionTypeRequiredDescription
agentIdstringnoScope the workspace to one agent.

Events

EventFires when
readyThe workspace has loaded and authenticated.
messageSentAn outbound message was sent.
messageDeliveredA sent message was delivered.
messageIncomingAn inbound message arrived.
conversationChangedThe agent opened a different conversation, or cleared the selection.

conversationChanged payload

Fires whenever the open conversation changes, so your page can stay in sync with what the agent is viewing. Every field is null when the selection is cleared.

FieldTypeDescription
customerIdstring | nullId of the customer whose conversation is now open.
namestring | nullCustomer display name.
identifierstring | nullCustomer phone number, in E.164 form.
conversationStatusstring | nullConversation status, e.g. OPEN.
unreadCountnumber | nullUnread messages in this conversation.
wabaIdstring | nullWhatsApp Business Account the conversation belongs to.

Notification sound

Team chat plays the incoming-message sound, so its iframe is granted autoplay in addition to clipboard-write. No microphone or camera access is requested.

Teardown

render returns an instance; call destroy() when you remove the embed (required in SPAs):

var instance = Embed.render("teamChat", {
  target: "#embed",
  authToken: "<jwt>",
});

// later…
instance.destroy();

How is this guide?

On this page