Socket API Chat Library that correspond to processes that transform your Custom Channel into a fully functional AI Chatbot.
This is the Chat Library of the Socket API that is currently available and compatible with the Captivate Chat platform. These are all intended to create processes that will transform your Custom Channel into a full-blown AI Chatbot.
Send this event to start a new conversation in Captivate Chat. On successful creation, expect to receive bot_messages and be able to send user_messages.
Emit : Yes
Receive : No
Payload :
conversation_start (with metadata)
This action initiates a new conversation for a specific user and allows you to attach metadata, such as user details.
Emit: Yes
Receive: No
Payload:
conversation_start_success
This event is received event to start a new conversation in a Captivate Flow.
On successful creation, expect to receive bot_messages immediately with the same conversation_id received here. Consider this as a confirmation that conversation start request has been successful.
Emit : No
Receive : Yes
Payload :
user_message
User messages sent from the client application.
Emit : Yes
Receive : No
Payload
bot_message
Bot messages sent from the Chat Flow.
Emit : No
Receive : Yes
Payload showing the model of the bot_message content
Payload example
sendMessage (with files)
This action sends a message from a user and includes file attachments.
Emit: Yes
Receive: No
Payload:
livechat_message
Live Chat messages sent from the connected live chat application (Slack, MS Teams, Freshdesk, etc.).
Emit : No
Receive : Yes
Payload
metadata
Metadata that can be set from the client application. This Captivate Chat document details how and why metadata is used in Captivate Chat. Examples of metadata that can be set are channel user data and sending preconfigured data depending on where the user is on the website. This metadata will be saved in Captivate Chat sessions and can be retrieved if required.
Emit : Yes
Receive : No
Payload
action
Aside from messages, actions can also be exchanged by the client application and Captivate Chat. Actions can be used for triggering events on both sides.
For example, a reserved CH action βescalateToHumanβ can be emitted from the client application for this example scenario:
There is button in the Web Widget that the user can click to ask for a Live Chat agent for assistance. Client application should then emit an action to Captivate Chat, and the Chat Flow will handle the action accordingly.
It is also possible to receive an action from Captivate Chat for an example scenario:
A user asks the chatbot βHow do I reach youβ, the chatbot then recognizes this and sends an outgoing action back to the channel with a title βredirectToContactUsβ. It is up to the client application developer then to utilize the action received.
Emit : Yes
Receive : Yes
Payload
conversation_transcript_request
Send this event to request for the conversation transcripts associated with a socket connection. Expect to receive a conversation_transcript event as a response.
Emit : Yes
Receive : No
Payload :
get_conversations
Request the list of Conversation IDs for a specific user by providing their userId
Emit: Yes
Receive: Yes
Payload:
Sample Response:
delete_conversation
This action removes an existing conversation using conversation_id.
Emit: Yes
Receive: No
Payload:
delete_conversation (all conversations)
This action removes all existing conversation using userId
Emit: Yes
Receive: No
Payload:
delete_conversation_success
When a conversation is deleted, the server sends an event called delete_conversation_success.
This event provides confirmation that the deletion has happened.
Emit: No
Receive: Yes
Payload:
metadata_request
This action retrieves the metadata for a specific conversation using the conversation's unique ID (idChat).
Emit: Yes
Receive: Yes
Payload:
conversation_transcript
The returned transcript in response to conversation_transcript_requestevent.
Emit : No
Receive : Yes
Payload :
Payload example with user, agent, and bot messages:
conversation_update
Updates specific to a conversation session. Details for updates types will be provided in the next documents.
Emit : No
Receive : Yes
Payload :
general_error
Sent during errors.
Emit : No
Receive : Yes
Payload
Example β at the moment, this Invalid conversation_Id is the only possible error returned.
{
"action": "sendMessage",
"event": {
"event_type": "conversation_start",
"event_payload": {
// userId - optional. if not provided, CH will assign "anon" as the userId.
"userId": "super-unique-user-id",
// userBasicInfo - optional. if provided, basic info is sent in livechat and chatbot
"userBasicInfo": { //optional
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]"
//DEV NOTE: Add phone number nalang here
},
// userData - optional. if provided, basic info is sent in livechat and chatbot
"userMetadata": {
}
//DEV NOTE: CHANGE TO userMetadata, metadata updates will be pushed here too.
}
}
}
{
"action": "sendMessage",
"event": {
"event_type": "user_message",
"event_payload": {
"type": "message_create",
"client_msg_id": "unique-message-id", // Unique message ID to be set by client, UUID type format is preferable.
"conversation_id": "temp123-aaaaa-aaaa", //Unique conversation session ID from Captivate Hub
"content": {
"type" : "text", // current supported type
"text": "hello"
}
}
}
}
{
"action": "receiveMessage",
"event": {
"event_type": "bot_message",
"event_payload": {
"type": "message_create",
"ch_msg_id": "f14efe6e-773a-4a52-85f5-90b6d801f2d1",
"bot": {},
"content": [{
// current supported types
"type" : "text || buttons || cards",
// sent only when type is "text"
"text" : "bot text message",
// sent only when type is "buttons"
"buttons" : {},
// sent only when type is "cards"
"cards" : {}
}]
},
"event_id": "Vp6x7GxOLPEFb7A=",
"accepts_response_payload": false
}
}
{
"action": "receiveMessage",
"event": {
"event_type": "bot_message",
"event_payload": {
"type": "message_create",
"ch_msg_id": "f14efe6e-773a-4a52-85f5-90b6d801f2d1",
"bot": {},
"content": [
{
"text": "Hi. I'm the Captivate Bot.",
"type": "text"
},
{
"text": "You can leave us your contact details or you can chat to us directly now!",
"type": "text"
},
{
"type": "button",
"buttons": {
"title": "Please choose from one of the following:",
"options": [
{
"label": "Leave Contact Details",
"value": "Leave Contact Details"
},
{
"label": "Chat to Agent",
"value": "Chat to Agent"
}
]
}
}
]
},
"event_id": "Vp6x7GxOLPEFb7A=",
"accepts_response_payload": false
}
}
{
"action": "sendMessage",
"event": {
"event_type": "action",
"event_payload": {
"type": "normal", // type can be utilized by developers, but by default this is set to "normal"
"id": "escalateToHuman", // Action ID Java
"data": {}, //Object to contain any custom supporting data for the action
"conversation_id": "temp123-aaaaa-aaaa"
}
}
}
{
"action": "receiveMessage",
"event": {
"event_type": "conversation_transcript",
"event_payload": {
"conversation_id": "hart_acb3b13e-4818-40fa-b57e-d8a80feba5c1",
"transcript": [
{
"event_id": "event id",
"messages": [
{
"actions": [], // if there are actions
"files": [], // if there are files
"from": "user || chatbot || livechat",
"chatbotName": "Name of chatbot in your hub if there is",
"channelName": "Name of channel in your hub",
"livechatName": "Name of livechat in your hub if there is",
//Array of chronological message contents
"messages": [
{
"type": "text || buttons || cards",
"text": "Actual message if type is text",
"buttons": {
// buttons if type is buttons
"title": "Choose from the following:",
"options": [
{
"label": "button label 1",
"value": "button value 1"
}
]
}
}
]
}
]
}
]
},
"event_id": "WvVB-EB6rPEFkJQ=",
"accepts_response_payload": false
}
}
{
"action": "receiveMessage",
"event": {
"event_type": "conversation_update",
"event_payload": {
"type": "failedAgentAssignment || livechatAgentConnected || livechatAgentDisconnected",
"conversation_id": "Captivate Hub Session ID",
"data": {} // data relevant to the type of conversation update, for example, if update is livechatAgentConnected, then this would contain the agentInfo
}
}
}