Skip to main content

$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:

  • user requests;
  • events;
  • bot reactions;
  • agent messages.

Message fields:

FieldDescription
questionID

Message identifier.

If the bot responds to a user request or event, the questionID in the bot response will match the questionID in the request or event.

textMessage text. The field is not present if the message has no text.
authorAuthor:
  • CLIENT for user requests and events.
  • BOT for bot reactions.
  • OPERATOR for agent messages.
statusStatus:
  • SENT
  • DELIVERED
  • NOT_DELIVERED
  • READ
  • NOT_SENT
eventDataData passed with the event.
sendDateInUTCSent time in Unix format in the UTC timezone.

How to use

The method is called without arguments:

state: historyJson
q: dialog history in JSON format
a: {{ $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
}
]