{"id":2885,"date":"2023-01-18T16:42:36","date_gmt":"2023-01-18T15:42:36","guid":{"rendered":"https:\/\/botnation.ai\/nlp-tunnels\/"},"modified":"2026-01-02T15:27:56","modified_gmt":"2026-01-02T14:27:56","slug":"nlp-tunnels","status":"publish","type":"support","link":"https:\/\/botnation.ai\/en\/support\/nlp-tunnels\/","title":{"rendered":"NLP tunnels"},"content":{"rendered":"<p>How to detect several intentions in the same sentence<\/p>\n\n\n\n\n\n<p><strong>Definition of a Tunnel:<\/strong><br>This is a priority AI rule that triggers a search in another context. Optionally, an intermediate sequence can be started.<\/p>\n\n\n\n<p>This intermediate sequence can be used, among other things, to store data in passing in a variable without displaying anything in the chatbot.<\/p>\n\n\n\n<p><strong>Definition of a Variable:<\/strong><br>This is data that the chatbot will store in its memory. A variable is defined by its name and by its value.<\/p>\n\n\n\n<p><strong><em>Example: <\/em><\/strong><em>The Variable with the name \u201cproperty_type\u201d can take the value<\/em><\/p>\n\n\n\n<p><strong>It is a complex logic to master, but it is a very powerful tool. It will indeed make it possible to detect several intents in the same sentence.<\/strong> The Tunnel in the default context detects a first Intent and then searches the AI rules of another context for the second Intent.<\/p>\n\n\n\n<p>It is also possible to put Tunnels in the secondary context and therefore to detect a third Intent. <strong>In theory, using Cascading Tunnels you can detect as many intentions as you want <\/strong>in the same sentence. But from a practical point of view, it is better to limit yourself to three intentions.<\/p>\n\n\n\n<p>The best way to understand how it works is to study a practical case.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong><em>Exemple:<\/em><\/strong><\/p>\n\n\n\n<p><strong><em>Also in our London real estate chatbot, we want to detect, in natural language, the type of transaction, the type of property and the district concerned<\/em><\/strong><em> in order to be able to launch a search in an ad database.<\/em><\/p>\n\n\n\n<p><em>It is therefore necessary, not only for the chatbot to understand a sentence such as \u201c<strong>I am looking for an apartment for sale in Camden<\/strong>\u201d but also to translate this information into data that can be understood by the search engine.<\/em><br><\/p>\n\n\n\n<p><em>Cascading tunnels and their intermediate sequences will be able to solve this problem.<\/em><\/p>\n\n\n\n<p><strong><em>The general idea is to detect each intent one after the other.<\/em><\/strong><br><\/p>\n\n\n\n<p><strong><em>We will need 3 contexts<\/em><\/strong><em>: the <strong>default context <\/strong>in which we will detect the \u201cTransaction type\u201d intention, a <strong>\u201cAsset type\u201d context<\/strong> to detect this intention and finally a <strong>\u201cDistrict\u201d Context <\/strong>for this intention.<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><em>Default context<\/em><\/strong><\/h4>\n\n\n\n<p><em>We create a first <strong>Tunnel \u201cPurchase\u201d<\/strong> with the keywords corresponding to this intention and which will launch a search in the <strong>Context \u201cType of asset\u201d<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-159.png.webp\" alt=\"\" class=\"wp-image-6773\"><\/figure>\n\n\n\n<p><em>And we use the intermediate sequence to store the information by assigning the <strong>value \u201cpurchase\u201d to the variable \u201ctransaction_type\u201d.<\/strong><\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-160.png.webp\" alt=\"\" class=\"wp-image-6775\"><\/figure>\n\n\n\n<p><em>We then create a <strong>\u201cSale\u201d Tunnel <\/strong>with the corresponding keywords and which will also launch a search in the <strong>\u201cType of asset\u201d Context<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-161.png.webp\" alt=\"\" class=\"wp-image-6777\"><\/figure>\n\n\n\n<p><em>And we use the intermediate sequence to store the information by assigning, this time, the <strong>value \u201csale\u201d to the variable \u201ctransaction_type\u201d<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-162.png.webp\" alt=\"\" class=\"wp-image-6779\"><\/figure>\n\n\n\n<p><em>We can therefore see that we can have 2 different tunnels which refer to the same context, but since their intermediate sequences and their keywords are different, they detect two different intentions.<\/em><\/p>\n\n\n\n<p><em>The chatbot can now therefore make the difference between \u201cI am looking to <strong>sell <\/strong>my apartment in Camden\u201d and \u201cI want to <strong>buy <\/strong>an apartment in camden\u201d.<\/em><br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><em>Context \u201cType of asset\u201d<\/em><\/strong><\/h4>\n\n\n\n<p><em>We create a <strong>\u201cApartment\u201d Tunnel <\/strong>with the corresponding keywords and which will launch a search in the<strong> \u201cDistrict\u201d Context<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-163.png.webp\" alt=\"\" class=\"wp-image-6781\"><\/figure>\n\n\n\n<p><em>And we use the intermediate sequence to store the information by assigning the <strong>value \u201capartment\u201d to the variable \u201casset_type\u201d<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-164.png.webp\" alt=\"\" class=\"wp-image-6783\"><\/figure>\n\n\n\n<p><em>We then create a <strong>\u201cHouse\u201d Tunnel <\/strong>with the corresponding keywords and which will also launch a search in the <strong>\u201cDistrict\u201d Context.<\/strong><\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-165.png.webp\" alt=\"\" class=\"wp-image-6785\"><\/figure>\n\n\n\n<p><em>And we use the intermediate sequence to store the information by assigning, this time, the <strong>value \u201chouse\u201d to the variable \u201casset_type\u201d<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-166.png.webp\" alt=\"\" class=\"wp-image-6787\"><\/figure>\n\n\n\n<p><em>The chatbot can now make the difference between \u201cI\u2019m looking to sell my <strong>apartment <\/strong>in Camden\u201d and \u201cI\u2019m looking for a <strong>house<\/strong> for sale in Camden\u201d<\/em><br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><em>Context \u201cDistrict\u201d<\/em><\/strong><\/h4>\n\n\n\n<p><em>In this context, we create simple AI rules to detect each district, each of which will refer to sequences in which we will<strong> store the name of the district in the variable \u201c district\u201d<\/strong>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-167.png.webp\" alt=\"\" class=\"wp-image-6789\"><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-168.png.webp\" alt=\"\" class=\"wp-image-6791\"><\/figure>\n\n\n\n<p><strong><em>To summarize:<\/em><\/strong><\/p>\n\n\n\n<p><em>In the default context, the chatbot detects the type of transaction then searches for the type of asset in the \u201cType of asset\u201d context and finally detects the district in the \u201cDistrict\u201d context.<\/em><\/p>\n\n\n\n<p><em>And at each step, the chatbot stores the corresponding info in variables.<\/em><\/p>\n\n\n\n<p><em>So if the user writes \u201c<strong>I\u2019m looking to buy an apartment in Camden<\/strong>\u201d the chatbot will detect the intentions and translate them as follows:<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>transaction_type = <strong>purchase<\/strong><\/em><\/li>\n\n\n\n<li><em>asset_type = <strong>apartment<\/strong><\/em><\/li>\n\n\n\n<li><em>district = <strong>camden<\/strong><\/em><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/botnation.ai\/wp-content\/uploads\/2023\/01\/image-169.png.webp\" alt=\"\" class=\"wp-image-6794\"><\/figure>\n\n\n\n<p><em>The chatbot can then launch the search in the database because this is information that can be used by the search engine.<\/em><\/p>\n<\/blockquote>\n\n\n\n<p><strong>Detecting multiple intents in a typed sentence is a headache for all AIs<\/strong> around the world.<strong> With tunnels, our platform finally offers a pragmatic and effective solution to this problem.<\/strong><\/p>\n\n\n","protected":false},"featured_media":0,"template":"","meta":{"_acf_changed":false},"categorie-support":[194,198,221],"class_list":["post-2885","support","type-support","status-publish","hentry","categorie-support-features","categorie-support-tutorials","categorie-support-web-chatbot-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support\/2885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/support"}],"about":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/types\/support"}],"wp:attachment":[{"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/media?parent=2885"}],"wp:term":[{"taxonomy":"categorie-support","embeddable":true,"href":"https:\/\/botnation.ai\/en\/wp-json\/wp\/v2\/categorie-support?post=2885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}