Surge

Conversation Component

The Conversation component shows a single message thread and a send field. Use it to embed a specific conversation in your application — useful when users navigate from your own inbox UI or when you want to open a specific thread.

Conversation component showing a single message thread with a composer at the bottom

Mount the component

<script src="https://embed.surge.app/v1/embed.js"></script>
<div id="surge-conversation"></div>
<script>
  SurgeEmbed.mount("conversation", {
    target: document.getElementById("surge-conversation"),
    token: "YOUR_USER_JWT",
    conversationId: "cnv_01jrzhe8d9enptypyx360pcmxk",
  });
</script>

Options

OptionTypeRequiredDescription
targetHTMLElementYesThe DOM element to mount the component into
tokenstringYesA signed JWT for the current End User
conversationIdstringNoThe ID of the conversation to display; omit to start a new conversation
onMessageSentfunctionNoCallback when the user sends a message; receives the message object
themeobjectNoCustom color and font overrides

Opening a new conversation

Omit conversationId to show an empty thread where the user can compose a new message. The component creates the conversation when the first message is sent.

SurgeEmbed.mount("conversation", {
  target: document.getElementById("surge-conversation"),
  token: "YOUR_USER_JWT",
  // No conversationId — starts a new conversation
  onMessageSent: (message) => {
    console.log("New message sent:", message.id);
  },
});