SDK Reference

Script tag attributes

Add to the <script> element that loads the widget.

AttributeDescription
data-raia-launcher-scriptRequired marker — identifies the launcher script tag.
data-agent-idAgent ID for the Raia chat skill to load.
data-inlineSet to 'true' to embed the widget inline instead of as a floating launcher.
data-console-enabledRender the in-page dev console for tweaking the widget live.
data-auto-open-disabledDisable any auto-open behavior configured on the agent.

window.raiaChat.sendCommand

Call window.raiaChat.sendCommand(type, payload) after the widget is ready. Returns a Promise that resolves when the iframe acknowledges the command.

init (API key)INIT_RAIA_CHAT
window.raiaChat.sendCommand("INIT_RAIA_CHAT", {
  "apiKey": ""
});
openChatOPEN_RAIA_CHAT
window.raiaChat.sendCommand("OPEN_RAIA_CHAT", {
  "page": "chat"
});
closeChatCLOSE_RAIA_CHAT
window.raiaChat.sendCommand("CLOSE_RAIA_CHAT");
sendMessageSEND_RAIA_CHAT_MESSAGE
window.raiaChat.sendCommand("SEND_RAIA_CHAT_MESSAGE", {
  "message": "Hello from the SDK"
});
setUserSET_RAIA_CHAT_USER
window.raiaChat.sendCommand("SET_RAIA_CHAT_USER", {
  "user": {
    "fkId": "",
    "firstName": "",
    "lastName": "",
    "email": "",
    "phoneNumber": "",
    "customData": {}
  }
});
clearUserCLEAR_RAIA_CHAT_USER
window.raiaChat.sendCommand("CLEAR_RAIA_CHAT_USER");
resetUserRESET_RAIA_CHAT_USER
window.raiaChat.sendCommand("RESET_RAIA_CHAT_USER");
setContextSET_RAIA_CHAT_CONTEXT
window.raiaChat.sendCommand("SET_RAIA_CHAT_CONTEXT", {
  "context": ""
});
clearContextCLEAR_RAIA_CHAT_CONTEXT
window.raiaChat.sendCommand("CLEAR_RAIA_CHAT_CONTEXT");
setConversationContextSET_RAIA_CHAT_CONVERSATION_CONTEXT
window.raiaChat.sendCommand("SET_RAIA_CHAT_CONVERSATION_CONTEXT", {
  "context": ""
});
deleteChatDELETE_RAIA_CHAT
window.raiaChat.sendCommand("DELETE_RAIA_CHAT");
enableCurrentPageTextENABLE_RAIA_CHAT_CURRENT_PAGE_TEXT
window.raiaChat.sendCommand("ENABLE_RAIA_CHAT_CURRENT_PAGE_TEXT");
disableCurrentPageTextDISABLE_RAIA_CHAT_CURRENT_PAGE_TEXT
window.raiaChat.sendCommand("DISABLE_RAIA_CHAT_CURRENT_PAGE_TEXT");
setWelcomeMessageSET_RAIA_CHAT_WELCOME_MESSAGE
window.raiaChat.sendCommand("SET_RAIA_CHAT_WELCOME_MESSAGE", {
  "message": "Welcome back 👋"
});
clearWelcomeMessageCLEAR_RAIA_CHAT_WELCOME_MESSAGE
window.raiaChat.sendCommand("CLEAR_RAIA_CHAT_WELCOME_MESSAGE");
patchSkillConfigPATCH_RAIA_CHAT_SKILL_CONFIG
window.raiaChat.sendCommand("PATCH_RAIA_CHAT_SKILL_CONFIG", {
  "suggestions": [
    "What can you do?"
  ]
});
setTextAreaAutofocusSET_RAIA_CHAT_TEXT_AREA_AUTOFOCUS
window.raiaChat.sendCommand("SET_RAIA_CHAT_TEXT_AREA_AUTOFOCUS", {
  "enabled": true
});
updateThemeUPDATE_RAIA_CHAT_THEME
window.raiaChat.sendCommand("UPDATE_RAIA_CHAT_THEME", {
  "themeMode": "auto",
  "lightTheme": {},
  "darkTheme": {}
});
destroyDESTROY_RAIA_CHAT
window.raiaChat.sendCommand("DESTROY_RAIA_CHAT");