Chatbot Overview
Conversational Bots
Intents & Entities
Intelligent Bots
Kore.ai's Approach
Kore.ai Conversational Platform
Bot Concepts and Terminology
Natural Language Processing (NLP)
Bot Types
Bot Tasks
Starting with Kore.ai Platform
How to Access Bot Builder
Working with Kore.ai Bot Builder
Building your first Bot
Getting Started with Building Bots
Using the Dialog Builder Tool
Creating a Simple Bot
Release Notes
Latest Updates
Older Releases
Bot Builder
Creating a Bot
Design
Develop
Dialog Task
Working with User Intent Node
Working with the Dialog Node
Working with Entity Node
Supported Entity Types
Working with Composite Entities
Supported Time Zones
Supported Colors
Supported Company Names
Working with Message Nodes
Working with the Confirmation Nodes
Working with Service Node
Implementing Custom Authentication
Enabling 2-way SSL for Service nodes
Working with Script Node
Working with Agent Transfer Node
Working with WebHook Node
Defining Connections & Transitions
Managing Dialogs
Prompt Editor
Action & Information Task
Working with Action Tasks
Working with Information Tasks
Establishing Flows
Alert Tasks
Working with Alert Tasks
Managing Ignore Words and Field Memory
Knowledge Graph
Terminology
Building Knowledge Graph
Generation of Knowledge Graph
Importing and Exporting Knowledge Graph
Knowledge Graph Analysis
Knowledge Extraction
Natural Language
Overview
Machine Learning
ML Model
Fundamental Meaning
Knowledge Graph Training
Traits
Ranking and Resolver
NLP Detection
NLP Settings and Guidelines
Bot Intelligence
Overview
Context Management
Session and Context Variables
Context Object
Dialog Management
Sub-Intents
Amend Entity
Multi-Intent Detection
Sentiment Management
Tone Analysis
Sentiment Management
Default Conversations
Default Standard Responses
Channel Enablement
Test & Debug
Talking to Bot
Utterance Testing
Batch Testing
Recording Conversations
Publishing your Bot
Analyzing your Bot
Overview
Dashboard
Custom Dashboard
Conversation Flows
Bot Metrics
Advanced Topics
Bot Authorization
Language Management
Collaborative Development
IVR Integration
Universal Bots
Defining
Creating
Customizing
Enabling Languages
Smart Bots
Defining
Sample Bots
Github
Asana
Travel Planning
Flight Search
Event Based Bot Actions
Bot Settings
Bot Functions
General Settings
PII Settings
Customizing Error Messages
Bot Management
Using Bot Variables
API Guide
API Overview
API List
API Collection
SDKs
SDK Overview
SDK Security
SDK App Registration
Kore.ai Web SDK Tutorial
Message Formatting and Templates
Mobile SDK Push Notification
Web Socket Connect & RTM
Using the BotKit SDK
Installing the BotKit SDK
BotKit SDK Configuration
Events for the BotKit SDK
Functions for the BotKit SDK
BotKit SDK Tutorial – Agent Transfer
BotKit SDK Tutorial – Flight Search Sample Bot
Using an External NLP Engine
Bot Administration
Bots Admin Console
User Management
Managing Users
Managing Groups
Managing Role
Bots Management
Enrollment
Inviting Users
Sending Bulk Invites to Enroll Users
Importing Users and User Data
Synchronizing Users from Active Directory
Security & Compliance
Overview
Using Single Sign-On
Cloud Connector
Analytics
Billing
Bot Store
Overview
Creating a Kore.ai Bot Account
Adding a Kore.ai Bot
Choosing a Channel for a Bot
Interacting with a Kore.ai Bot
Setting Up Web Service Alerts
Setting Up RSS Alerts
Setting Up the Kore.ai Webhook Bot
Custom Kore.ai Bots
Bots for your Customers FAQs
Bots for your Workforce FAQs
Adding Bots
Contacting Kore.ai Support
Setting Up Filters
Bot Store Settings
How Tos
Context Switching
Using Traits
Live Agent Transfer
Schedule a Smart Alert
Configure Agent Transfer
Custom Dashboard
  1. Home
  2. Docs
  3. Bots
  4. API Guide
  5. Conversation History API

Conversation History API

Fetches the conversational messages between the bot and user in reverse chronological order. This API supports pagination. You can provide offset/skip and limit to get a certain number of messages at a time.

This is a newer version of the old API which will soon be deprecated. This revised API addresses the limitation of the older version on enabling BotKit or Agent Transfer.

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.

Get https://{{host}}/api/public/stream/{{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/stream/{{BotID}}/getMessages
and https://{{host}}/api/public/getMessages for Bot Admin Console

Parameters

Parameter Description
BotID (optional) Bot ID. You can access it from the bot’s General Settings page.
userId (optional) The ID of the user whose conversation history to access. Can be user email id or enterprise assigned unique id.
skip/offset (optional) The number of messages to be skipped.
limit (optional) The number of messages to be shown on each page.
forward (optional) Takes boolean values true/false. Specifies the direction of the messages to be retrieved.

  • If the value is true, then the conversation history is retrieved in the order old to the most recent one.
  • If the value is false, then the conversation history is retrieved in the reverse order i.e, the most recent to the oldest message
dateFrom (optional) Takes the date format yyyy-mm-dd
(or) yyyy-mm-ddThh:mm:ss.msZ
eg:2019-04-01 (or) 2019-04-01T13:25:58.515ZIf not provided, calculated as 7 days behind dateTo.
dateTo (optional) Takes the date format yyyy-mm-dd
(or) yyyy-mm-ddThh:mm:ss.msZ
eg:2019-04-01 (or) 2019-04-01 T13:26:05.598ZIf not provided, calculated as 7 days from dateFrom. If dateFrom is also not provided then set to Today.
channelType (optional) Name of the channel of whose conversation history is needed, default is ‘rtm’ .

