{"id":837,"date":"2023-03-09T16:58:20","date_gmt":"2023-03-09T13:58:20","guid":{"rendered":"https:\/\/docs.unibell.ru\/?page_id=837"},"modified":"2026-06-16T11:10:10","modified_gmt":"2026-06-16T08:10:10","slug":"%d0%bf%d0%b5%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d0%bd%d0%b0%d1%8f","status":"publish","type":"page","link":"https:\/\/docs.cpaas.mittoapi.net\/?page_id=837","title":{"rendered":"Variable"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/08\/variable.png\"><img decoding=\"async\" width=\"110\" height=\"78\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/08\/variable.png\" alt=\"\" class=\"wp-image-3817\"\/><\/a><\/figure>\n\n\n\n<p>The &#171;Variable\u201d block is used for operations with variables.<\/p>\n\n\n\n<p>The block properties contain fields for selecting a variable and a setting block for the &#171;Assign&#187; operation. In the first field, a variable is selected through the drop-down list. If the drop-down list is empty when you click, it means that there are no variables in your script. Create it in the \u201cVariables\u201d area and then return to the settings of this block.<\/p>\n\n\n\n<p>After specifying the variable to which the data in this block will be written, assign the required value to it by entering it in the &#171;Assigned value&#187; 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\" width=\"278\" height=\"296\" 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>Either switch to the &#171;Variable&#187; tab and select another variable whose value will be assigned to the first Variable.<\/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\" width=\"278\" height=\"362\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable1.png\" alt=\"\" class=\"wp-image-2836\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable1.png 278w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable1-230x300.png 230w\" sizes=\"(max-width: 278px) 100vw, 278px\" \/><\/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\" width=\"289\" height=\"367\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable2.png\" alt=\"\" class=\"wp-image-2838\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable2.png 289w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable2-236x300.png 236w\" sizes=\"(max-width: 289px) 100vw, 289px\" \/><\/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.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable5.png\"><img decoding=\"async\" width=\"376\" height=\"337\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable5.png\" alt=\"\" class=\"wp-image-4015\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable5.png 376w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable5-300x269.png 300w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/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>Example. For instance, there is a variable that has been assigned a value, and we need to extract information from it:<\/p>\n\n\n\n<p>Value in the variable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var1 =\n{\n    \"dateTimeFrom\":\"26.06.2024\",\n    \"dateTimeTo\":\"26.06.2024\",\n    \"type\":\"PERIOD\"\n}<\/code><\/pre>\n\n\n\n<p>Extraction of the nested object dateTimeFrom from var1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var = var1.dateTimeFrom<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var = 26.06.2024<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example1.png\"><img decoding=\"async\" width=\"203\" height=\"390\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example1.png\" alt=\"\" class=\"wp-image-4158\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example1.png 203w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example1-156x300.png 156w\" sizes=\"(max-width: 203px) 100vw, 203px\" \/><\/a><\/figure>\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.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example2.png\"><img decoding=\"async\" width=\"344\" height=\"441\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example2.png\" alt=\"\" class=\"wp-image-4159\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example2.png 344w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2025\/02\/example2-234x300.png 234w\" sizes=\"(max-width: 344px) 100vw, 344px\" \/><\/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 =\n{ \n  \"name\":\"John\",\n  \"age\":30,\n  \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]\n}<\/code><\/pre>\n\n\n\n<p>Specify in the fields:<\/p>\n\n\n\n<ul>\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: &#171;BMW&#187;.<\/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\" width=\"746\" height=\"381\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable.png\" alt=\"\" class=\"wp-image-3536\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable.png 746w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable-300x153.png 300w\" sizes=\"(max-width: 746px) 100vw, 746px\" \/><\/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 &#171;Ford&#187;, 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>\n<li>In the &#171;Variable&#187; 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\" width=\"752\" height=\"428\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable1.png\" alt=\"\" class=\"wp-image-3537\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable1.png 752w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable1-300x171.png 300w\" sizes=\"(max-width: 752px) 100vw, 752px\" \/><\/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 &#171;Random value&#187; to be passed to your variable, then you need to select the tab of the same name in the settings block for the &#171;Assign&#187; 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\" width=\"283\" height=\"369\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable3-1.png\" alt=\"\" class=\"wp-image-2842\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable3-1.png 283w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable3-1-230x300.png 230w\" sizes=\"(max-width: 283px) 100vw, 283px\" \/><\/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 &#171;Minimum value&#187; to &#171;Maximum value&#187;.<\/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\" width=\"279\" height=\"371\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable4-1.png\" alt=\"\" class=\"wp-image-2843\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable4-1.png 279w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable4-1-226x300.png 226w\" sizes=\"(max-width: 279px) 100vw, 279px\" \/><\/a><\/figure>\n\n\n\n<p> Example of a scenario when selecting a &#171;Random value&#187;:<\/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\" width=\"883\" height=\"680\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable5.png\" alt=\"\" class=\"wp-image-2841\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable5.png 883w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/04\/variable5-300x231.png 300w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The &#171;Variable\u201d block is used for operations with variables. The block properties contain fields for selecting a variable and a setting block for the &#171;Assign&#187; operation. In the first field, a variable is selected through the drop-down list. If the drop-down list is empty when you click, it means that there are no variables in <a href=\"https:\/\/docs.cpaas.mittoapi.net\/?page_id=837\" class=\"more-link\">&#8230;<span class=\"screen-reader-text\">  Variable<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":862,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"tpl\/scenario-personal.php","meta":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/837"}],"collection":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=837"}],"version-history":[{"count":18,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/837\/revisions"}],"predecessor-version":[{"id":4319,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/837\/revisions\/4319"}],"up":[{"embeddable":true,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/862"}],"wp:attachment":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}