Programmatic Control Example

Control the chat programmatically using refs and method calls.

Control Panel
Live Chat
Uses the playground credentials saved in this browser (API key, agent ID, and environment). Configure them in any component playground, e.g. Embedded Chat. Without them the chat only returns canned demo responses.
Programmable Assistant
Code Example
<button id="send-btn">Send Message</button>
<button id="clear-btn">Clear Chat</button>
<div id="chat-container" style="height: 600px"></div>

<!-- SuperIntern SDK -->
<script src="https://cdn.superintern.ai/sdk/embed.global.js" defer></script>
<script>
  window.addEventListener("load", function () {
    // The returned widget instance exposes the chat methods
    const chat = SuperIntern.EmbeddedChat("#chat-container", {
      baseSettings: {
        apiKey: "YOUR_API_KEY",
        agentId: "your-agent-id",
        environment: "production", // "production" (default) or "test"
      },
    });

    document.getElementById("send-btn").addEventListener("click", function () {
      chat.submitMessage("Hello!");
    });

    document.getElementById("clear-btn").addEventListener("click", function () {
      chat.clearChat();
    });

    // Also available:
    //   chat.updateInputMessage(message)
    //   chat.focusInput()
    //   chat.update(partialConfig)
    //   chat.unmount()
  });
</script>