Accepted channel types are “skypeforbusiness”, “msteams”, “twitter”, “spark”, “rtm”, “facebook”, “slack”, “skype”, “kore”, “email”, “sms”, “wfacebook”, “ringcentral”, “jabber”, “yammer”, “alexa”, “twiliovoice”, “telegram”, “ivr”, “ivrVoice”, “line”, “liveperson”, “googleactions”, “hangoutchat”, “mattermost”, “rcs”.

Note: In case of multi-webhook channel configuration, “ivr” will give the conversations for the first WebHook instance. For those related to other instance, specify the ivrInstID, you can get it from the WebHook URL which is of the form: {{host_url}}/chatbot/hooks/{{BotId}}/hookInstance/{{ivrInstID}})

msgId (optional) A specific Message-Id if known.
direction (optional when msgId is given)
  • <0 reverse
  • =0 bidirectional
  • >0 forward
sessionId (optional) A specific Session-Id if known. Refer here to obtain the session id
tags (optional) Meta tags to filter the conversations.

Note: The duration between dateTo and dateFrom should be less than 7 days, else an error will be thrown.

Authorization

Invoke the API with JWT in the header with the following syntax:

auth: {{JWT}}

Response content type

application/JSON

Sample Request

curl -X GET \
'https://bots.kore.ai/api/public/stream/{{BotId}}/getMessages?userId=u-XXX-XXX&
channelType=facebook&dateFrom=2019-04-01&dateTo=2019-04-05' \ 
-H 'auth: {{YOUR_JWT_ACCESS_TOKEN}}'

Sample Request for POST call

curl -X POST \
  https://bots.kore.ai/api/public/getMessages \
  -H 'auth: {{YOUR_JWT_ACCESS_TOKEN}}' \
  -d '{
        userId           : u-xxxx-xxxxx-xxxx
	skip             : 0,                           
	limit            : 100,                       
	dateFrom         : “2019-04-01”  (or)  “2019-04-01T13:25:58.515Z”,
	dateTo           : “2019-04-01”  (or)  “2019-04-01T13:25:58.515Z”,
	channelType      : “rcs”,
	sessionId        : [“5eadxxxxxxxxxxxxx”,”5ebxxxxxxxxxxxxxxx”],
	tags	         : {
		          and   : [
			            {
			              “name”  : ”tagname”,
			              “values”  : [“tagvalue1”,”tagvalue2”],
                                      “type”    : “tagtype” // user/message/session	
                                     },
                                   {
                                    “name”  : ”tagname”,
    			            “values”  : [“tagvalue1”,”tagvalue2”],
                                    “type”    : “tagtype”  // user/message/session	
                                   }
                                  ]	
                       }
           }

Sample Response

{
    "total": 1,
    "moreAvailable": false,
    "messages": [
        {
            "_id": "ms-e172XXXXXX9a492cd2",
            "type": "outgoing",
            "status": "pending",
            "lmodifiedOn": "2019-04-01T13:25:58.512Z",
            "createdBy": "u-dfb0a15XXXXXXXXX6afa4c74d",
            "channels": [
                {
                    "type": "rcs"
                }
            ],
            "components": [
                {
                    "_id": "cp-4fbXXXXXXXXXX6ebdd586531",
                    "cT": "text",
                    "data": {
                        "text": "Thanks! I now have access to your Kore Assistant account. Don’t worry, I never access your account without you asking me to do something for you."
                    },
                    "thumbnails": []
                }
            ],
            "botId": "st-fe7XXXXXX6e115e94c",
            "orgId": "o-5a64XXXXXXXXXa58cd43460c3",
            "accountId": "5c9c95bXXXXX23c523dbc",
            "isBB": 1,
            "ms": 1,
            "chnl": "rcs",
            "createdOn": "2019-04-01T13:25:58.515Z",
            "timestampValue": 1554125158515,
            "__v": 0,
            "resourceid": "messagestore",
            "tags": {
                "messageTags": [],
                "userTags": [
                    {
                        "value": "+919346804623",
                        "name": "RCSID"
                    }
                ],
                "sessionTags": []
            }        }
    ]
}

Sample Response from POST call:

{
  "total": 1,
  "moreAvailable": false,
  "messages"  : [
                {
                  "_id": "ms-xxxxxxxxxxxxxxxxxxxx",
                  "type": "incoming",
                  "status": "sent to cs",
                  "createdBy":"u-xxxxxxxxxxxxxxxxxxx",
                  "lmodifiedBy": u-xxxxxxxxxxxxxxxxxxx",
                  "lmodifiedOn": "2019-04-10T10:21:45.103Z",
                  "channels": [
                     {
                      "type": "rtm"
                        }
                     ],
                  "botId":"st-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                  "orgId": “o-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                  "accountId": "5xxxxxxxxxxxxxxxxxxxxxxxx",
                  "isBB": 0,
                  "ms": 1,
                  "channel": "rtm",
                  "components": [
                    {
                      "_id":"cp-xxxxxxxxxxx",
                      "cT": "text",
                      "data": {
                          "text": "23"
                           },
                      "thumbnails": []
                      }
                    ],
                    "createdOn": "2019-04-10T10:21:45.106Z",
                    "timestampValue": 1554891705106,
                    "__v": 0,
                    "sessionId": "5cadbefc6a81a71559f6bece"
               }
             ]
 }
Menu