Skip to content

raia Chat · Section

SDK & Embed Guide

JavaScript SDK and iframe integration.

Before you start, make sure you’ve read the raia Chat overview.

Recommended practice

Open your page with the installed widget and send a short test message. Copy method names and the script URL from the Live Chat SDK developer guide.

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.
01

What's inside

  1. 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.
    1. Highlight 1: Launch tab
    2. Highlight 2: View Embed Code
    3. Highlight 3: Agent Status
  2. 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.

  3. 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.

  4. 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.

02

At a glance

CapabilitySDKIframe
Open / closeYes — sendCommand("OPEN_CHAT") / sendCommand("CLOSE_CHAT")Open only, with the Iframe SDK wrapper (OPEN_CHAT); CLOSE_CHAT is not handled
User detailsSET_USER (not authentication)SET_USER with the Iframe SDK wrapper (not authentication)
Event APIWidget messages only; no documented event hooks yetWidget messages only; no documented event hooks yet
Send a messageSEND_MESSAGESEND_MESSAGE with the Iframe SDK wrapper
Setup effortOne snippet plus optional wiringIframe snippet; add the wrapper script for programmatic control

Security

Keep secret keys on your server. Put only the value your account snippet uses in browser code. Before sharing the widget, check it loads on your site and is blocked on a site that isn’t allowed.
03

Related