This page will help you get started with Chat Transcripts API.
Step 1: Call the "login" request. The result is a JSON object:
{
"failure": 0,
"sid": {
"accountId": 1,
"operatorId": 1,
"loginId": "c8e8dd39-0c12-4e5c-801c-cb6982db8631"
}
}
The "sid" is a token they will need to save. An encoded version of this token is needed for every request. This token is good for 5 minutes. After that, it will need to be refreshed (sync) or renewed (re-login).
Step 2: Encode the token by converting it to a string, and b64 encoding it. In JS it looks like this: var token = bota(JSON.stringify(sid)). Add the HTTP header "x-chatbeacon" to subsequent requests, and give it the value of the encoded token.
Step 3. Make a history request. The result is a JSON object with an array of chats:
{
"chats": [{
"ownerId": 0,
"acdRouted": false,
"hubSpotNoteId": 0,
"startTime": "2021-02-16T13:40:29.533Z",
"endTime": "2021-02-16T13:44:22.373Z",
"allowFiles": false,
"locked": false,
"operatorTyping": null,
"participants": {
"current": [],
"former": [],
"acceptingOperatorId": 1
},
"postChatSurvey": null,
"prechatSurvey": {
"chatId": 1,
"queueId": 1,
"submissionTime": null,
"type": 1,
"skipped": false,
"items": [{
"value": "",
"required": false,
"autoPopulate": false,
"id": 1,
"label": "name",
"type": 12,
"variableId": 0
}, {
"multiLine": false,
"value": "",
"required": false,
"autoPopulate": false,
"id": 1,
"label": "Company Name:",
"type": 1,
"variableId": 0
}, {
"sendTranscript": true,
"value": "",
"required": false,
"autoPopulate": false,
"id": 1,
"label": "Email Address",
"type": 6,
"variableId": 0
}, {
"multiLine": false,
"value": "",
"required": false,
"autoPopulate": false,
"id": 1,
"label": "Phone Number(optional):",
"type": 1,
"variableId": 0
}, {
"multiLine": false,
"value": "",
"required": false,
"autoPopulate": false,
"id": 1,
"label": "What is your question?",
"type": 1,
"variableId": 0
}],
"name": "",
"id": 0
},
"queue": {
"status": 0,
"overflowQueue": 0,
"requestTimeout": 0,
"hideButtonOffline": false,
"siteId": 1,
"message": null,
"fileSettings": null,
"activeChatLimit": 0,
"strings": null,
"sendTranscript": false,
"emailFrom": null,
"queueEmailAddress": null,
"stateNotifications": null,
"smsNumber": null,
"facebookPageToken": null,
"facebookPageId": null,
"distribution": null,
"callbackUrl": null,
"persistantChats": false,
"name": null,
"id": 1
},
"segments": null,
"sendCopy": false,
"sessionId": "92d4ff69-b1ee-4e16-a8ce-b9b4e053be3b",
"status": 6,
"translating": false,
"type": 1,
"priorChatId": 0,
"postChatId": 0,
"video": false,
"name": "smartmax",
"id": 1
}]
}