{"id":3256,"date":"2024-08-15T14:50:16","date_gmt":"2024-08-15T11:50:16","guid":{"rendered":"https:\/\/docs.unibell.tech\/?page_id=3256"},"modified":"2024-08-16T08:23:44","modified_gmt":"2024-08-16T05:23:44","slug":"variable","status":"publish","type":"page","link":"https:\/\/docs.unibell.tech\/?page_id=3256","title":{"rendered":"Variable"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable.png\"><img decoding=\"async\" width=\"110\" height=\"78\" src=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable.png\" alt=\"\" class=\"wp-image-3413\"\/><\/a><\/figure>\n\n\n\n<p>The \u2018Variable\u2019 block is used to work with variables.<\/p>\n\n\n\n<p>In the block settings you can find a field where you can choose a variable and also settings for the field \u2018Assign\u2019.<\/p>\n\n\n\n<p>In the first field you will see a drop-down list to choose a variable. If the drop-down list is empty it means that you don\u2019t have any variables created in your scenario. You can create it in the section \u2018Variables\u2019 and after it get back to this section.<\/p>\n\n\n\n<p>After you choose a variable that will have recorded data for this block you can assign a needed value to it by entering it in the \u2018Assigned value\u2019 field.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable.png\" alt=\"\" class=\"wp-image-2835\"\/><\/a><\/figure>\n\n\n\n<p>The \u2018Variable\u2019 block is used to work with variables.<\/p>\n\n\n\n<p>In the block settings you can find a field where you can choose a variable and also settings for the field \u2018Assign\u2019.<\/p>\n\n\n\n<p>In the first field you will see a drop-down list to choose a variable. If the drop-down list is empty it means that you don\u2019t have any variables created in your scenario. You can create it in the section \u2018Variables\u2019 and after it get back to this section.<\/p>\n\n\n\n<p>After you choose a variable that will have recorded data for this block you can assign a needed value to it by entering it in the \u2018Assigned value\u2019 field.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable1.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable1.png\" alt=\"\" class=\"wp-image-2836\"\/><\/a><\/figure>\n\n\n\n<h2 id=\"Nested_object\" class=\"anchor\">Nested object<\/h2>\n\n\n\n<p>The \u2018Nested object\u2019 setting is used to extract a certain object if some data structure is supposed to be transferred to a variable. Syntax of Java Script is used to extract this object.<\/p>\n\n\n\n<p>For example, in HTTP request server sends to the variable \u2018answer\u2019 the following data structure:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\t\"name\": \"John\",\n\t\"surname\": \"Doe\"\n}<\/code><\/pre>\n\n\n\n<p>To extract from this structure \u00abJohn\u00bb you can create a variable \u2018name\u2019, choose it in the settings of the \u2018Variable\u2019 block and assign \u2018answer\u2019 variable to it. In the field \u2018Embedded object\u2019 you can type \u2018name\u2019.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable2.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable2.png\" alt=\"\" class=\"wp-image-2838\"\/><\/a><\/figure>\n\n\n\n<p>his way you will have value \u00abJohn\u00bb saved to the variable \u2018name\u2019.<\/p>\n\n\n\n<p>Below you can find more examples of how you can use the \u2018Variable\u2019 block.<\/p>\n\n\n\n<p>For instance, if you want the robot to say \u2018Hello\u2019 after a subscriber answers the call, you can do the following steps. You can create a variable and name it \u2018Hello\u2019, then under the \u2018Outgoing call\u2019 block you can add the \u2018Variable\u2019 block that has a \u2018Hello\u2019 value assigned and then you can put the \u2018Player\u2019 block below it, where in the settings you can enter the variable \u2018Hello\u2019 into the text field.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_5.png\"><img decoding=\"async\" width=\"491\" height=\"372\" src=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_5.png\" alt=\"\" class=\"wp-image-3415\" srcset=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_5.png 491w, https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_5-300x227.png 300w\" sizes=\"(max-width: 491px) 100vw, 491px\" \/><\/a><\/figure>\n\n\n\n<p>As a result you will have a scenario that will meet the following requirements: a subscriber answers the call and the robot says \u2018Hello\u2019.<\/p>\n\n\n\n<p>Another example of how you can use this block is when an action that a subscriber has chosen needs to be transferred to your server. To do this you can place the \u2018IVR\u2019 block under the \u2018Outgoing call\u2019 block and set a range of action options for a subscriber. For instance, the robot pronounces \u2018Press 1 if\u2026, press 2 if\u2026\u2019 and assign as the response options for a subscriber Key 1 and Key 2. Then you can create a variable \u2018Select\u2019 and put into the scenario two \u2018Variable\u2019 blocks for each key. In each block setting you can choose the variable \u2018Select\u2019 and for one block assign the value Key 1 and for another block the value Key 2. After that connect each block with the corresponding option of the \u2018IVR\u2019 block. Below it you should place and setup the \u2018HTTP-request\u2019 block to transfer a response that the subscriber has chosen to the server.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_6.png\"><img decoding=\"async\" width=\"519\" height=\"462\" src=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_6.png\" alt=\"\" class=\"wp-image-3417\" srcset=\"https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_6.png 519w, https:\/\/docs.unibell.tech\/wp-content\/uploads\/2024\/08\/variable_6-300x267.png 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/a><\/figure>\n\n\n\n<p>The use case in the array. Processing an array that comes, for example, from an HTTP request:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var1 = { \"name\":\"John\",\n \"age\":30,\n \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]}<\/code><\/pre>\n\n\n\n<p>Specify in the fields:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An assignable variable, for example: var1;<\/li>\n\n\n\n<li>Nested object: cars[1].<\/li>\n<\/ul>\n\n\n\n<p>Result: &#8220;BMW&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable.png\" alt=\"\" class=\"wp-image-3536\"\/><\/a><\/figure>\n\n\n\n<p>The second option. It is recorded and saved in var1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;\n{\n   \"name\":\"Ford\",\n   \"val\":\"John\",\n   \"price\":\"1000\",\n   \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]\n},\n{\n   \"name\": \"BMW\",\n   \"val\":\"Jack\",\n   \"price\":\"2000\",\n   \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]\n},\n{\n   \"name\": \"Fiat\",\n   \"val\":\"Nik\",\n   \"price\":\"3000\",\n   \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]\n}\n]<\/code><\/pre>\n\n\n\n<p>To find cars &#8220;Ford&#8221;, you need to specify the following in the script fields:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var1&#91;0].cars&#91;]<\/code><\/pre>\n\n\n\n<p>To do this, specify in the fields:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In the &#8220;Variable&#8221; set: var1;<\/li>\n\n\n\n<li>Nested object: [0].cars[0].<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable1.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable1.png\" alt=\"\" class=\"wp-image-3537\"\/><\/a><\/figure>\n\n\n\n<p>This will form the element of the array var1[0].cars[0].<\/p>\n\n\n\n<h2 id=\"random value\" class=\"anchor\">Random value<\/h2>\n\n\n\n<p>If you want some kind of &#8220;Random value&#8221; to be passed to your variable, then you need to select the tab of the same name in the settings block for the &#8220;Assign&#8221; operation.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable3-1.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable3-1.png\" alt=\"\" class=\"wp-image-2842\"\/><\/a><\/figure>\n\n\n\n<p>A random value is a value that is selected from a certain set according to a certain probability distribution.<\/p>\n\n\n\n<p>For example, if the interval is set from 10 to 50, then a random number will be selected from this interval so that it lies between these two values, including them.<\/p>\n\n\n\n<p>When generating a random number in a certain range, a variable will be assigned a random value in the range from &#8220;Minimum value&#8221; to &#8220;Maximum Value&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable4-1.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable4-1.png\" alt=\"\" class=\"wp-image-2843\"\/><\/a><\/figure>\n\n\n\n<p> Example of a scenario when selecting a &#8220;Random value&#8221;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable5.png\"><img decoding=\"async\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable5.png\" alt=\"\" class=\"wp-image-2841\"\/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The \u2018Variable\u2019 block is used to work with variables. In the block settings you can find a field where you can choose a variable and also settings for the field \u2018Assign\u2019. In the first field you will see a drop-down list to choose a variable. If the drop-down list is empty it means that you <a href=\"https:\/\/docs.unibell.tech\/?page_id=3256\" class=\"more-link\">&#8230;<span class=\"screen-reader-text\">  Variable<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"tpl\/scenario-personal.php","meta":{"footnotes":""},"class_list":["post-3256","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=\/wp\/v2\/pages\/3256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3256"}],"version-history":[{"count":3,"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=\/wp\/v2\/pages\/3256\/revisions"}],"predecessor-version":[{"id":3418,"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=\/wp\/v2\/pages\/3256\/revisions\/3418"}],"wp:attachment":[{"href":"https:\/\/docs.unibell.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}