Live Chat SDK
The following is SDK Documentation on how to customize the Live Chat experience.
Live Chat Customization
To pass variables to the Live Chat can be done using our SDK. This is important if you want to pass information to the AI Agent (via Live Chat) much like you pass via our API.
You can do the following:
Set User - This will add the user into raia for tracking / memory
Set Context - This provide context of the conversation for the AI Agent.
Command usage:
// 1. Open the chat
raiaChat.sendCommand('OPEN_CHAT', { page: 'chat' });
// 2. Close the chat
raiaChat.sendCommand('CLOSE_CHAT');
// 3. Send a message
raiaChat.sendCommand('SEND_MESSAGE', { message: 'Hello! I need some help.' });
// 4. Set user info
raiaChat.sendCommand('SET_USER', {
user: {
fkId: 'abc123',
fkUserId: 'user456',
firstName: 'Jane',
lastName: 'Doe',
email: 'jane@example.com',
phoneNumber: '+1234567890',
},
});
// 5. Clear user
raiaChat.sendCommand('CLEAR_USER');
// 6. Set context
raiaChat.sendCommand('SET_CONTEXT', { context: 'checkout_support' });
// 7. Clear context
raiaChat.sendCommand('CLEAR_CONTEXT');
Important: To use raiaChat.sendCommand
, make sure the script is loaded before calling it. Example:
<script>
function onRaiaChatLoaded() {
raiaChat.sendCommand("OPEN_CHAT", { page: "chat" });
raiaChat.sendCommand("SET_CONTEXT", { context: "test context" });
raiaChat.sendCommand("SET_USER", {
user: { email: "test@test.com" },
});
}
</script>
<script
async
src=""
data-api-key="5ac087fb-06d2-4219-8bae-b393c8db549f"
onload="onRaiaChatLoaded()"
></script>
Example integration can be found here https://codesandbox.io/p/sandbox/4w5g86
Last updated