{"id":21343,"date":"2019-06-04T07:34:33","date_gmt":"2019-06-04T06:34:33","guid":{"rendered":"https:\/\/developer.kore.ai\/v7-1\/?p=21343"},"modified":"2019-11-01T11:34:12","modified_gmt":"2019-11-01T11:34:12","slug":"sessions-api","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v7-1\/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. This API is available in BT and BAC app scopes.<\/p>\n<p class=\"note\">To use this API, app needs the Bot Builder API scope of <em>Bot sessions<\/em>.<br \/>\nOR the Admin API Scope of <em>Bot sessions<\/em> under <em>Bot Analytics<\/em>.<\/p>\n<p><strong>POST<\/strong>\u00a0<code>https:\/\/{{host}}\/api\/public\/stream\/{{BotID}}\/getSessions<\/code><br \/>\nand <code>https:\/\/{{host}}\/api\/public\/getSessions<\/code> for Bot Admin Console<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3><span class=\"ez-toc-section\" id=\"Parameters\">Parameters<\/span><\/h3>\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td>userId (optional)<\/td>\n<td>The ID of the user whose conversation history to access. Can be user email id or enterprise assigned unique id.<\/td>\n<\/tr>\n<tr>\n<td>skip\/offset (optional)<\/td>\n<td>The number of messages to be skipped.<\/td>\n<\/tr>\n<tr>\n<td>limit (optional)<\/td>\n<td>The number of messages to be shown on each page.<\/td>\n<\/tr>\n<tr>\n<td>dateFrom (optional)<\/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.515ZIf not provided, calculated as 7 days behind <em>dataTo<\/em>.<\/td>\n<\/tr>\n<tr>\n<td>dateTo (optional)<\/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.598ZIf 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<\/tr>\n<tr>\n<td>tags (optional)<\/td>\n<td>Meta tags to filter the conversations.<\/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<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3><span class=\"ez-toc-section\" id=\"Authorization\">Authorization<\/span><\/h3>\n<p>Invoke the API with JWT in the header with the following syntax:<br \/>\n<code>auth: {{JWT}}<\/code><\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3><span class=\"ez-toc-section\" id=\"Response_content_type\">Response content type<\/span><\/h3>\n<p><code>application\/JSON<\/code><\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3><span class=\"ez-toc-section\" id=\"Sample_Payload\">Sample Payload<\/span><\/h3>\n<pre class=\"\">{\r\n  userId          : u-xxxx-xxxxx-xxxx, \r\n  skip            : 0,                           \r\n  limit           : 100,                       \r\n  dateFrom        : \"2019-04-01\"  (or)  \"2019-04-01T13:25:58.515Z\",\r\n  dateTo          : \"2019-04-01\"  (or)  \"2019-04-01T13:25:58.515Z\",\r\n  tags\t          : {\r\n     \t\t    and   : [\r\n\t\t\t     {\r\n\t\t\t      \"name\"  : \"tagname\",\r\n\t\t\t      \"values\"  : [\"tagvalue1\",\"tagvalue2\"],\r\n                              \"type\"    : \"tagtype\"  \/\/ user\/session\t\r\n                               },\r\n                     \t     {\r\n                              \"name\"  : \"tagname\",\r\n\t\t\t      \"values\"  : [\"tagvalue1\",\"tagvalue2\"],\r\n                              \"type\"    : \"tagtype\"  \/\/ user\/session\t\r\n                               }\r\n                            ]\t\r\n                       }\r\n  \r\n<\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3><span class=\"ez-toc-section\" id=\"Sample_Response\">Sample Response<\/span><\/h3>\n<pre>{\r\n    \"total\": 2,\r\n    \"moreAvailable\": false,\r\n    \"sessions\": [\r\n        {\r\n            \"sessionId\": \"5cbxxx\",\r\n            \"botId\": \"st-xx-xxx-xxx-xxx-fd3576329741\",\r\n            \"channel\": \"rtm\",\r\n            \"userId\": \"u-xxx-xxx-xxx-xxx-01ae7156fbd8\",\r\n            \"start_time\": \"2019-04-23T10:25:34.075Z\",\r\n            \"end_time\": \"2019-04-23T10:52:10.638Z\",\r\n            \"session_lang\": \"en\"\r\n        },\r\n        {\r\n            \"sessionId\": \"5ccxxxxx\",\r\n            \"botId\": \"st-xxx-xxx-xxx-xxx-fd3576329741\",\r\n            \"channel\": \"rtm\",\r\n            \"userId\": \"u-xxx-xxx-xxx-xxx-01ae7156fbd8\",\r\n            \"start_time\": \"2019-04-24T12:27:59.929Z\",\r\n            \"end_time\": \"2019-04-24T12:28:09.472Z\",\r\n            \"session_lang\": [\"en\"],\r\n            \"tags\": {\r\n                \"userTags\": [\r\n                    {\r\n                        \"value\": \"+919346804623\",\r\n                        \"name\": \"RCSID\"\r\n                    }\r\n                ],\r\n                \"sessionTags\": []\r\n            }\r\n        }\r\n   ]\r\n}\r\n<\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"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\u00a0https:\/\/{{host}}\/api\/public\/stream\/{{BotID}}\/getSessions and https:\/\/{{host}}\/api\/public\/getSessions for Bot Admin Console Parameters Parameter Description userId (optional) The...","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\/v7-1\/wp-json\/wp\/v2\/posts\/21343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/comments?post=21343"}],"version-history":[{"count":13,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/posts\/21343\/revisions"}],"predecessor-version":[{"id":22636,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/posts\/21343\/revisions\/22636"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/media?parent=21343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/categories?post=21343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/tags?post=21343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}