Featured tool
SDK Studio — sdk.raia.run
Use this hosted tool to configure and test the Live Chat widget. Generate your embed snippet, preview commands live, and copy the code into your app.
Launch SDK StudioGet your embed code from SDK Studio
- Open sdk.raia.run.
- In Agent, paste your Live Chat key into API Key. Leave Script URL as it is unless you were told to change it.
- Highlight 1: API Key: paste your Live Chat key here. This screenshot shows the placeholder YOUR_LIVE_CHAT_KEY.
- Highlight 2: Script URL: the widget script the snippet loads.
- Highlight 3: Inline embed (data-inline), Dev console (data-console-enabled) and Disable auto-open add options to the snippet. Disable auto-open isn't verified to work in the widget; use Auto-open mode no instead.
- Adjust Launcher, Behavior and Suggestions if you want to.
- In Generated code, choose HTML, Vanilla JS, React or Next.js, then click Copy.
- Highlight 1: Pick the code style for your site: HTML, Vanilla JS, React or Next.js.
- Highlight 2: data-api-key holds your key. Replace the placeholder with your own key.
- Highlight 3: Click Copy, then paste the code into your page.
Expected result: with a valid key, the live preview shows your widget. These screenshots use the placeholder YOUR_LIVE_CHAT_KEY, so the preview is blank. If your preview stays blank, check the key you pasted.

