Start a chat
isChatOnly: true when your server asks for the token.
The agent’s greeting arrives as its first message.
Send the visitor’s message
sendMessage() throws if the chat hasn’t started, or if the text is empty. chatMessageReceived brings you the agent’s messages, so show the visitor’s message yourself when they send it, as above.
Show the agent’s replies as they stream in
chatMessageReceived fires several times for one reply while the agent writes it, then once more when it’s complete. Each message has:
Show that the agent is typing
End the chat
Good to know
chatMessageReceivedfires only for chats.messageReceivedalso fires for chat, but it fires for voice transcripts as well, so preferchatMessageReceivedfor a chat window.- In a chat, the voice events (
transcriptionReceived,answerReceived) and the audio events don’t fire. - A chat is a call: it has a
jobId, shows in Call history, and sends the agent’s webhook.
Related
Events
Every event the SDK sends.
Start calls
Keys, call tokens, and why a chat can’t start.