{"id":22484,"date":"2019-09-11T07:09:35","date_gmt":"2019-09-11T06:09:35","guid":{"rendered":"https:\/\/developer.kore.ai\/v7-2\/?p=22484"},"modified":"2020-04-16T10:07:32","modified_gmt":"2020-04-16T09:07:32","slug":"how-to-schedule-an-alert","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v7-2\/docs\/bots\/how-tos\/how-to-schedule-an-alert\/","title":{"rendered":"How to Schedule a Smart Alert"},"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>In this How-To, we will explore a scenario in a Bot, say traveling Bot, where the user needs to be provided with weather updates daily for a preferred location. We will be using an Alert task to achieve the same. We will also see how auto subscription can be enabled on this Alert task, making it smart.<\/p>\n<p>For details on what Alert task is and how it is implemented in the Kore.ai Bots platform, <a href=\"\/v7-2\/docs\/bots\/bot-builder-tool\/alert\/notification-tasks\/\" target=\"_blank\" rel=\"noopener noreferrer\">refer here<\/a>.<\/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<h2><span class=\"ez-toc-section\" id=\"Problem_Statement\">Problem Statement<\/span><\/h2>\n<p>A registered user of a Bot needs to be sent a weather update in the form of an alert, on a pre-specified time of the day and\/or at a specified interval of time.<\/p>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-chat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22499\" src=\"\/wp-content\/uploads\/sites\/13\/SA-chat.png\" alt=\"\" width=\"496\" height=\"365\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-chat.png 496w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-chat-300x221.png 300w\" sizes=\"auto, (max-width: 496px) 100vw, 496px\" \/><\/a><\/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<p>In this document, we will show how an Alert Task can be used to cater to such situations and take appropriate action.<\/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<h2><span class=\"ez-toc-section\" id=\"Pre-requisites\">Pre-requisites<\/span><\/h2>\n<ul>\n<li>Basic Bot building knowledge.<\/li>\n<li>A working Bot, we are using a <a href=\"\/v7-2\/docs\/bots\/how-tos\/creating-a-banking-bot\/\" target=\"_blank\" rel=\"noopener noreferrer\">Banking Bot<\/a>.<\/li>\n<li>Access to a web service that gives a weather updates. We are using a REST service hosted at: <a href=\"http:\/\/api.openweathermap.org\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/api.openweathermap.org<\/a>. If you want to use this service, you need register to their free alert service as we will be using the API key to access their APIs.<\/li>\n<\/ul>\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<h2><span class=\"ez-toc-section\" id=\"Implementation\">Implementation<\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Setting_Alert_Task\">Setting Alert Task<\/span><\/h3>\n<p>Alert tasks can be used to deliver timely, relevant, and personalized information from enterprise systems to customers and employees by polling the relevant service in real-time or according to a user-defined schedule.<\/p>\n<p><strong>Steps<\/strong>:<\/p>\n<ol>\n<li>From <strong>Bot Tasks <\/strong>add an <strong>Alert Task<\/strong> (click on the <strong>+<\/strong> in the Alert Tasks card). On<br \/>\nthe task details page:<\/p>\n<ol>\n<li>Enter a <strong>Task Name<\/strong>, say <em>Get Daily Weather <\/em><\/li>\n<li>Choose the <strong>Connection Type, <\/strong>we will go with <em>Webservice<\/em><\/li>\n<li>Choose the <strong>Connection Mode<\/strong>, we will be using <em>REST<\/em><\/li>\n<li>Click <strong>Create &amp; Proceed<\/strong><br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-creation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22489\" src=\"\/wp-content\/uploads\/sites\/13\/SA-creation.png\" alt=\"\" width=\"1366\" height=\"768\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095130\/SA-creation.png 1366w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095130\/SA-creation-300x169.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095130\/SA-creation-1024x576.png 1024w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/li>\n<\/ol>\n<\/li>\n<li>You will be directed to the Alert Settings page\n<ol>\n<li>Review and modify the <strong>General Settings<\/strong> if needed. For our use case, we do not need to modify any settings here.<\/li>\n<li>Select the <strong>API Request<\/strong> tab\n<ol>\n<li>Ensure that the <strong>Content Type<\/strong> is set to <em>JSON<\/em><\/li>\n<li>We do not need to set <strong>Authorization Provider<\/strong> for our use case. Configure the same if the API you are using has any authorization requirements.<\/li>\n<li>Set <strong>Parameter<\/strong> to gather the <em>preferred City<\/em> from the User. Ensure that it is set as a <strong>Mandatory<\/strong> field. This is the API requirement.<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-param.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22500\" src=\"\/wp-content\/uploads\/sites\/13\/SA-param.png\" alt=\"\" width=\"694\" height=\"764\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095128\/SA-param.png 694w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095128\/SA-param-273x300.png 273w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/a><\/li>\n<li>We will not need any <strong>Initializer<\/strong> requirements for our use case. Use this in case any JavaScript needs to be executed before the request is sent.<\/li>\n<li>Under <strong>Request<\/strong> click <strong>Add API<\/strong> to add the service API that needs to be invoked. We are using a <em>GET<\/em> method from the following API: <code>http:\/\/api.openweathermap.org\/data\/2.5\/weather?q={cityname}&amp;APPID=&lt;your-app-id&gt;<\/code>\n<ul>\n<li>The <strong>APPID<\/strong> in the above url is assigned to you by OpenWeather when you sign up. You can find it from the <a href=\"https:\/\/home.openweathermap.org\/api_keys\" target=\"_blank\" rel=\"noopener noreferrer\">API keys<\/a> section after you login to your account.<\/li>\n<li>Notice that the <strong>Parameters<\/strong> list is populated automatically with the parameters entered earlier.<\/li>\n<li><strong>Save <\/strong> the API.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-API.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22501\" src=\"\/wp-content\/uploads\/sites\/13\/SA-API.png\" alt=\"\" width=\"696\" height=\"762\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095128\/SA-API.png 696w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095128\/SA-API-274x300.png 274w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/a><\/li>\n<li><strong>Test<\/strong> the API to ensure that the configuration is proper. Enter a sample city name, when prompted and ensure you get a success message and a proper Response.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Save<\/strong> the response.<\/li>\n<\/ol>\n<\/li>\n<li>Next we need to format the <strong>Bot Response.<\/strong> For our use case, we will be parsing the weather description, temperature and humidity details returned by the API call to be presented to the user.<br \/>\nWe are using the following rich text to achieve the same:<\/p>\n<pre class=\"lang:default decode:true\">Todays weather details: &lt;%=weather[0].description%&gt;\r\nTemperature: &lt;%=main.temp%&gt;\r\nHumidity: &lt;%=main.humidity%&gt;<\/pre>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-response.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22491\" src=\"\/wp-content\/uploads\/sites\/13\/SA-response.png\" alt=\"\" width=\"1366\" height=\"768\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-response.png 1366w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-response-300x169.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-response-1024x576.png 1024w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><br \/>\nThe values returned by the API call can be accessed from the <strong>Variable Keys<\/strong> option. Clicking Variable Keys opens the Request\/Response Keys window. The various variables available are categorized. Expand <strong>Response Keys<\/strong> section to access the response from API call and select the key for the value you want to display and click <strong>OK<\/strong>, the key will be inserted in the editor in the appropriate format, for example for the following selection &#8211;<code>&lt;%=weather[0].description%&gt;<\/code><br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-response-keys.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22504\" src=\"\/wp-content\/uploads\/sites\/13\/SA-response-keys.png\" alt=\"\" width=\"895\" height=\"691\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095128\/SA-response-keys.png 895w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095128\/SA-response-keys-300x232.png 300w\" sizes=\"auto, (max-width: 895px) 100vw, 895px\" \/><\/a><\/li>\n<li>Select <strong>Setttings<\/strong> tab and expand the <strong>Schedule<\/strong> section. Use this section to configure an initial schedule, these are the options that are provided to the user to choose from for the initial setup.<br \/>\nFor example, in this example, we have set the schedule to be at 10:30 am daily followed by an update every 4 hrs. The user may choose just once at 10:30 am and not get the further updates.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-schedule.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22490\" src=\"\/wp-content\/uploads\/sites\/13\/SA-schedule.png\" alt=\"\" width=\"1366\" height=\"768\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095130\/SA-schedule.png 1366w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095130\/SA-schedule-300x169.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095130\/SA-schedule-1024x576.png 1024w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/li>\n<li><strong>Finish Setup<\/strong><\/li>\n<\/ol>\n<\/li>\n<\/ol>\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=\"Execution\">Execution<\/span><\/h3>\n<p>Before publishing and sharing the Bot with a user, you can test it from the <strong>Talk to bot<\/strong> feature.<\/p>\n<ol>\n<li>Launch <strong>Talk to bot<\/strong>.<\/li>\n<li>Initiate the schedule task, <strong>Get Daily Weather<\/strong> (name of the Alert Task we configured).<\/li>\n<li>You will be prompted to enter city name.<\/li>\n<li>Next you will be prompted to enter a specific time, you can enter a time or enter &#8220;every x minutes&#8221;.<\/li>\n<li>As you can see if the time you enter does no match the scheduled time configured, the nearest time will be presented. Same is the case with the frequency setting.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-chat1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22497\" src=\"\/wp-content\/uploads\/sites\/13\/SA-chat1.png\" alt=\"\" width=\"683\" height=\"1249\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-chat1.png 683w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-chat1-164x300.png 164w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095129\/SA-chat1-560x1024.png 560w\" sizes=\"auto, (max-width: 683px) 100vw, 683px\" \/><\/a><\/li>\n<li>This is a one-time setup. From this point onwards whenever you launch Talk to Bot for this Bot, you will be given the Weather Alert at the specified time.<\/li>\n<li>The user can trigger the task using the Alert Task name, just like any other Dialog Task and set up the alert manually. The experience User will have when they start using your Bot will be similar to the above-mentioned flow.<\/li>\n<\/ol>\n<h3 id=\"subscription\"><span class=\"ez-toc-section\" id=\"Smart_Alert\">Smart Alert<\/span><\/h3>\n<p>You can set the alert for the user automatically by adding the <strong>Alert Subscription Service<\/strong> type Service node in, say, a welcome dialog task.<\/p>\n<ol>\n<li>Add a <strong>Service Node<\/strong> in the Dialog which will act as the trigger for the Alert Task.<\/li>\n<li>Set the <strong>Service Type<\/strong> to be <em>Alert Subscription Service.<\/em><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-AlertSetup.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22508\" src=\"\/wp-content\/uploads\/sites\/13\/SA-AlertSetup.png\" alt=\"\" width=\"817\" height=\"639\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095127\/SA-AlertSetup.png 817w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095127\/SA-AlertSetup-300x235.png 300w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/a><\/li>\n<li>Click <strong>Edit Request<\/strong> and select the already configured Alert Task, in this case <em>Get Daily Weather<\/em>.<\/li>\n<li>You will be navigated to the <strong>Smart\/Automatic Alerts<\/strong> window<\/li>\n<li>Set up the <strong>Alert Parameters<\/strong> as required.<\/li>\n<li>Set the <strong>Alert Frequency<\/strong><\/li>\n<li>You can set the Alert Expiry values based upon either the duration of the subscription or the number of notifications sent, these will come in handy in case your subscription to the service is limited. Here we have set the <strong>Number of Notification<\/strong> to <em>maximum value<\/em>.<\/li>\n<li>You can also define the <strong>Alert Ugrade <\/strong>behavior in case the Alert task is updated and published.<\/li>\n<li><strong>Save<\/strong><\/li>\n<li>On setup, the first time this service node is hit the subscription will be in effect without user intervention.<\/li>\n<\/ol>\n<p><strong>NOTE<\/strong>: Only published Alert Tasks are available for Alert subscription.<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/SA-AlertSetup1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22509\" src=\"\/wp-content\/uploads\/sites\/13\/SA-AlertSetup1.png\" alt=\"\" width=\"681\" height=\"919\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095127\/SA-AlertSetup1.png 681w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095127\/SA-AlertSetup1-222x300.png 222w\" sizes=\"auto, (max-width: 681px) 100vw, 681px\" \/><\/a><\/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><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"In this How-To, we will explore a scenario in a Bot, say traveling Bot, where the user needs to be provided with weather updates daily for a preferred location. We will be using an Alert task to achieve the same. We will also see how auto subscription can be enabled on this Alert task, making...","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[],"class_list":["post-22484","post","type-post","status-publish","format-standard","hentry","category-how-tos"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/22484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/comments?post=22484"}],"version-history":[{"count":19,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/22484\/revisions"}],"predecessor-version":[{"id":23494,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/22484\/revisions\/23494"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/media?parent=22484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/categories?post=22484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/tags?post=22484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}