{
    "componentChunkName": "component---src-templates-doc-page-js",
    "path": "/docs/en/common/bot_structure/js/",
    "result": {"data":{"site":{"siteMetadata":{"title":"Gatsby-doc-engine"}},"markdownRemark":{"id":"f1c113b3-3960-5f73-821a-db2b02860213","excerpt":"JS code in a chat bot project?> JAICP DSL use JavaScript code snippets (EcmaScript v5) to describe business logic and integration with external systems. A bot…","html":"<h1>JS code in a chat bot project</h1>\n<hr>\n<p class='warn'>JAICP DSL use JavaScript code snippets (EcmaScript v5) to describe business logic and integration with external systems.</p>\n<p>A bot can perform calculations, verify previously saved data and react depending on the results of the conversation. For example, a bot can store certain information in variables and re-use it during conversation. A bot can also check the communication channel and display corresponding graphics depending on the result.</p>\n</br>\n<h3>JS code structure in a project</h3>\n<p>JS code in a project:</p>\n<ul>\n<li>Expressions in <a href=\"/1.10.5/docs/en/JAICP_DSL/tags/reaction_tags/if_elseif_else\"><code class=\"language-text\">if</code>, <code class=\"language-text\">else</code>, <code class=\"language-text\">elseif</code></a> tags — condition functions used to define conditional jump rules.</li>\n<li><a href=\"/1.10.5/docs/en/JAICP_DSL/tags/reaction_tags/script\"><code class=\"language-text\">script</code></a> tag — script snippets used to perform calculations and calls to external systems.</li>\n<li><a href=\"/1.10.5/docs/en/JAICP_DSL/tags/declarative_tags/init\"><code class=\"language-text\">init</code></a> tag — initialization scripts; executed only once when the script is loaded and can be used to create global variables and bind <a href=\"/1.10.5/docs/en/JS_API/built_in_functions/bind_(type_handler_path_name)\">pre/post processes</a>.</li>\n<li>Linked JS files — these files are linked to the script via the <a href=\"/1.10.5/docs/en/JAICP_DSL/tags/declarative_tags/require\"><code class=\"language-text\">require</code></a> tag. They contain objects and functions that can be used in any other script.</li>\n<li>Built-in functions — special objects and functions provided by the platform. They can provide functions that can be used to invoke a matcher or external services.</li>\n<li>Built-in libraries — JS libraries loaded automatically with each bot.</li>\n</ul>\n<p class='warn'>Learn more on built-in <a href=/1.10.5/docs/en/JS_API/variables/variables  >variables</a>, <a href=/1.10.5/docs/en/JS_API/built_in_functions/bind_(type_handler_path_name)  >functions</a> and <a href=/1.10.5/docs/en/JS_API/built_in_services/http/http  >services</a></p>\n</br>\n<h3>JS files</h3>\n<p>You can define your logic directly in the <code class=\"language-text\">.sc</code> script file. But we recommend moving all your JS code to a separate file. You will need to create a file with the <code class=\"language-text\">.js</code> extension in the <code class=\"language-text\">src</code> folder, e.g. <code class=\"language-text\">functions.js</code>. Add functions to it that can later be called from the script file after the <a href=\"/1.10.5/docs/en/JAICP_DSL/tags/reaction_tags/script\"><code class=\"language-text\">script</code></a> tag.</p>\n<p class='tip'>Please note that JS files contain objects and functions that can be used in any other script.</p>\n<p><code class=\"language-text\">.js</code> files are linked at the start of the script via the <code class=\"language-text\">require</code> tag:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">require:</span> scripts/functions.js</code></pre></div>\n<p class='warn'><a href=/1.10.5/docs/en/JAICP_DSL/tags/declarative_tags/require  >Learn more about using the <code class=\"language-text\">require</code> tag</a></p>","frontmatter":{"title":"","description":null},"headings":[{"value":"JS code in a chat bot project"}]}},"pageContext":{"slug":"/docs/en/common/bot_structure/js/","previous":{"fields":{"slug":"/docs/en/common/bot_structure/modules/"},"frontmatter":{"title":"","description":null}},"next":{"fields":{"slug":"/docs/en/common/bot_structure/csv/"},"frontmatter":{"title":"","description":null}}}},
    "staticQueryHashes": ["1209419333"]}