$jsapi.chatHistoryJson
The $jsapi.chatHistoryJson()
method returns the detailed dialog history of the current session in the JSON format.
In this format, you can send the history to external systems.
A history is a list of various messages:
Message fields:
Field | Description |
---|---|
questionID | Message identifier. If the bot responds to a user request or event, the |
text | Message text. The field is not present if the message has no text. |
author | Author:
|
status | Status:
|
eventData | Data passed with the event. |
sendDateInUTC | Sent time in Unix format in the UTC timezone. |
How to use
The method is called without arguments.
- ECMAScript 5
- ECMAScript 6
state: historyJson
q: dialog history in JSON format
a: {{ $jsapi.chatHistoryJson() }}
In the ECMAScript 6 runtime, the method is asynchronous:
state: historyJson
q: dialog history in JSON format
scriptEs6:
$reactions.answer(await $jsapi.chatHistoryJson());
History example:
[
{
"questionId": "example1-0000-0000-0000-000000000000",
"text": "How do I buy a ticket?",
"author": "CLIENT",
"status": "SENT",
"eventData": {},
"sendDateInUTC": 1713883656
},
{
"questionId": "example1-0000-0000-0000-000000000000",
"text": "You can buy a ticket online: https://example.com/buy",
"author": "BOT",
"status": "SENT",
"eventData": {},
"sendDateInUTC": 1713883656
},
{
"questionId": "example2-0000-0000-0000-000000000000",
"author": "CLIENT",
"status": "SENT",
"eventData": {
"example": "data"
},
"sendDateInUTC": 1713883656
},
{
"questionId": "example2-0000-0000-0000-000000000000",
"text": "Download the ticket: https://example.com/ticket",
"author": "BOT",
"status": "SENT",
"eventData": {},
"sendDateInUTC": 1713883656
}
]