There are two ways to put raia Chat on a page. The script embed loads the widget and exposes window.raiaChat, which accepts commands through sendCommand(type, payload). The iframe embed renders the widget inside a frame; your page can still talk to it with browser messages, but those use different internal names, so follow the iframe example in the developer guide.
In this section
- Use the script embed for most websites: it adds the chat button to every page and gives you the most control. Use the iframe to place the chat in a specific spot on a page, or if your website builder doesn’t allow scripts.
- Install the script snippet and open or close the widget with sendCommand.
- Pass user details for context only — they are not proof of identity.
- Use the documented widget messages and check acknowledgments when wiring commands.
What's inside
- 01
Script embed (SDK)
Copy the snippet for your agent from your account and paste it just before the closing </body> tag on your page. The script reads data-api-key. Once loaded, window.raiaChat is available. Example (illustrative): window.raiaChat.sendCommand("OPEN_CHAT", { page: "chat" }) and window.raiaChat.sendCommand("CLOSE_CHAT").
Worked example
The examples use fictional data. Follow the same checks with approved, non-sensitive information for your own task.
Open the agent, then Launch. This screenshot shows a Private agent. To try it through Live Chat, first use an agent intended for public access and set Agent Status to Public, then select Test Agent. Private is not a working Live Chat test state. Check the agent’s knowledge and enabled tools before making it publicly accessible.
Launch tab showing Private status. Live Chat testing requires Public status. - Highlight 1: Launch tab
- Highlight 2: View Embed Code
- Highlight 3: Agent Status
- 02
Iframe embed
Place the iframe on a page or CMS block. A plain iframe just shows the chat. To control it from your page, add the Iframe SDK wrapper and use its sendCommand (see the developer guide). The wrapper handles OPEN_CHAT but not CLOSE_CHAT, DESTROY or SET_VIEW_MODE, so it can't do everything the script embed can.
- 03
User context
SET_USER and SET_CONTEXT pass details from the browser. They help the agent personalize replies but are not authentication. Keep access decisions in your own backend.
- 04
Widget messages
The current widget posts messages such as RAIA_CHAT_LISTENER_READY, RAIA_CHAT_INIT_READY, RAIA_CHAT_COMMAND_ACK / NACK and RAIA_CHAT_NEW_MESSAGE_RECEIVED. Listen for these with window.addEventListener("message", …). Event hooks such as "conversation started" or "escalation raised" aren’t documented yet.
At a glance
| Capability | SDK | Iframe |
|---|---|---|
| Open / close | Yes — sendCommand("OPEN_CHAT") / sendCommand("CLOSE_CHAT") | Open only, with the Iframe SDK wrapper (OPEN_CHAT); CLOSE_CHAT is not handled |
| User details | SET_USER (not authentication) | SET_USER with the Iframe SDK wrapper (not authentication) |
| Event API | Widget messages only; no documented event hooks yet | Widget messages only; no documented event hooks yet |
| Send a message | SEND_MESSAGE | SEND_MESSAGE with the Iframe SDK wrapper |
| Setup effort | One snippet plus optional wiring | Iframe snippet; add the wrapper script for programmatic control |
Security