{"id":53015,"date":"2019-11-21T00:00:00","date_gmt":"2019-11-20T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/hranilishhe-key-value-ili-kak-nashi-prilozheniya-stali-udobnee"},"modified":"2020-02-18T14:00:51","modified_gmt":"2020-02-18T11:00:51","slug":"hranilishhe-key-value-ili-kak-nashi-prilozheniya-stali-udobnee","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/hranilishhe-key-value-ili-kak-nashi-prilozheniya-stali-udobnee","title":{"rendered":"Key-Value Storage: How Our Applications Became More User-Friendly","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/Voximplant\/blog\/476452\/\"><img decoding=\"async\" alt=\"Key-Value Storage: How Our Applications Became More User-Friendly\" src=\"\/wp-content\/uploads\/2019\/11\/686d1669d32a1fb5c5a42cf6c068b19b.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/a><\/noindex><\/p>\n<p>Anyone developing on Voximplant is familiar with the concept of \"applications\" that link cloud scripts, phone numbers, users, rules, and call queues. Simply put, applications are the cornerstone of development on our platform, serving as the entry point to any Voximplant-based solution, as everything begins with the creation of an application.<\/p>\n<p>Previously, applications \"did not remember\" either the actions performed by the scripts or the results of calculations, so developers had to store values in third-party services or on their backend. If you've ever worked with local storage in a browser, our new functionality is quite similar, as it allows applications to remember \"key-value\" pairs, unique to each application in your account. The storage functionality was made possible by a new module. <noindex><a rel=\"nofollow\" href=\"https:\/\/voximplant.com\/docs\/references\/voxengine\/applicationstorage\">ApplicationStorage<\/a><\/noindex> \u2013 below you will find a brief guide on how to use it, welcome!<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h2>You will need a<\/h2>\n<p><\/p>\n<ul>\n<li>Voximplant account. If you don't have one, registration is available here. <noindex><a rel=\"nofollow\" href=\"https:\/\/voximplant.com\/sign-up\/\">A Voximplant application, as well as a script, rule, and one user. We will create all of this in this tutorial;<\/a><\/noindex>;<\/li>\n<li>A web client to make a call \u2013 we will use our web phone.<\/li>\n<li>phone.voximplant.com <noindex><a rel=\"nofollow\" href=\"https:\/\/phone.voximplant.com\/\">Voximplant Settings<\/a><\/noindex>.<\/li>\n<\/ul>\n<p><\/p>\n<h2>First, log into your account:<\/h2>\n<p>\nmanage.voximplant.com\/auth <noindex><a rel=\"nofollow\" href=\"https:\/\/manage.voximplant.com\/auth\">. In the left menu, click on \"Applications,\" then \"New Application\" and create an application named storage. Go into the new application, switch to the \"Scripts\" tab to create a script called countingCalls with the following code:<\/a><\/noindex>require(Modules.ApplicationStorage);\n\nVoxEngine.addEventListener(AppEvents.CallAlerting, async (e) =&gt; {\nlet r = {value: -1};\n\n    try {\n        r = await ApplicationStorage.get('totalCalls');\n        if (r === null) {\n            r = await ApplicationStorage.put('totalCalls', 0);\n        }\n    } catch(e) {\n        Logger.write('Failure while getting totalCalls value');\n    }\n\n    try {\n        await ApplicationStorage.put('totalCalls', (r.value | 0) + 1);\n    } catch(e) {\n        Logger.write('Failure while updating totalCalls value');\n    }\n    \n    e.call.answer();\n    e.call.say(`Greetings. Number of past calls: ${r.value}. `, Language.RU_RUSSIAN_MALE);\n\n    e.call.addEventListener(CallEvents.PlaybackFinished, VoxEngine.terminate);\n\n});<\/p>\n<pre><code class=\"javascript\">The first line connects the ApplicationStorage module, while the rest of the logic is placed in the event handler<\/code><\/pre>\n<p>\nCallAlerting <noindex><a rel=\"nofollow\" href=\"https:\/\/voximplant.com\/docs\/references\/voxengine\/appevents#callalerting\">Call Alerting<\/a><\/noindex>.<\/p>\n<p>First, we declare a variable to compare the initial value with the call counter. Then we attempt to retrieve the value of the key totalCalls from storage. If such a key doesn't exist, we create it:<\/p>\n<pre><code class=\"javascript\">try {\n    r = await ApplicationStorage.get('totalCalls');\n    if (r === null) {\n        r = await ApplicationStorage.put('totalCalls', 0);\n    }\n}<\/code><\/pre>\n<p>\nNext, we need to increment the value of the key in storage:<\/p>\n<pre><code class=\"javascript\">try {\n        await ApplicationStorage.put('totalCalls', (r.value | 0) + 1);\n    }<\/code><\/pre>\n<p><\/p>\n<blockquote><p>PLEASE NOTE<\/p>\n<p>For each promise, it's necessary to explicitly handle failures, as shown in the listing above \u2013 otherwise, the script execution will be halted, and you will see an error in the logs. More details <noindex><a rel=\"nofollow\" href=\"https:\/\/voximplant.com\/blog\/cloud-side-javascript-promise-handling-update\">here<\/a><\/noindex>.<\/p><\/blockquote>\n<p> After working with the storage, the script responds to the incoming call with voice synthesis and tells how many times you have called before. After this message, the script ends the session.<\/p>\n<p>After saving the script, go to the 'Routing' tab of your application and click 'New Rule'. Name it startCounting, specify the countingCalls script, and leave the mask as default (.*).<\/p>\n<p><img decoding=\"async\" alt=\"Key-Value Storage: How Our Applications Became More User-Friendly\" src=\"\/wp-content\/uploads\/2019\/11\/5f7452211a61dd98ccbdcbfac3f7ccd9.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nThe last step is to create a user. For this, go to 'Users', click 'Create User', specify a name (for example, user1) and a password, then click 'Create'. This username-password pair will be needed for authentication in the webphone.<\/p>\n<h2>Checking<\/h2>\n<p>\nOpen the webphone via the link <noindex><a rel=\"nofollow\" href=\"https:\/\/phone.voximplant.com\/\">Voximplant Settings<\/a><\/noindex> and log in using the account name, application name, and the username-password pair from the application. After successfully logging in, enter any string of characters in the input field and click Call. If everything was done correctly, you will hear a synthesized greeting!<\/p>\n<p>We wish you great development with Voximplant, and stay tuned for updates \u2013 there will be many more from us \ud83d\ude09<br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/Voximplant\/blog\/476452\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0422\u043e\u0442, \u043a\u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 Voximplant, \u0437\u043d\u0430\u0435\u0442 \u043e \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u00ab\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438, \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0432\u043e\u043d\u043a\u043e\u0432. \u041f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2013 \u044d\u0442\u043e \u043a\u0440\u0430\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u043c\u0435\u043d\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 \u043d\u0430\u0448\u0435\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435, \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432 \u043b\u044e\u0431\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Voximplant, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0441\u0435 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f. \u0420\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u00ab\u043d\u0435 \u043f\u043e\u043c\u043d\u0438\u043b\u0438\u00bb [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-53015","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/hranilishhe-key-value-ili-kak-nashi-prilozheniya-stali-udobnee\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 key-value, \u0438\u043b\u0438 \u043a\u0430\u043a \u043d\u0430\u0448\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u0438 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 | ProHoster\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/hranilishhe-key-value-ili-kak-nashi-prilozheniya-stali-udobnee\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-11-20T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:00:51+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Key-value storage, or how our applications became more convenient | ProHoster","description":"","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/hranilishhe-key-value-ili-kak-nashi-prilozheniya-stali-udobnee","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 key-value, \u0438\u043b\u0438 \u043a\u0430\u043a \u043d\u0430\u0448\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u0438 \u0443\u0434\u043e\u0431\u043d\u0435\u0435 | ProHoster","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/hranilishhe-key-value-ili-kak-nashi-prilozheniya-stali-udobnee","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-11-20T21:00:00+00:00","article:modified_time":"2020-02-18T11:00:51+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"53015","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-24 05:45:21","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 20:32:32","updated":"2026-01-24 05:45:21","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/53015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=53015"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/53015\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=53015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=53015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=53015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}