Websocket
Setup
Complete the steps mentioned in the Setup guide.
Use
Use the following code to review conversation message types that you can use with the Aisera Conversation Websocket.
Most other usage details are same as those for the Conversation API.
Sample Requests
You can use the following sample payloads to create requests using websockets with the Conversation Websocket.
Basic Request
{
"token": "<token>",
"userId": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"text": "Contact live agent",
"sessionVars": {},
"reqId": "1",
"isKL": false
}
}
Interactive Requests
{
"token": "<token>",
"userId": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"sessionVars": {},
"isKL": false,
"userFullName": "Mark Smith",
"text": "This is what I was looking for",
"reqId": "REQ123",
"followUpId": "R:0e70f8b8-6f6c-4ee5-8d26-6a8375e9bcea"
}
}
Form Submit Requests
{
"token": "<token>",
"userid": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"sessionVars": {},
"isKL": false,
"userFullName": "Mark Smith",
"text": "",
"reqId": "REQ123",
"channelCapabilities": {
"isFormSupported": true
},
"followUpData": {
"formId": "bcbed7df-951f-4369-b5f0-443ef31e2372",
"formFieldValues": {
"simpleStringSample": "Quick brown fox",
"textAreaSample": "The quick brown fox jumps over the lazy dog.",
"dateSample": "2021-11-17",
"dropdownSample": "option3",
"radiosSample": "option2",
"multiSelectCheckboxesSample": ["check1", "check2"],
"numberSample": 6,
"booleanSample": true
}
}
}
}
SessionVar Requests
{
"token": "<token>",
"userid": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"isKL": false,
"channelId": "f9975e56-84dd-cbfb-e171-1785ae4b1282",
"userFullName": "Mark Smith",
"text": "test sessionVars",
"reqId": "REQ123",
"sessionVars": {
"myVar": "someValue"
},
"channelCapabilities": {
"isFormSupported": true,
"isPopupSupported": false
}
}
}
Needs Session History Requests
{
"token": "<token>",
"userid": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"sessionVars": {},
"isKL": false,
"userFullName": "Mark Smith",
"needsSessionHistory": true,
"reqId": "REQ123",
"channelCapabilities": {
"isFormSupported": true,
"isPopupSupported": false
}
}
}
IsReset Requests
{
"token": "<token>",
"userid": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"sessionVars": {},
"isKL": false,
"userFullName": "Mark Smith",
"isReset": true,
"reqId": "REQ123",
"channelCapabilities": {
"isFormSupported": true,
"isPopupSupported": false
}
}
}
Logout User - Finish Current Session
{
"token": "<token>",
"userid": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"sessionVars": {},
"isKL": false,
"userFullName": "Mark Smith",
"text": "/logout",
"reqId": "REQ123",
"channelCapabilities": {
"isFormSupported": true,
"isPopupSupported": false
}
}
}
Go Back
{
"token": "<token>",
"userid": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"sessionVars": {},
"channelId": "f9975e56-84dd-cbfb-e171-1785ae4b1282",
"userFullName": "Mark Smith",
"followUpId": "_go:back_",
"followUpContext": {
"type": "FlowGoBack"
},
"reqId": "REQ123",
"channelCapabilities": {
"isFormSupported": true,
"isPopupSupported": false
}
}
}
Start Over
{
"token": "<token>",
"userid": "<userid>",
"userEmail": "<userEmail>",
"channelId": "<channelId>",
"data": {
"sessionVars": {},
"userFullName": "Mark Smith",
"followUpId": "_go:back_",
"followUpContext": {
"type": "FlowStartOver"
},
"reqId": "REQ123",
"channelCapabilities": {
"isFormSupported": true,
"isPopupSupported": false
}
}
}
Websocket Client Files
Your Aisera team can provide you with a .zip package for a websocket client. If you don't receive the .zip package, you can build one using the following files.
Message Types
// modeType in conversation server response
LiveAgentResponse: "LiveAgent",
LiveAgentWaiting: "LiveAgentWaiting",
LiveAgentJoined: "LiveAgentJoined",
LiveAgentExited: "LiveAgentExited",
LiveAgentWaitingUpdate: "LiveAgentWaitingUpdate",
LiveAgentTyping: "LiveAgentTyping",
Error: "Error",
FormError: "FormError",
ExternalSystemError: "ExternalSystemError",
FlowStarted: "FlowStarted",
FlowCompleted: "FlowCompleted",
SilentModeAnswerFound: "SilentModeAnswerFound",
SilentModeAnswered: "SilentModeAnswered",
SilentModeAnsweredConfidentially: "SilentModeAnsweredConfidentially",
SilentModeFirstResponse: "SilentModeFirstResponse",
SilentModeResolved: "SilentModeResolved",
SilentModeEscalated: "SilentModeEscalated",
SilentModeTicketCreated: "SilentModeTicketCreated",
SilentModeCancelled: "SilentModeCancelled",
SilentModeFollowUp: "SilentModeFollowUp",
SilentModeConversationEnded: "SilentModeConversationEnded",
SilentModeStopResponding: "SilentModeStopResponding", // Not sent from/to conversation server; handled by chatbot
// type in conversation server requests
LiveAgentPickUp: "LiveAgentPickUp",
LiveAgentCompleted: "LiveAgentCompleted",
LiveAgentTransfer: "LiveAgentTransfer",
SessionTimeout: "SessionTimeout",
EndSessionSurvey: "EndSessionSurvey",
// streaming responses
StatusUpdate: "StatusUpdate",
StreamingInProgress: "StreamingInProgress", // RAG answer in progress
StreamingCompleted: "StreamingCompleted", // RAG answer completed
// campaign
Campaign: "Campaign",
AskForApproval: "AskForApproval"
Postman Collection




Sample Client Implementation
The ReadMe file in the package will help you configure and run the sample client.
Last updated