{
    "componentChunkName": "component---src-templates-doc-page-js",
    "path": "/docs/en/script_development/context/",
    "result": {"data":{"site":{"siteMetadata":{"title":"Gatsby-doc-engine"}},"markdownRemark":{"id":"31ff0b76-1a99-548a-b1b8-b0ffb81eb363","excerpt":"Managing the context noContext You can specify the  flag for the  tag, which takes a boolean value ( by default). If , the system will not change the context…","html":"<h1>Managing the context</h1>\n<hr>\n<h3>noContext</h3>\n<p>You can specify the <code class=\"language-text\">noContext</code> flag for the <a href=\"/1.10.3/docs/en/JAICP_DSL/tags/declarative_tags/state\"><code class=\"language-text\">state</code></a> tag, which takes a boolean value (<code class=\"language-text\">false</code> by default).</p>\n<p>If <code class=\"language-text\">noContext=true</code>, the system will not change the context when it switches to a state with that flag. The next request will be processed in the context of the previous one in this case.</p>\n<p>Consider the following script:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">theme:</span> /\n\t<span class=\"token keyword\">state:</span> Greeting\n\t\t<span class=\"token storageType\">q!:</span> * (hi/good (~day/~morning/~evening)) *\n\t\t<span class=\"token variableParameter\">a:</span> Hello! How are you doing?\n\n\t\t<span class=\"token keyword\">state:</span> DoinGood\n\t\t\t<span class=\"token storageType\">q:</span> * (good/ok/fine) *\n\t\t\t<span class=\"token variableParameter\">a:</span> I am glad you are fine! How can I help you?\n\n\t\t<span class=\"token keyword\">state:</span> DoinBad\n\t\t\t<span class=\"token storageType\">q:</span> * (bad|not [really] good) *\n\t\t\t<span class=\"token variableParameter\">a:</span> Sorry to hear that. Maybe I can help?\n\n\t<span class=\"token keyword\">state:</span> CatchAll\n\t\t<span class=\"token storageType\">event!:</span> noMatch\n\t\t<span class=\"token variableParameter\">a:</span> Sorry, I don’t understand you. Please try to rephrase.</code></pre></div>\n</br>\n<p>Greet the chat bot and answer <code class=\"language-text\">I am OK</code> to the <code class=\"language-text\">How are you doing?</code> question. The pattern does not cover that answer, so the script will switch to the <code class=\"language-text\">CatchAll</code> state and the chat bot will ask to rephrase. Say <code class=\"language-text\">well, everything is fine</code>. Although the pattern is matched, the request will not be recognized as the context of the conversation has changed and nested states are not available.</p>\n</br>\n<p>Set the <code class=\"language-text\">noContext</code> flag to the <code class=\"language-text\">CatchAll</code> state:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">theme:</span> /\n\t<span class=\"token keyword\">state:</span> Greeting\n\t\t<span class=\"token storageType\">q!:</span> * (hi/good (~day/~morning/~evening)) *\n\t\t<span class=\"token variableParameter\">a:</span> Hello! How are you doing?\n\n\t\t<span class=\"token keyword\">state:</span> DoinGood\n\t\t\t<span class=\"token storageType\">q:</span> * (good/ok/fine) *\n\t\t\t<span class=\"token variableParameter\">a:</span> I am glad you are fine! How can I help you?\n\n\t\t<span class=\"token keyword\">state:</span> DoinBad\n\t\t\t<span class=\"token storageType\">q:</span> * (bad|not [really] good) *\n\t\t\t<span class=\"token variableParameter\">a:</span> Sorry to hear that. Maybe I can help?\n\n\t<span class=\"token keyword\">state:</span> CatchAll || noContext=true\n\t\t<span class=\"token storageType\">event!:</span> noMatch\n\t\t<span class=\"token variableParameter\">a:</span> Sorry, I don’t understand you. Please try to rephrase.</code></pre></div>\n</br>\n<p>When we switch to the <code class=\"language-text\">CatchAll</code> state now, the context will not change and the next request will be processed within the <code class=\"language-text\">Greeting</code> state. So, the <code class=\"language-text\">well, everything is fine</code> response will be processed in the context of the <code class=\"language-text\">How are you doing?</code> state and will switch to the <code class=\"language-text\">DoinGood</code> nested state.</p>\n<p class='warn'>The <code class=\"language-text\">noContext</code> flag is used to avoid moving the conversation context forward. It is usually used in <code class=\"language-text\">CatchAll</code> states or in repeated replies.</p>\n</br>\n<h3>modal</h3>\n<p>You can specify the <code class=\"language-text\">modal</code> flag for the <a href=\"/1.10.3/docs/en/JAICP_DSL/tags/declarative_tags/state\"><code class=\"language-text\">state</code></a> tag, which takes a boolean value (<code class=\"language-text\">false</code> by default).</p>\n<p>If <code class=\"language-text\">modal=true</code>, the system will process the request in the context of that state, i.e. the request can only be switched to one of its nested states. If the nested states have no matching answer and the local <code class=\"language-text\">CatchAll</code> state is missing, the system will return an error. The error log will tell you that no state to switch to was found in the script.</p>\n<p class='warn'>States with the <code class=\"language-text\">modal=true</code> flag are used when you need some important information from the client that is required for the conversation to go on.</p>\n<p>How to use:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">theme:</span> /\n\n\t<span class=\"token keyword\">state:</span> OrderStatus|| modal = true\n\t\t<span class=\"token storageType\">q!:</span> * (where|status) * ~of order *\n\t\t<span class=\"token variableParameter\">a:</span> Hello! Please specify your order number.\n\n\t\t<span class=\"token keyword\">state:</span> GetNumber\n\t\t\t<span class=\"token storageType\">q:</span> * $Number *\n\t\t\t<span class=\"token variableParameter\">a:</span> Your order is underway!\n\t\t\t<span class=\"token variableParameter\">go!:</span> /WhatElse\n\n\t\t<span class=\"token keyword\">state:</span> LocalCatchAll\n\t\t\t<span class=\"token storageType\">event:</span> noMatch\n\t\t\t<span class=\"token variableParameter\">a:</span> This does not look like an order number. Please try again.\n\n\t<span class=\"token keyword\">state:</span> WhatElse\n\t\t<span class=\"token variableParameter\">a:</span> How else can I help you?</code></pre></div>\n</br>\n<p>The user wants to get the status of their order in this script and is prompted to specify the order number. <code class=\"language-text\">modal = true</code> prevents the conversation from exiting the order number prompt context until the required information is specified.</p>\n<p>Use the <a href=\"/1.10.3/docs/en/JAICP_DSL/tags/reaction_tags/go\"><code class=\"language-text\">go</code></a> tag or the <a href=\"/1.10.3/docs/en/script_development/context#fromstate\"><code class=\"language-text\">fromState</code></a> flag to exit a modal state.</p>\n<p class='tip'>Include <code class=\"language-text\">LocalCatchAll</code> in your script to avoid conversation errors.</p>\n</br>\n<h3>fromState</h3>\n<p>The <code class=\"language-text\">fromState</code> flag can be set for the <a href=\"/1.10.3/docs/en/JAICP_DSL/tags/declarative_tags/q\"><code class=\"language-text\">q</code></a> tag and defines a state from which a switch can be made based on this pattern.</p>\n<p class='warn'>You can use the <code class=\"language-text\">fromState</code> flag to address a question from a certain context to a desired state without using global pattern, or to exit the modal context at a certain request.</p>\n<p>How to use:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">theme:</span> /\n\n\t<span class=\"token keyword\">state:</span> OrderStatus || modal = true\n\t\t<span class=\"token storageType\">q!:</span> * (where|status) * ~of order *\n\t\t<span class=\"token variableParameter\">a:</span> Hello! Please specify your order number.\n\n\t\t<span class=\"token keyword\">state:</span> GetNumber\n\t\t\t<span class=\"token storageType\">q:</span> * $Number *\n\t\t\t<span class=\"token variableParameter\">a:</span> Your order is underway!\n\t\t\t<span class=\"token variableParameter\">go!:</span> /WhatElse\n\n\t\t<span class=\"token keyword\">state:</span> LocalCatchAll\n\t\t\t<span class=\"token storageType\">event:</span> noMatch\n\t\t\t<span class=\"token variableParameter\">a:</span> This does not look like an order number. Please try again.\n\n\t<span class=\"token keyword\">state:</span> WhatElse\n\t\t<span class=\"token variableParameter\">a:</span> How else can I help you?\n\n\t<span class=\"token keyword\">state:</span> Question\n\t\t<span class=\"token storageType\">q!:</span> * [answer me] (a/some) question* *\n        <span class=\"token storageType\">q:</span> l* [answer me] (a/some) question* * || fromState = /OrderStatus\n        <span class=\"token variableParameter\">a:</span> Of course, I am listening!</code></pre></div>\n</br>\n<p>Here the client exits the modal state if he or she has a question to the bot.</p>\n</br>\n<h3>onlyThisState</h3>\n<p>The <code class=\"language-text\">onlyThisState</code> flag is set for the <a href=\"/1.10.3/docs/en/JAICP_DSL/tags/declarative_tags/q\"><code class=\"language-text\">q</code></a> tag and is used together with the <a href=\"/1.10.3/docs/en/script_development/context#fromstate\"><code class=\"language-text\">fromState</code></a> flag.</p>\n<p class='warn'>If the <code class=\"language-text\">onlyThisState=true</code> flag is set, a switch based on the pattern with that flag can only be made from the state specified in the <code class=\"language-text\">fromState</code> flag — but not from nested states.</p>\n<p>If the <code class=\"language-text\">onlyThisState</code> flag is not set, the switch can also be made from nested states of the <code class=\"language-text\">fromState</code> state.</p>\n<p>How to use:</p>\n<div class=\"gatsby-highlight\" data-language=\"sc\"><pre class=\"language-sc\"><code class=\"language-sc\"><span class=\"token keyword\">theme:</span> /\n\n\t<span class=\"token keyword\">state:</span> OrderStatus || modal = true\n\t\t<span class=\"token storageType\">q!:</span> * (where|status) * ~of order *\n\t\t<span class=\"token variableParameter\">a:</span> Hello! Please specify your order number.\n\n\t\t<span class=\"token keyword\">state:</span> GetNumber\n\t\t\t<span class=\"token storageType\">q:</span> * $Number *\n\t\t\t<span class=\"token variableParameter\">a:</span> Your order is underway!\n\t\t\t<span class=\"token variableParameter\">go!:</span> /WhatElse\n\n\t\t<span class=\"token keyword\">state:</span> LocalCatchAll\n\t\t\t<span class=\"token storageType\">event:</span> noMatch\n\t\t\t<span class=\"token variableParameter\">a:</span> This does not look like an order number. Please try again.\n\n\t<span class=\"token keyword\">state:</span> WhatElse\n\t\t<span class=\"token variableParameter\">a:</span> How else can I help you?\n\n\t<span class=\"token keyword\">state:</span> Question\n\t\t<span class=\"token storageType\">q!:</span> * [answer me] (a/some) question* *\n        <span class=\"token storageType\">q:</span> * [answer me] (a/some) question* * || fromState = /OrderStatus<span class=\"token entityNameClass\">, onlyThisState =</span> true\n        <span class=\"token variableParameter\">a:</span> Of course, I am listening!</code></pre></div>\n<p>In the <a href=\"/1.10.3/docs/en/script_development/context#fromstate\"><code class=\"language-text\">fromState</code></a> example, you could switch to <code class=\"language-text\">/Question</code> from either <code class=\"language-text\">/OrderStatus</code> or <code class=\"language-text\">/OrderStatus/LocalCatchAll</code>; but here you can only switch from <code class=\"language-text\">/OrderStatus</code>.</p>","frontmatter":{"title":"","description":null},"headings":[{"value":"Managing the context"}]}},"pageContext":{"slug":"/docs/en/script_development/context/","previous":{"fields":{"slug":"/docs/en/security/log_removal/"},"frontmatter":{"title":"","description":null}},"next":{"fields":{"slug":"/docs/en/script_development/switch_states/"},"frontmatter":{"title":"","description":null}}}},
    "staticQueryHashes": ["1209419333"]}