Command overview: use the SDK Studio command picker below to choose a supported command and inspect its settings.
Overview
The raia Live Chat SDK embeds the agent widget into your web app and lets you control it programmatically from JavaScript.
Embedding in a Zoho Desk Help Center?
Installation
Paste this script just before the closing </body> tag of your page. Copy the current snippet for your agent from its Live Chat settings rather than retyping it, and keep the script URL and version it gives you consistent across your pages. The example below uses the current widget script URL with a placeholder.
<script
src="https://raiabot.raia2.com/assets/raia-chatbot-widget.js"
data-api-key="{your-public-agent-id}"
defer>
</script>Security note
The window.raiaChat object
Once the script loads, the SDK exposes a global window.raiaChat object. You interact with the widget exclusively by sending commands through it.
window.raiaChat.sendCommand(COMMAND_TYPE, payload);SDK Studio's SDK commands list shows each command's friendly name next to the type you pass to sendCommand.
- Highlight 1: Each entry shows the friendly name and the command type to pass to sendCommand, for example openChat → OPEN_CHAT.
- Highlight 2: Add queues the command and runs it on the live preview when it is connected.
- Highlight 3: Read the note: commands run on the live preview and appear in the generated code.
Add runs the command
Widget control commands
| Command | Payload | Description |
|---|---|---|
OPEN_CHAT | { page?: string } | Opens the chat window. Optionally navigates to a specific internal page. |
CLOSE_CHAT | None | Closes the chat window, minimizing it to the launcher button. |
DESTROY | None | Completely removes the widget from the DOM and cleans up event listeners. |
User & context commands
| Command | Payload | Description |
|---|---|---|
SET_USER | { user: UserInfo } | Passes user identity (name, email, customData) to the agent. |
CLEAR_USER | None | Removes the current user identity. |
SET_CONTEXT | { context: string } | Sets global context that persists across the session. |
CLEAR_CONTEXT | None | Clears the global context. |
Conversation management commands
| Command | Payload | Description |
|---|---|---|
SEND_MESSAGE | { message: string } | Sends a message to the agent on behalf of the user. |
RESET_CONVERSATION | None | Clears the current chat history and starts a fresh conversation. |
DELETE_CHAT | None | Asks the widget to delete the current chat. This does not by itself prove that every stored copy or log is permanently removed; retention depends on your account's policies. |
SET_WELCOME_MESSAGE | { message: string } | Overrides the default welcome message dynamically. |
Example: identifying a signed-in user
A common use of the SDK is identifying a user after your own app has signed them in. Passing their details via SET_USER lets the agent address them by name and use their account context.
SET_USER is not sign-in
// After successful login
const userData = {
firstName: "Jane",
lastName: "Doe",
email: "jane@example.com",
customData: {
accountId: "12345",
planType: "enterprise"
}
};
window.raiaChat.sendCommand('SET_USER', { user: userData });Iframe setup
Use the Iframe SDK when you need to manage the chat container placement yourself. You embed the chat inside an <iframe> that you manage.
<div class="raia-chat-wrapper">
<iframe
id="raia-chat-iframe"
class="raia-chat-iframe"
src="https://raiabot.raia2.com/YOUR_AGENT_ID/chat"
allow="camera; microphone;"
></iframe>
</div>
<script src="https://raiabot.raia2.com/assets/raia-chatbot-iframe.js"></script>
<script>
const raiaIframeChat = new window.RaiaIframeChat({
iframeId: "raia-chat-iframe",
isSecurityKeyRequired: true, // set to false if you don't use an API key
});
window.addEventListener("DOMContentLoaded", () => {
raiaIframeChat.sendCommand("INIT", {
apiKey: "YOUR_API_KEY",
});
});
</script>Add Raia Live Chat to a Windows desktop app — Show your Live Chat agent beside your app's screens in a VB.NET WinForms or PxPlus app, using a hosted HTTPS page in an embedded browser.
SDK Command Reference (Iframe)
A plain iframe on its own has no command API. The Iframe SDK script shown above wraps it: create it with new window.RaiaIframeChat({ iframeId, isSecurityKeyRequired }), send INIT with { apiKey }, then use sendCommand. It waits for the chat to say it's ready, checks the message origin, and reports each command as accepted or rejected. It handles most Embed JS SDK commands, but CLOSE_CHAT, DESTROY and SET_VIEW_MODE are listed and not handled by the iframe wrapper, so don't rely on them there. Copy the iframe snippet from your agent's Live Chat settings so the page and script match. You send commands via the raiaIframeChat instance you created.
raiaIframeChat.sendCommand("OPEN_CHAT", { page: "chat" });
raiaIframeChat.sendCommand("SEND_MESSAGE", { message: "Hello!" });CSS Customization (Iframe)
With the Iframe SDK, you can style the <iframe> and its container. The internal chat UI is styled via your Live Chat Design settings.
/* Outer wrapper for the iframe */
.raia-chat-wrapper {
position: relative; /* or absolute/fixed */
width: 420px;
height: 600px;
max-height: 80vh;
border-radius: 24px;
overflow: hidden;
box-shadow: 0 18px 45px rgba(15, 23, 42, 0.45);
}
/* The iframe itself */
.raia-chat-iframe {
display: block;
width: 100%;
height: 100%;
border: none;
}Live Chat Security Key
Generate a Security Key in Live Chat settings to restrict access. Once enabled, the widget won't load unless you pass the key during initialization.
Generate a key, then add it to your widget initialization code.
Step 1: Generate a Security Key
First, you need to generate the key from your admin panel.
- Navigate to Live Chat > Security.
- In the Security Key and Origins section, click Generate Security Key.
- Copy the generated key immediately. You will need it for your code.
- Click Save to activate the key.
Widget blocked until initialized
Step 2: Add the Security Key to your embed
To unblock the chat, you must pass the security key when the widget loads. This is done by using the onload attribute on your script tag to call a function that sends the INIT command.
The Code Logic
- The standard chat widget script is loaded with the
asyncattribute. - The
data-api-keyattribute still contains your Agent ID. - The
onload="onRaiaChatLoaded()"attribute is added to the script tag. This tells the browser to execute theonRaiaChatLoadedfunction as soon as the script is finished loading. - Inside the
onRaiaChatLoadedfunction, you use the SDK commandraiaChat.sendCommand(). - You send the INIT command and pass an object containing the
apiKeyfield.
Important note
apiKey field inside the INIT command must contain your Security Key, not your Agent ID. Because this runs in the browser, the key is visible in your page source: it is a widget deployment key, not a server secret. These docs don't describe any signed-token (HMAC or JWT) setup.Code Implementation
Add the example below to your website, replacing the placeholder values with your Agent ID and Security Key.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Live Chat with Security Key</title>
<script>
// This function is called automatically when the chat widget script has loaded
async function onRaiaChatLoaded() {
// Send the INIT command with the Security Key
raiaChat.sendCommand("INIT", {
apiKey: "YOUR_SECURITY_KEY_HERE", // Paste the key you generated here
});
}
</script>
</head>
<body>
<h1>Your Page Content</h1>
<!-- The Raia Chatbot Widget Script -->
<script
async
src="https://raiabot.raia2.com/assets/raia-chatbot-widget.js"
data-api-key="YOUR_AGENT_ID_HERE"
onload="onRaiaChatLoaded()"
></script>
</body>
</html>Summary of Placeholders
| Placeholder | Your Value |
|---|---|
YOUR_SECURITY_KEY_HERE | The Security Key you generated in the admin panel. |
YOUR_AGENT_ID_HERE | The Agent ID from your Live Chat settings. |
Frequently asked questions
Can I open the chat when a user clicks a specific button on my site?
window.raiaChat.sendCommand('OPEN_CHAT').How do I style the widget to match my brand?
Does SET_USER create a new conversation?