{"id":21343,"date":"2019-06-04T07:34:33","date_gmt":"2019-06-04T06:34:33","guid":{"rendered":"https:\/\/developer.kore.ai\/v9-3\/?p=21343"},"modified":"2022-12-29T13:32:53","modified_gmt":"2022-12-29T13:32:53","slug":"sessions-api","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v9-3\/docs\/bots\/api-guide\/sessions-api\/","title":{"rendered":"Sessions History API"},"content":{"rendered":"<section class=\"l-section wpb_row height_auto\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row type_default valign_top\"><div class=\"vc_col-sm-12 wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>This API retrieves the conversation sessions created. The API details are available in the Bot Builder and Bot Admin Console (BAC) app scopes.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Method<\/strong><\/td>\n<td>POST<\/td>\n<\/tr>\n<tr>\n<td><strong>Endpoint<\/strong><\/td>\n<td><code>https:\/\/{{host}}\/api\/public\/bot\/{{BotID}}\/getSessions?containmentType={{containmentType}}<\/code><br \/>\nand <code>https:\/\/{{host}}\/api\/public\/getSessions?containmentType={{containmentType}}<\/code>for BAC<\/td>\n<\/tr>\n<tr>\n<td><strong>Content Type<\/strong><\/td>\n<td><code>application\/json<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>Authorization<\/strong><\/td>\n<td>\n<p><code>auth: {{JWT}}<\/code><\/p>\n<p>See <a href=\"https:\/\/developer.kore.ai\/v9-3\/docs\/bots\/api-guide\/apis\/#Generating_the_JWT_Token\" rel=\"noopener noreferrer\" target=\"_blank\">How to generate the JWT Token.<\/a><\/td>\n<\/tr>\n<tr>\n<td><strong>API Scope<\/strong><\/td>\n<td>\n<ul>\n<li>Bot Builder: Bot Sessions<\/li>\n<p>OR<\/p>\n<li>Admin Console: Bot Analytics > Bot Sessions<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Path_Parameters\">Path Parameters<\/span><\/h2>\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>host<\/td>\n<td>Environment URL, for example, https:\/\/bots.kore.ai<\/td>\n<\/tr>\n<tr>\n<td>BotID<\/td>\n<td>Bot ID or Stream ID. You can access it from the General Settings page of the bot.<\/td>\n<\/tr>\n<tr>\n<td>containmentType<br \/>\n<strong>(introduced in ver9.0)<\/strong><\/td>\n<td>Use to filter the results based on the type of the session i.e Self-service vs. Drop-off vs. Agent Transfer<br \/>\nValid values:<\/p>\n<ul>\n<li>dropOff,<\/li>\n<li>selfService,<\/li>\n<li>agent.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/thead>\n<\/table>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Request\">Sample Request<\/span><\/h2>\n<ul>\n<li>Without a body\n<pre class=\"\">curl --location --request POST '{{host}}\/api\/public\/getSessions?containmentType={{containmentType}}' \\\r\n     --header 'auth: {{YOUR_JWT_ACCESS_TOKEN}}' \\\r\n     --header 'Content-Type: application\/json' \\\r\n     --data-raw ''<\/pre>\n<\/li>\n<li>With a body\n<pre class=\"\">curl --location --request POST '{{host}}\/api\/public\/getSessions?containmentType={{containmentType}}' \\\r\n     --header 'auth: {{YOUR_JWT_ACCESS_TOKEN}}' \\\r\n     --header 'Content-Type: application\/json' \\\r\n     --data-raw '{\r\n        \"skip\" : 0,                          \r\n        \"limit\" : 100,                      \r\n        \"dateFrom\" : \"2020-02-11\",\r\n        \"dateTo\" : \"2020-02-12\"\r\n }'<\/pre>\n<\/li>\n<li>For Specific Bot\n<pre class=\"\">curl --location --request POST '{{host}}\/api\/public\/bot\/{{BotId}}\/getSessions?containmentType={{containmentType}}' \\\r\n     --header 'auth: {{YOUR_JWT_ACCESS_TOKEN}}' \\\r\n     --header 'Content-Type: application\/json' \\\r\n     --data-raw '{\r\n        \"skip\" : 0,                          \r\n        \"limit\" : 100,                      \r\n        \"dateFrom\" : \"2020-02-11\",\r\n        \"dateTo\" : \"2020-02-12\"\r\n }'<\/pre>\n<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Request_Body_Parameters\">Request Body Parameters<\/span><\/h2>\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Description<\/th>\n<th>Required\/Optional<\/th>\n<\/tr>\n<tr>\n<td>userId<\/td>\n<td>The ID of the user whose conversation history to access. Can be a user email id or enterprise assigned unique id.<\/td>\n<td>Optional<\/td>\n<\/tr>\n<tr>\n<td>skip\/offset<\/td>\n<td>The number of messages to be skipped.<\/td>\n<td>Optional<\/td>\n<\/tr>\n<tr>\n<td>limit<\/td>\n<td>The number of messages to be shown on each page.<\/td>\n<td>Optional<\/td>\n<\/tr>\n<tr>\n<td>dateFrom<\/td>\n<td>Takes the date format yyyy-mm-dd<br \/>\n(or) yyyy-mm-ddThh:mm:ss.msZ<br \/>\neg:2019-04-01 (or) 2019-04-01T13:25:58.515Z. If not provided, calculated as 7 days behind <em>dataTo<\/em>.<\/td>\n<td>Optional<\/td>\n<\/tr>\n<tr>\n<td>dateTo<\/td>\n<td>Takes the date format yyyy-mm-dd<br \/>\n(or) yyyy-mm-ddThh:mm:ss.msZ<br \/>\neg:2019-04-01 (or) 2019-04-01 T13:26:05.598Z. If not provided, calculated as 7 days from <em>dateFrom<\/em>. If <em>dateFrom<\/em> is also not provided then set to <strong>Today<\/strong>.<\/td>\n<td>Optional<\/td>\n<\/tr>\n<tr>\n<td>tags<\/td>\n<td>Meta tags to filter the conversations.<\/td>\n<td>Optional<\/td>\n<\/tr>\n<tr>\n<td>sessionType<br \/>\n(introduced in ver8.0)<\/td>\n<td>\n<p>Type to filter the conversations &#8211; can be:<\/p>\n<ul>\n<li>non-interactive &#8211; sessions that have bot messages presented without any message from the user<\/li>\n<li>interactive &#8211; sessions that include one or more messages from the user<\/li>\n<\/ul>\n<\/td>\n<td>Optional<\/td>\n<\/tr>\n<\/thead>\n<\/table>\n<p><strong>Note<\/strong>: The duration between <em>dateTo<\/em> and <em>dateFrom<\/em> should be less than 7 days, else an error will be thrown.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Response\">Sample Response<\/span><\/h2>\n<ul>\n<li><strong>for <em>dropOff<\/em> sessions<\/strong>\n<pre>{\r\n  \"total\": 1,\r\n  \"moreAvailable\": false,\r\n  \"sessions\": [\r\n   {\r\n     \"sessionId\": \"xxxxaxxexxxaxexdxxxdxxxe\",\r\n     \"botId\": \"st-ffeffxxx-xxxc-xexa-axxx-cxxabxxxxcxx\",\r\n     \"channel\": \"rtm\",\r\n     \"userId\": \"u-xxfexxxd-xxex-xdxe-xaec-xeaxbxxxxfxx\",\r\n     \"start_time\": \"2021-04-26T11:27:25.977Z\",\r\n     \"end_time\": \"2021-04-26T11:27:26.145Z\",\r\n     \"session_lang\": [\r\n       \"en\"\r\n      ],\r\n     \"sessionType\": \"interactive\",\r\n     \"containmentType\": \"dropOff\",\r\n     \"isDeveloper\": false,\r\n     \"tags\": {\r\n       \"userTags\": [\r\n        {\r\n         \"value\": \"newuser\",\r\n         \"name\": \"regular\"\r\n        }\r\n      ],\r\n      \"sessionTags\": []\r\n     },\r\n     \"noOfMessagesExchanged\": 1,\r\n     \"noOfTasksExecuted\": 0\r\n   }\r\n  ]\r\n}<\/pre>\n<\/li>\n<li><strong>for <em>selfService<\/em> sessions<\/strong>\n<pre class=\"code-limit-400px\">{\r\n  \"total\": 2,\r\n  \"moreAvailable\": false,\r\n  \"sessions\": [\r\n   {\r\n     \"sessionId\": \"xxxxaxxexxxaxexdxxxdxxxe\",\r\n     \"botId\": \"st-ffeffxxx-xxxc-xexa-axxx-cxxabxxxxcxx\",\r\n     \"channel\": \"rtm\",\r\n     \"userId\": \"u-xxfexxxd-xxex-xdxe-xaec-xeaxbxxxxfxx\",\r\n     \"start_time\": \"2021-04-26T11:27:25.977Z\",\r\n     \"end_time\": \"2021-04-26T11:27:26.145Z\",\r\n     \"session_lang\": [\r\n       \"en\"\r\n      ],\r\n     \"sessionType\": \"non-interactive\",\r\n     \"containmentType\": \"selfService\",\r\n     \"isDeveloper\": false,\r\n     \"tags\": {\r\n       \"userTags\": [\r\n        {\r\n         \"value\": \"newuser\",\r\n         \"name\": \"regular\"\r\n        }\r\n       ],\r\n       \"sessionTags\": []\r\n     },\r\n     \"noOfMessagesExchanged\": 6,\r\n     \"noOfTasksExecuted\": 0\r\n    },\r\n   {\r\n     \"sessionId\": \"xxxxaxxexxxaxexdxxxdxxxe\",\r\n     \"botId\": \"st-ffeffxxx-xxxc-xexa-axxx-cxxabxxxxcxx\",\r\n     \"channel\": \"rtm\",\r\n     \"userId\": \"u-xxfexxxd-xxex-xdxe-xaec-xeaxbxxxxfxx\",\r\n     \"start_time\": \"2021-04-26T11:27:25.977Z\",\r\n     \"end_time\": \"2021-04-26T11:27:26.145Z\",\r\n     \"session_lang\": [\r\n       \"en\"\r\n      ],\r\n      \"sessionType\": \"non-interactive\",\r\n      \"containmentType\": \"selfService\",\r\n      \"isDeveloper\": false,\r\n     \"tags\": {\r\n       \"userTags\": [\r\n         {\r\n          \"value\": \"newuser\",\r\n          \"name\": \"regular\"\r\n        }\r\n      ],\r\n     \"sessionTags\": []\r\n     },\r\n     \"noOfMessagesExchanged\": 8,\r\n     \"noOfTasksExecuted\": 0\r\n    }\r\n  ]\r\n}<\/pre>\n<\/li>\n<li><strong>for <em>agent<\/em> sessions<\/strong>\n<pre>{\r\n  \"total\": 1,\r\n  \"moreAvailable\": false,\r\n  \"sessions\": [\r\n   {\r\n     \"sessionId\": \"xxxxaxxexxxaxexdxxxdxxxe\",\r\n     \"botId\": \"st-ffeffxxx-xxxc-xexa-axxx-cxxabxxxxcxx\",\r\n     \"channel\": \"rtm\",\r\n     \"userId\": \"u-xxfexxxd-xxex-xdxe-xaec-xeaxbxxxxfxx\",\r\n     \"start_time\": \"2021-04-26T11:27:25.977Z\",\r\n     \"end_time\": \"2021-04-26T11:27:26.145Z\",\r\n     \"session_lang\": [\r\n       \"en\"\r\n      ],\r\n\t \"sessionType\": \"interactive\",\r\n         \"containmentType\": \"agent\", \r\n\t \"isDeveloper\": false,\r\n\t \"tags\": {\r\n\t\t\"userTags\": [],\r\n\t\t\"sessionTags\": []\r\n\t },\r\n\t \"noOfMessagesExchanged\": 7,\r\n\t \"noOfTasksExecuted\": 2\r\n\t}\r\n  ]\r\n}<\/pre>\n<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Response_Body_Parameters\">Response Body Parameters<\/span><\/h2>\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>total<\/td>\n<td>\n<p>The total number of records identified as per the API request parameters. The response will include a maximum of X records. If more than X records are identified, then the \u2018moreAvailable\u2019 field in the response will have the value as \u2018True\u2019.<\/p>\n<p>It is recommended to programmatically iterate the request by dynamically updating the values of the \u2018skip\u2019 and \u2018limit\u2019 parameters in the request.<\/td>\n<\/tr>\n<tr>\n<td>moreAvailable<\/td>\n<td>Indicates if the API has returned all the records or if more are available, based on the pagination criteria.<br \/><strong>True<\/strong> if more records are available. <strong>False<\/strong> if there are no more records to be retrieved.<\/td>\n<\/tr>\n<tr>\n<td>sessions<\/td>\n<td>Contains complete information about the session.<\/td>\n<\/tr>\n<tr>\n<td>sessions.sessionId<\/td>\n<td>The unique identifier for the session record.<\/td>\n<\/tr>\n<tr>\n<td>sessions.botId<\/td>\n<td>Bot ID or Stream ID.<\/td>\n<\/tr>\n<tr>\n<td>sessions.channel<\/td>\n<td>The channel in which the end user is having the conversation: sms, email, rtm, slack, skype, twitter, msteams, api, kore, facebook, or skypeforbusiness.<\/td>\n<\/tr>\n<tr>\n<td>sessions.userId<\/td>\n<td>The user Id of the end user who is having a conversation with the bot.<\/td>\n<\/tr>\n<tr>\n<td>sessions.start_time<\/td>\n<td>The start time of the session. (ISO Date format YYYY-MM-DDThh:mm:ss.mmmZ)<\/td>\n<\/tr>\n<tr>\n<td>sessions.end_time<\/td>\n<td>The end time of the session. (ISO Date format YYYY-MM-DDThh:mm:ss.mmmZ)<\/td>\n<\/tr>\n<tr>\n<td>sessions.session_lang<\/td>\n<td>All the languages in which the conversation happened during the session.<\/td>\n<\/tr>\n<td>sessions.sessionType<\/td>\n<td>\n<p>The type to filter the conversations:<\/p>\n<ul>\n<li>non-interactive \u2013 sessions having only bot messages, no message from the user.<\/li>\n<li>interactive \u2013 sessions having one or more messages from the user.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td>sessions.containmentType<\/td>\n<td>Used to filter the results based on the type of the session: selfservice, dropOff, or agent.<\/td>\n<\/tr>\n<tr>\n<td>sessions.isDeveloper<\/td>\n<td>Informs whether the session was initiated by a developer; 1 for Yes, 0 for No.<\/td>\n<\/tr>\n<tr>\n<td>sessions.tags<\/td>\n<td>Meta tags to filter the sessions.<\/td>\n<\/tr>\n<tr>\n<td>sessions.tags.userTags<\/td>\n<td>User tags object; custom tags added to the user&#8217;s profile information.<\/td>\n<\/tr>\n<tr>\n<td>sessions.tags.userTags.value<\/td>\n<td>Tag&#8217;s value.<\/td>\n<\/tr>\n<tr>\n<td>sessions.tags.userTags.name<\/td>\n<td>Tag&#8217;s name.<\/td>\n<\/tr>\n<tr>\n<td>sessions.tags.sessionTags<\/td>\n<td>Session tags object; custom tags added to the conversation session.<\/td>\n<\/tr>\n<tr>\n<td>sessions.tags.sessionTags.value<\/td>\n<td>Tag&#8217;s value.<\/td>\n<\/tr>\n<tr>\n<td>sessions.tags.sessionTags.name<\/td>\n<td>Tag&#8217;s name.<\/td>\n<\/tr>\n<tr>\n<td>sessions.noOfMessagesExchanged<\/td>\n<td>The number of messages exchanged in the session.<\/td>\n<\/tr>\n<tr>\n<td>sessions.noOfTasksExecuted<\/td>\n<td>The number of tasks executed in the session.<\/td>\n<\/tr>\n<\/thead>\n<\/table>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<\/div><\/div><\/div><\/div><\/div><\/section><section class=\"l-section wpb_row height_auto\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row type_default valign_top\"><div class=\"vc_col-sm-12 wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\"><div class=\"ult-spacer spacer-6aef4f1887c73\" data-id=\"6aef4f1887c73\" data-height=\"40\" data-height-mobile=\"40\" data-height-tab=\"40\" data-height-tab-portrait=\"\" data-height-mobile-landscape=\"\" style=\"clear:both;display:block;\"><\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"This API retrieves the conversation sessions created. The API details are available in the Bot Builder and Bot Admin Console (BAC) app scopes. Method POST Endpoint https:\/\/{{host}}\/api\/public\/bot\/{{BotID}}\/getSessions?containmentType={{containmentType}} and https:\/\/{{host}}\/api\/public\/getSessions?containmentType={{containmentType}}for BAC Content Type application\/json Authorization auth: {{JWT}} See How to generate the JWT Token. API Scope Bot Builder: Bot Sessions OR Admin Console: Bot Analytics >...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-21343","post","type-post","status-publish","format-standard","hentry","category-api-guide"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/posts\/21343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/comments?post=21343"}],"version-history":[{"count":47,"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/posts\/21343\/revisions"}],"predecessor-version":[{"id":50209,"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/posts\/21343\/revisions\/50209"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/media?parent=21343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/categories?post=21343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-3\/wp-json\/wp\/v2\/tags?post=21343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}