Archives
Archives give you a real-time insight into every bot interaction and user input. They also provide you with valuable data about your visitors and guide you what adjustments you need to do to increase the efficiency of your chatbots.
Get list of chats
Returns a list of the last 40 chat archives. Learn more about Pagination here.
Request URL
curl --request GET \
--url https://api.chatbot.com/v2/chats \
--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}'
URL Parameters
Parameter | Type | Description |
---|---|---|
after |
Alphanumeric | required Last result timestamp (learn more) |
Pagination
The results are divided into pages, each containing 40 chats. To access next pages of the results, use ?after=ID
parameter.
The ID
is the value of the createdAt
field from the last chat (the timestamp), which then needs to be converted to milliseconds. This number of milliseconds specifies the “page” of the next results.
To easily convert createdAt
(the value in the ‘datetime’ format) to milliseconds, you can use any programming language converter, in the example below it is the most popular one used by our clients - JavaScript.
If the last result on the list has the value createdAt: 2021-07-27T15:19:54.069Z
, then you take the date and paste it into the following example (e.g. in the Chrome console, or directly in your code):
Number (new Date ('2021-07-27T15:19:54.069Z'))
After the conversion, the number in milliseconds will be returned. We paste this value into the ID
field in ?after=ID
to get the next page results, for example:
curl --request GET \
--url https://api.chatbot.com/v2/chats?after=1627399194069 \
--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}'
Response example
{
"id": "62b972235ce24a960007f98ebe",
"storyId": "62b123125358cb5610007835534",
"user": {
"id": "62123155c3ca7400007b5da78",
"name": "John",
"avatar": null
},
"source": "app",
"messages": [
{
"from": "bot",
"message": "Hello"
},
{
"from": "user",
"message": "Hi there!"
},
{
"from": "bot",
"message": "How can I help you?"
}
],
"createdAt": "2022-06-27T09:16:12.488Z",
"updatedAt": "2022-06-27T09:16:16.151Z"
},
{
"id": "62b1233551cb13ce000708c42f",
"storyId": "6231275358cb5610007835534",
"user": {
"id": "62b932350055a380007c950a6",
"name": "Peter",
"avatar": null
},
"source": "app",
"messages": [
{
"from": "bot",
"message": "Hi! How can I help you?"
},
{
"from": "user",
"message": "I have a question."
},
{
"from": "bot",
"message": "Go ahead."
}
],
"createdAt": "2022-06-27T09:16:01.022Z",
"updatedAt": "2022-06-27T09:16:09.012Z"
}
Get single chat
Returns a single chat data.
Request URL
curl --request GET \
--url https://api.chatbot.com/v2/chats/:chatId \
--header 'authorization: Bearer ${DEVELOPER_ACCESS_TOKEN}'
URL Parameters
Parameter | Type | Description |
---|---|---|
chatId |
Alphanumeric | required Chat ID |
Response example
{
"id": "62b1233e1e9826a9000725d604",
"storyId": "62b231d764d46a900079b92bf",
"user": {
"id": "62b12339e1e3ca7400007b269b5",
"name": "John",
"avatar": null,
"createdAt": "2022-06-22T22:56:30.504Z"
},
"source": "widget",
"attributes": {
"default_url": "https://www.example-site.com"
},
"messages": [
{
"id": "e9f449af-c757-457f-8cfe-4461c0c0ef74",
"requestId": "b87c-4893-80ed-1be66026e84e",
"date": "2022-06-22T22:56:30.689Z",
"score": 1,
"responses": [
{
"id": "01ff-41ab-b661-4f326d3666d1",
"type": "INPUT_WELCOME"
},
{
"id": "2708-4b55-84bf-8c37635c2849",
"type": "START_POINT"
},
{
"id": "7860-49f5-b6e3a-866e12fc8045",
"type": "BOT_RESPONSE",
"responses": [
{
"type": "text",
"delay": 500,
"message": "Hi"
}
]
}
]
},
{
"id": "124w-4bdc-b775-cfe3af6b7126",
"requestId": "cbbd-45bb-9d36-d48f414d4d5a",
"date": "2022-06-22T22:56:34.591Z",
"score": 1,
"responses": [
{
"id": "0288-4d81-b574-fdfac5482865",
"type": "INPUT_BUTTON",
"value": "Go to website",
"buttonId": "2017-4ecb-a317-3d7c094107fc"
}
]
}
],
"createdAt": "2022-06-22T22:56:30.691Z",
"updatedAt": "2022-06-22T22:56:34.591Z"
}