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:

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/

1 Like

@sadhvi.chandra

When I try those methods, It’s fetching me the old conversation history which happened 3 or 4 months ago. I’m not able to get the latest history by filtering the date also. If you know, kindly drop out a reply.

@praveen.r1,

Please check and let us know if you are observing a value to the “moreAvailable” attribute in the API response.

If “moreAvailable” shows a number, please set the skip value to 100 and check if you are observing the required response.

Kindly send us the API response screenshots if you are still observing the issue even after setting skip parameter.

Regards,
Yoga Ramya

@yogaramya.mendu

The “moreAvailable” is true when I made a postman request. Then, As you said I set the skip value to 100 and checked for the response.

Again I’m getting the same Old conversation history that happened 3 or 4 months ago.

Kindly help me. This needs to be implemented ASAP.

convFirst convSec

Hi,

I’m trying to filter conversations using custom tags. But I couldn’t find a proper explanation on documentation how pass the request body parameter “tags”. This is what tried:

{
    "skip": 0,
    "limit": 100,
    "dateFrom": "2022-03-20",
    "dateTo": "2022-03-24",
    "channelType": "rtm",
    "tags":[{
        "name"  : "LocationSearch",
        "values"  : ["True"],
        "type"    : "session" }]
}
{
    "skip": 0,
    "limit": 100,
    "dateFrom": "2022-03-20",
    "dateTo": "2022-03-24",
    "channelType": "rtm",
    "tags":{ 
        "name"  : "LocationSearch",
        "values"  : ["True"],
        "type"    : "session" 
    }
}

So far none worked. Please help :slight_smile:

Hello @lalankarage ,

Try using it as below:

tags  : {
		 and: [ {
			        “name”  : ”LocationSearch”,
			        “values”  : [“True”],
                    “type”    : “session” 	
                }
              ]	
 }

Hello @sameera.tumuluri,

I tried but this is also not working.

@lalankarage ,

If the data is developer tested records, then you will need to include isDeveloper condition as true as well.
If even with that data is not seen, share the response you receive, and the complete curl.

Thanks it works! Yes, the data is developer tested records.