{"id":32092,"date":"2022-01-25T14:29:21","date_gmt":"2022-01-25T14:29:21","guid":{"rendered":"https:\/\/developer.kore.ai\/v9-1\/?p=32092"},"modified":"2022-03-01T14:04:18","modified_gmt":"2022-03-01T14:04:18","slug":"proactive-notifications-api","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v9-1\/docs\/bots\/api-guide\/proactive-notifications-api\/","title":{"rendered":"Proactive Notifications 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>To send proactive notifications to the configured channel in bot.<\/p>\n<p class=\"note\">To use this API, the app needs the Bot Builder API scope of Proactive Messages OR the Admin API Scope of Proactive Messages and respective channel should be configured and published with proactive notifications option enabled in the bot.<\/p>\n<p><b>POST<\/b> <code>https:\/\/{{host}}\/api\/public\/bot\/{{BotID}}\/notify<\/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=\"Path_Parameters\">Path Parameters<\/span><\/h3>\n<table>\n<tbody>\n<tr>\n<th><b>Parameter<\/b><\/th>\n<th><b>Required\/Optional<\/b><\/th>\n<th><b>Description<\/b><\/th>\n<\/tr>\n<tr>\n<td>host<\/td>\n<td>Required<\/td>\n<td>Environment URL, for example, https:\/\/bots.kore.ai<\/td>\n<\/tr>\n<tr>\n<td>BotId<\/td>\n<td>Required<\/td>\n<td>\n<p>Bot ID or Stream ID. You can access it from the General Settings page of the bot.<\/p>\n<p><b>Note<\/b>: This is required only for Bot Builder API scope of Proactive Messages.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\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=\"Body_Parameters\">Body Parameters<\/span><\/h3>\n<table>\n<tbody>\n<tr>\n<th><b>Parameter<\/b><\/th>\n<th><b>Required\/Optional<\/b><\/th>\n<th><b>Description<\/b><\/th>\n<\/tr>\n<tr>\n<td>channel<\/td>\n<td>Required<\/td>\n<td>\n<p>Name of the channel for which notifications to be sent<\/p>\n<p>Accepted channel types are:\u201c<strong>msteams<\/strong>\u201d and &#8220;<strong>slack<\/strong>&#8220;.<\/td>\n<\/tr>\n<tr>\n<td>userIdentityType<\/td>\n<td>Required<\/td>\n<td>\n<p>Define whether to resolve the user identities provided in the API call to get the channel identities, or to directly use the user identities for delivering the messages<\/p>\n<p>The values is <em>resolve<\/em>.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>message<\/td>\n<td>Required<\/td>\n<td>\n<p>It is an object and accepts two fields<\/p>\n<ul>\n<li><em>type<\/em> \u2192 Indicates the type of message. \u201ctext\u201d for sending plain text and \u201cscript\u201d for sending JavaScript templates as messages.<\/li>\n<li><em>val<\/em> \u2192 value of the message to be sent to user.<\/li>\n<\/ul>\n<p><strong>Example 1:Text<\/strong>:<br \/><code>{<br \/>\"type\": \"text\",<br \/>\"val\": \"Hi User\"<br \/>}<\/code><\/p>\n<p><strong>Example 2: Script<\/strong>:<\/p>\n<p><code>{<br \/>\"type\": \"script\",<br \/>\"val\": \"var envMsg = 'John'; var channel = context.session.BotUserSession.lastMessage.channel; print(JSON.stringify({text: 'Hi ' + envMsg + ' message is from ' + channel + ' channel'}));\"<br \/>}<\/code><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>identities<\/td>\n<td>Required<\/td>\n<td>\n<p>It accepts the list of user identities for whom notifications need to be sent.<\/p>\n<p>A maximum of 1000 identities are supported.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\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:<\/p>\n<p><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_Request\">Sample Request<\/span><\/h3>\n<pre>curl --location --request \r\nPOST \\' https:\/\/{{host}}\/api\/public\/bot\/{{BotID}}\/notify' \\\r\n--header 'auth: {{JWT}}' \\\r\n--header 'Content-Type: application\/json' \\\r\n--data-raw '{\r\n    \"channel\": \"msteams\",\r\n    \"userIdentityType\": \"resolve\",\r\n    \"message\": {\r\n        \"type\": \"text\",\r\n        \"val\": \"hello\"\r\n    },\r\n    \"identities\": [\r\n        \"john@kore.com\",\r\n        \"jane@outlook.com\",\r\n        \"sam@slack.com\"\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    \"status\": \"IN_PROGRESS\",\r\n    \"percentageComplete\": 0,\r\n    \"streamId\": \"st-xxxxx-xxx-xxx-xxx-xxxxx\",\r\n    \"createdBy\": \"u-xxxxx-xxx-xxx-xxx-xxxxx\",\r\n    \"jobType\": \"PROACTIVE_NOTIFICATIONS_API\",\r\n    \"action\": \"PROACTIVE_NOTIFICATIONS\",\r\n    \"statusLogs\": [],\r\n    \"_id\": \"ds-xxxxx-xxx-xxx-xxx-xxxxx\",\r\n    \"lMod\": \"2022-01-25T06:56:48.000Z\",\r\n    \"createdOn\": \"2022-01-25T06:56:48.891Z\",\r\n    \"requestedTime\": \"2022-01-25T06:56:48.891Z\",\r\n    \"__v\": 0\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><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\r\n\t\t<\/div>\r\n\t<\/div>\r\n<\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"To send proactive notifications to the configured channel in bot. To use this API, the app needs the Bot Builder API scope of Proactive Messages OR the Admin API Scope of Proactive Messages and respective channel should be configured and published with proactive notifications option enabled in the bot. POST https:\/\/{{host}}\/api\/public\/bot\/{{BotID}}\/notify. Path Parameters Parameter Required\/Optional...","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-32092","post","type-post","status-publish","format-standard","hentry","category-api-guide"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/32092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/comments?post=32092"}],"version-history":[{"count":3,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/32092\/revisions"}],"predecessor-version":[{"id":33987,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/32092\/revisions\/33987"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/media?parent=32092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/categories?post=32092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/tags?post=32092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}