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.

  1. Basic Request

{
    "token": "<token>",
    "userId": "<userid>",
    "userEmail": "<userEmail>",
    "channelId": "<channelId>",
    "data": {
        "text": "Contact live agent",
        "sessionVars": {},
        "reqId": "1",
        "isKL": false
    }
}
  1. 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"
    }
}
  1. 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
            }
        }
    }
}
  1. 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
        }
    }
}
  1. 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
        }
    }
}
  1. 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
        }
    }
}
  1. 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
        }
    }
}
  1. 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
        }
    }
}
  1. 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

Postman Collections for websockets cannot currently be exported. Please refer the screenshots below to setup and test your websocket using Postman.

Websocket request and response
Websocket variables / configurations
Setting up event listeners
Websocket settings

Sample Client Implementation

The ReadMe file in the package will help you configure and run the sample client.

Last updated