NAV
curl

Poll for new chat message

Check for new chat messages, recommend interval no more than 1-2 seconds. Please see the cURL tab to the right for an example.

GET /api/v1/chat/poll/{caseId}

Request Parameters

Data Type Description
caseId String Unique identifier of chat session. (Obtained from Start New Chat API response: POST /api/v1/chat)
index Integer The start index of chats to return. Default is 0.
isTyping Boolean Is the visitor currently typing a message? Default is false.

Sample Request

Please see the cURL tab to the right for an example.

// NOTE: Make sure to replace the "{api_key}" below with your API key!

curl -X GET \
  https://www.snapengage.com/api/v1/chat/poll/f383eadb-a15e-4d13-bda2-6f3bf412de62 \
  -H 'x-api-key: {api_key}'

Response Parameters

Data Type Description
caseId String Unique identifier of chat session.
agentTyping Boolean Is true if the agent is currently typing a message.
messageList Array An array of messages.
↳index Integer Index of the chat message in the transcript.
↳type String Either “agent” or “system”.
↳author String The agent alias.
↳text String The message that was sent.

Success Response

200 OK

Please see the json tab to the right for an example.

{
    "caseId": "f383eadb-a15e-4d13-bda2-6f3bf412de62",
    "messageList": [
        {
            "index": 2,
            "type": "system",
            "author": "Sam",
            "text": "/NIC Sam "
        },
        {
            "index": 3,
            "type": "system",
            "author": "Sam",
            "text": "/CAL 1 "
        },
        {
            "index": 4,
            "type": "system",
            "author": "",
            "text": "/NFO Just a moment...<br> "
        },
        {
            "index": 6,
            "type": "system",
            "author": "Sam",
            "text": "/SYS EMTR false "
        },
        {
            "index": 7,
            "type": "system",
            "author": "Sam",
            "text": "/SYS GRCP -1 "
        },
        {
            "index": 8,
            "type": "system",
            "author": "Sam",
            "text": "/SYS WAGT 6%2CSorry%2520for%2520the%2520delay.%2520We%27re%2520working%2520on%2520getting%2520to%2520you%2520as%2520quickly%2520as%2520possible.%2520If%2520you%2520need%2520to%2520run%2C%2520please%2520feel%2520free%2520to%2520%5Bleave%2520us%2520a%2520message%5D "
        },
        {
            "index": 9,
            "type": "system",
            "author": "Sam",
            "text": "/SYS REAS 16 "
        },
        {
            "index": 10,
            "type": "system",
            "author": "Sam",
            "text": "/NIC Sam "
        },
        {
            "index": 11,
            "type": "system",
            "author": "Sam",
            "text": "/CAL 1 "
        },
        {
            "index": 12,
            "type": "agent",
            "author": "Sam",
            "text": "hi "
        },
        {
            "index": 14,
            "type": "agent",
            "author": "Sam",
            "text": "Ok, I can help you with that! "
        }
    ],
    "agentTyping": false
}