Conversation History API

The Conversation History API can be used to fetch the conversational messages between the bot and user. This can also be a debugging tool that developers can use to expose chat logs and outputs—as a conversation with a chatbot is happening.

Note: To use this API, app needs the Bot Builder API scope of Chat History or the Admin API Scope of Chat History under Bot Analytics.

We have two types of calls: GET and POST

GET https://{{host}}/api/public/bot/{{BotID}}/getMessages?userId={{userID}}&skip=10&limit=10

A POST API call can also be used to include Session-Id and MetaTags in the retrieved Conversation History.

POST https://{{host}}/api/public/bot/{{BotID}}/getMessages
and https://{{host}}/api/public/getMessages for Bot Admin Console.

Implementation:

Sample Curl to pull the conversation history data. This curl can be called using the Postman.
(Open Postman > Import > Paste raw text > paste the following curl by replacing your own parameters)

curl -X GET \
  'https://bots.kore.ai/api/public/stream/st-59d03560-8722-5a69-b4c6-xxxxxxxxxxxx/getMessages?userId=u-f1xxxx1e-7096-xxxx-8369-24bxxxxxxxxxx&skip=0&limit=100&dateFrom=2020-04-01&dateTo=2020-04-30' \
  -H 'auth: eyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' 

In the above sample curl, you can replace with your own:

  1. Bot ID (st-59dxxxx)
  2. User ID (u-f1xxx)

You can provide offset/skip and limit to get a certain number of messages at a time.

If we want data related to any particular channel, we need to specify the channelType. If the channelType is not provided, by default it will take rtm as the channel type. (Optional)

Sample Curl:

curl -X GET \
  'https://bots.kore.ai/api/public/stream/st-59d03560-8722-5a69-b4c6-xxxxxxxxxxxx/getMessages?userId=u-f1xxxxxx-7096-xxxx-8369-xxxxxxxxxxx&skip=0&limit=100&dateFrom=2020-04-01&dateTo=2020-04-30&channelType=wfacebook' \
  -H 'auth: eyxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' 

Output:
image

For Conversation history API, upto one week worth of data can be extracted which means the dates can go back as far back as you have data available as long as the no.of days between the start and end date is 7 days.
Ex: start date = 7/01/2020 & end date = 7/07/2020

This API supports pagination.

For more information on Conversation History API, please refer to https://developer.kore.ai/docs/bots/api-guide/conversation-history-api/