{"id":2125,"date":"2022-11-08T11:06:37","date_gmt":"2022-11-08T10:06:37","guid":{"rendered":"https:\/\/botnation.ai\/configure-the-escalation-to-human-based-on-days-and-times\/"},"modified":"2026-01-02T15:27:45","modified_gmt":"2026-01-02T14:27:45","slug":"configure-the-escalation-to-human-based-on-days-and-times","status":"publish","type":"support","link":"https:\/\/botnation.ai\/en\/support\/configure-the-escalation-to-human-based-on-days-and-times\/","title":{"rendered":"Configure the escalation to human based on days and times"},"content":{"rendered":"<p>Case study of the use of conditions on date variables native to Botnation<\/p>\n\n\n\n\n\n<p>We will take the case of a customer service where the advisers are available from Monday to Friday from 9am to 12pm and from 2pm to 6pm.<br><br>The chatbot should therefore only offer the <a href=\"https:\/\/botnation.ai\/en\/configure-the-escalation-to-human-based-on-days-and-times\/\">escalation to the human<\/a> (connecting with a chat advisor in the chatbot) when they are present.<\/p>\n\n\n\n<p>The user must also be given an alternative way to contact customer service. In this example we will choose to send an email.<br><br>We will imagine that the chatbot has a menu with a \u201cContact Us\u201d button.<br><br>When the user clicks on this button, the chatbot must check the availability of the advisors. This is possible with conditions on the Botnation date and time variables.<br><br>We need 4 sequences:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Menu<\/li>\n\n\n\n<li>Checking availability<\/li>\n\n\n\n<li>Climbing towards the human<\/li>\n\n\n\n<li>Send email<\/li>\n<\/ul>\n\n\n\n<p>The \u201cContact us\u201d button in the Menu sequence will redirect to the \u201cCheck availability\u201d sequence.<\/p>\n\n\n\n<p>To achieve this, we will focus on the periods of non-availability of advisors. All the conditions that we are going to set up, will aim to determine when the chatbot must propose the sending of emails. And if the day and time do not meet any of these conditions, then the consultants are available and the escalation to the human should be offered.<br><br>First of all, at the beginning of the sequence, the \u201cAvailability\u201d variable must be reset. Otherwise it will keep its previous value when it is run again on this sequence.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/11\/image-70.png.webp\" alt=\"\" class=\"wp-image-2128\"><\/figure>\n\n\n\n<p>For the verification of the day we will use the variable {{bn_date_Wday}} which assigns a number from 1 to 7 to each day of the week (1 = Sunday, 2 = Monday\u2026 7 = Saturday).<br><br>So the chatbot needs to redirect the user to send email for days 1 and 7.<br><br>This results in the following conditions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>If<\/strong> the variable \u201cbn_date_day\u201d = 1 <strong>OR<\/strong> <strong>If<\/strong> the variable \u201cbn_date_day\u201d = 7 <strong>Then<\/strong> the variable \u201cAvailability\u201d will take the value \u201cNo\u201d.<\/li>\n<\/ul>\n\n\n\n<p><em>When creating these conditions, you will have to create the variable bn_date_day but as it is a Botnation variable, it takes its value automatically.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/11\/image-71.png.webp\" alt=\"\" class=\"wp-image-2130\"><\/figure>\n\n\n\n<p>To check the time we will use another native variable {{bn_date_hour}} which gives the time as a number from 0 to 24.  <\/p>\n\n\n\n<p>The first set of conditions will check if the time is before 9AM or after 6PM. In these time slots, the advisors are not available, so the user will be redirected to the email.<br><br>This results in the following conditions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>If<\/strong> the variable \u201cbn_date_hour\u201d &lt; 9 <strong>OR<\/strong> <strong>If <\/strong>the variable \u201cbn_date_hour\u201d \u2265 18 <strong>Then<\/strong> the variable \u201cDisponibility\u201d will take the value \u201cNo\u201d<\/li>\n<\/ul>\n\n\n\n<p><em>It\u2019s good <strong>\u2265 18<\/strong> because from 18H to 18h59, \u201cbn_date_hour\u201d keeps the value 18<\/em><br><em>When creating these conditions, as with the bn_date_day variable, you will need to create the bn_date_hour variable.<\/em><\/p>\n\n\n\n<p><em>Please note:<\/em><\/p>\n\n\n\n<p>In this example, we have taken the system variable bn_date_local_hour: it takes into account the chatbot\u2019s time zone rather than the user\u2019s. We recommend it when the schedule should not change depending on the user\u2019s location. For example, if your office hours are based on Paris time but you have clients in South America.<\/p>\n\n\n\n<p>To learn more, we invite you to read <a href=\"https:\/\/botnation.ai\/en\/date-variables-and-functions\/\">the dedicated article<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/11\/image-72.png.webp\" alt=\"\" class=\"wp-image-2132\"><\/figure>\n\n\n\n<p>Now you have to check if the time is not between 12 and 2 pm. Note that in this time range from 12 to 13:59, \u201cbn_date_hour\u201d must be greater than or equal to 12 and less than 14.<\/p>\n\n\n\n<p>This translates into the following condition:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>If <\/strong>the variable \u201cbn_date_hour\u201d \u226512 <strong>AND<\/strong> <strong>If <\/strong>the variable \u201cbn_date_hour\u201d &lt;14 <strong>Then<\/strong> the variable \u201cDisponibility\u201d will take the value \u201cNo\u201d<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/11\/image-73.png.webp\" alt=\"\" class=\"wp-image-2134\"><\/figure>\n\n\n\n<p>In the end, if none of the above conditions have been met, then the consultants are available at that time.<\/p>\n\n\n\n<p>Finally, we use a condition on the \u201cAvailability\u201d variable to guide the user according to the availability of a consultant:  <strong>IF<\/strong>  a consultant is not free (CAD when the \u201cAvailability\u201d variable is set to \u201cNo\u201d)  <strong>THEN<\/strong>  we redirect him to a sequence on which he can leave a message  <strong>OR<\/strong>  we redirect it to the climbing sequence.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2022\/11\/image-74.png.webp\" alt=\"\" class=\"wp-image-2136\"><\/figure>\n\n\n\n<p><br>The \u201cContact us\u201d button will send you to the chat with the consultants according to their availability.<\/p>\n\n\n","protected":false},"featured_media":0,"template":"","meta":{"_acf_changed":false},"categorie-support":[198,222,221],"class_list":["post-2125","support","type-support","status-publish","hentry","categorie-support-tutorials","categorie-support-variables-en","categorie-support-web-chatbot-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support\/2125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support"}],"about":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/types\/support"}],"wp:attachment":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/media?parent=2125"}],"wp:term":[{"taxonomy":"categorie-support","embeddable":true,"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/categorie-support?post=2125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}