This API retrieves the conversation sessions created. This API is available in BT and BAC app scopes.
To use this API, app needs the Bot Builder API scope of Bot sessions.
OR the Admin API Scope of Bot sessions under Bot Analytics.
POST https://{{host}}/api/public/bot/{{BotID}}/getSessions
and https://{{host}}/api/public/getSessions
for Bot Admin Console
Parameters
Parameter | Description |
---|---|
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. |
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 dataTo. |
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. |
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
- Without a body
curl --location --request POST '{{host}}/api/public/getSessions' \ --header 'auth: {{YOUR_JWT_ACCESS_TOKEN}}' \ --header 'Content-Type: application/json' \ --data-raw ''
- With a body
curl --location --request POST '{{host}}/api/public/getSessions' \ --header 'auth: {{YOUR_JWT_ACCESS_TOKEN}}' \ --header 'Content-Type: application/json' \ --data-raw '{ "skip" : 0, "limit" : 100, "dateFrom" : "2020-02-11", "dateTo" : "2020-02-12" }'
- For Specific Bot
curl --location --request POST '{{host}}/api/public/bot/{{BotId}}/getSessions' \ --header 'auth: {{YOUR_JWT_ACCESS_TOKEN}}' \ --header 'Content-Type: application/json' \ --data-raw '{ "skip" : 0, "limit" : 100, "dateFrom" : "2020-02-11", "dateTo" : "2020-02-12" }'
Sample Response
{ "total": 2, "moreAvailable": false, "sessions": [ { "sessionId": "5e43acb58c8ae94f1250e014", "botId": "st-c68c3e8f-c88e-541c-bd3b-a624f3e113f7", "channel": "rtm", "userId": "u-b7a2c3ff-efde-59f0-a95f-ee02d1f4c231", "start_time": "2020-02-12T07:43:49.041Z", "end_time": "2020-02-12T09:10:49.082Z", "session_lang": [ "en" ], "tags": { "userTags": [], "sessionTags": [] } }, { "sessionId": "5e43a73582f2844d4edbacbd", "botId": "st-fb172f53-31db-51b2-a5b2-4ef1919daed9", "channel": "ivrVoice", "userId": "u-c9d0de82-a459-574b-b64c-4ef3b22ec59c", "start_time": "2020-02-12T07:20:21.105Z", "end_time": "2020-02-12T07:20:22.073Z", "session_lang": [ "en" ], "tags": { "userTags": [], "sessionTags": [] } } ] }