<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arthur Grishkevich</title>
    <description>The latest articles on DEV Community by Arthur Grishkevich (@arrrgr).</description>
    <link>https://dev.to/arrrgr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F679074%2F3b96717c-8a6f-4266-ad86-7c0e26f1f651.png</url>
      <title>DEV Community: Arthur Grishkevich</title>
      <link>https://dev.to/arrrgr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arrrgr"/>
    <language>en</language>
    <item>
      <title>Conversational AI is now available via Zapier. 3 steps to a simple app</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Tue, 12 Oct 2021 06:06:18 +0000</pubDate>
      <link>https://dev.to/arrrgr/conversational-ai-is-now-available-via-zapier-3-steps-to-a-simple-app-ef4</link>
      <guid>https://dev.to/arrrgr/conversational-ai-is-now-available-via-zapier-3-steps-to-a-simple-app-ef4</guid>
      <description>&lt;p&gt;We finally integrated Dasha with Zapier. This is pretty awesome because now any conversational app you write for Dasha can be used as an input/output function using any other apps on Zapier. &lt;/p&gt;

&lt;p&gt;For example - we can input into a Dasha app the user's first name and phone number collected from a lead form on a website using Zapier. Dasha app calls the user and collects data which is then output into Hubspot CRM or Google Calendar or anything else you can think of.&lt;/p&gt;

&lt;p&gt;Here is a demo of the result: &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/MjKQ2Zibqgk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I previously wrote a &lt;a href="https://dasha.ai/en-us/blog/how-to-qualify-inbound-leads"&gt;tutorial&lt;/a&gt; on how such an app can be built using Dasha. Today we will integrate this app into a workflow, in less than fifteen minutes. For this tutorial we will use the following tools: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://daha.ai"&gt;Dasha&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://zapier.com"&gt;Zapier&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hubspot.com"&gt;Hubspot&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the process at a glance: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We create a stand-alone form on Hubspot with the fields "First Name", "Email" and "Phone". &lt;/li&gt;
&lt;li&gt;We point to this form submission as the action that initiates the Zap in Zapier. &lt;/li&gt;
&lt;li&gt;We launch a call with the Dasha Zapier integration and pass Name and Phone as input variables. &lt;/li&gt;
&lt;li&gt;Once the call is complete, we write all the collected information to specially created fields in the Hubspot lead card using another Zapier step. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, let's get started. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up your Dasha app
&lt;/h2&gt;

&lt;p&gt;For this tutorial we will reuse code that I wrote previously. It is a conversational AI app that qualifies inbound leads for a company (ACME Software) that sells a software for invoicing automation. At its core, the app checks if now is a good time to talk, asks a few questions and asks when a good time for the user to take a call from an account executive is. Let's get this application opened in your development environment. &lt;/p&gt;

&lt;p&gt;If you have never used Dasha before, you need to activate your API key. The API key lets you load your conversational application to the Dasha Cloud Platform, where it is executed. If you have your Dasha API key, ignore this part.  &lt;/p&gt;

&lt;p&gt;Make sure you have the latest Microsoft Visual Studio Code, Node.js and NPM installed. Dasha Studio is implemented as an extension to VSCode for your convenience. Open Visual Studio Code and install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=dasha-ai.dashastudio"&gt;Dasha Studio extension&lt;/a&gt; and Dasha Command Line Interface .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;code &lt;span class="nt"&gt;--install-extension&lt;/span&gt; dasha-ai.dashastudio &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; 
npm i &lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="s2"&gt;"@dasha.ai/cli@latest"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, run a command to register your Dasha API key. A browser window will pop up and you will need to sign up for an account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dasha account login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards, run to check your API key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dasha account info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you need to clone the inbound leads Dasha app and open the folder in which it is located. We will be cloning &lt;a href="https://github.com/dasha-samples/inbound-lead-qualification"&gt;this app&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/dasha-samples/inbound-lead-qualification
&lt;span class="nb"&gt;cd &lt;/span&gt;blank-slate-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In building Dasha apps in VSCode, you will mainly work with three files: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;main.dsl&lt;/strong&gt; is the Dasha Scripting Language file. DSL is a domain specific language, derived from TypeScript and used for the exclusive purpose of describing a conversation. You can read more about it in our &lt;a href="http://docs.dasha.AI"&gt;documentation&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;data.json&lt;/strong&gt; is the data set you provide to train the Dasha Cloud neural networks to recognize user &lt;a href="https://dasha.ai/en-us/blog/intent-classification"&gt;intents&lt;/a&gt; and identify &lt;a href="https://dasha.ai/en-us/blog/named-entity-recognition"&gt;named entities&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;index.js&lt;/strong&gt; is the server-side JavaScript file to which the Dasha SDK is imported and which launches the contents of the &lt;strong&gt;/app&lt;/strong&gt; folder to the Dasha Cloud to be executed. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note that last bit. "launches the contents of the &lt;strong&gt;/app&lt;/strong&gt; folder to the Dasha Cloud to be executed". This means that when your Dasha application is launched from Zapier, it only functions as the contents of the &lt;strong&gt;/app&lt;/strong&gt; folder. &lt;/p&gt;

&lt;p&gt;Take a look at the &lt;strong&gt;main.dsl&lt;/strong&gt; file, namely the context variables, beginning at line 7.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;context 
{
    input phone: string;
    input name: string = "";

    output software: string = "";
    output invoices: string = "";
    output lead_source: string = "";
    output calltimeday: string ="";

    calltime: string = "";
    callday: string = "";
    callback: string = "";
    visitedNodeTime: boolean = false;
    visitedNodeQuestion1: boolean = false;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that you are taking Input variables &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;phone&lt;/code&gt; and outputting variables &lt;code&gt;software&lt;/code&gt;, &lt;code&gt;invoices&lt;/code&gt;, &lt;code&gt;lead_source&lt;/code&gt; and &lt;code&gt;calltimeday&lt;/code&gt;. This is a key ingredient to the Zapier integration. We will input the &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;phone&lt;/code&gt; from the collected form data and output all of our output variables to be saved to the lead card in Hubspot. &lt;/p&gt;

&lt;p&gt;Now, you need to run a sample. It will serve two purposes. You will test the app and secondly, you will register the app in the Dasha Cloud to your account, so that you can refer to it from Zapier in building your integration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i 
npm start 12223334455 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where 12223334455 is your phone number in the international format. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Hubspot
&lt;/h2&gt;

&lt;p&gt;Log into your Hubspot account. Everything we will do here today can be done with the free Hubspot package. We will do two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a stand-alone form &lt;/li&gt;
&lt;li&gt;Add a few custom Contact properties &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Creating a form
&lt;/h3&gt;

&lt;p&gt;On the top menu, hit Marketing &amp;gt; Lead capture &amp;gt; Forms. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/2GBYn3kQ5AKCPGBN4sA6Zq/418bfbc8e9dbc0c5107cdaf887f4fea6/Screenshot_at_Oct_08_10-09-00.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/2GBYn3kQ5AKCPGBN4sA6Zq/418bfbc8e9dbc0c5107cdaf887f4fea6/Screenshot_at_Oct_08_10-09-00.png" alt="Screenshot at Oct 08 10-09-00"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, click Create Form in the upper right corner, select Standalone Page from the Form menu and click Next. Pick Blank Template and click Next again. Name your form (I named mine "Zapier test form") and add the following fields: First Name, Last Name, email, Phone number. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/6iB6AobAWe6sWspOHMhPwF/1217372728796eecacc7e2788550f33c/Screenshot_at_Oct_08_10-13-20.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/6iB6AobAWe6sWspOHMhPwF/1217372728796eecacc7e2788550f33c/Screenshot_at_Oct_08_10-13-20.png" alt="Fields in your Hubspot form "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Update &amp;gt; Publish. You will get a pop up with the link to access the form. Copy this link and set it aside, we will need it to test the integration. &lt;/p&gt;

&lt;h3&gt;
  
  
  Create custom fields (properties) in Hubspot
&lt;/h3&gt;

&lt;p&gt;Refer back to the output variables in &lt;strong&gt;main.dsl&lt;/strong&gt;. We need to map fields in Hubspot to four output variables. Here is how I named mine in Hubspot: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;calltimeday &amp;gt; call_time_day_test &lt;/li&gt;
&lt;li&gt;invoices &amp;gt; invoices_test&lt;/li&gt;
&lt;li&gt;lead_source &amp;gt; lead_source_test&lt;/li&gt;
&lt;li&gt;software &amp;gt; software_test &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Click on Settings, then Properties and finally Create Property. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/JYegbGLJcxSCgEy0rpAq6/3296aca24f1f0987d13785f7269fe948/Screenshot_at_Oct_08_10-17-38.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/JYegbGLJcxSCgEy0rpAq6/3296aca24f1f0987d13785f7269fe948/Screenshot_at_Oct_08_10-17-38.png" alt="Settings &amp;gt; Properties &amp;gt; Create Property in Hubspot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select &lt;br&gt;
Object Type &amp;gt; Contact &lt;br&gt;
Group: Contact information &lt;br&gt;
Label: &lt;code&gt;your name for the property&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/2WMSycfVpOUUFECf7dFbvp/1f8f70ffddb07381b8f8b6f0ef585050/Screenshot_at_Oct_08_10-36-28.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/2WMSycfVpOUUFECf7dFbvp/1f8f70ffddb07381b8f8b6f0ef585050/Screenshot_at_Oct_08_10-36-28.png" alt="Creating a new Property in Hubspot "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hit Next, and select field type: single line text. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/34FSLtWOUgY4blayFOkQ0R/fa74d8ee7b7728ab953aa294df575acd/Screenshot_at_Oct_08_10-37-06.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/34FSLtWOUgY4blayFOkQ0R/fa74d8ee7b7728ab953aa294df575acd/Screenshot_at_Oct_08_10-37-06.png" alt="Screenshot at Oct 08 10-37-06"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do the same for the other 3 properties. &lt;/p&gt;

&lt;p&gt;Now, let's make these properties clearly visible on the lead card, so that you can easily look at the results of the test. Open any contact by going to Contacts &amp;gt; Contacts and clicking on any one of them. Now, scroll a bit down and click "View all properties". &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/w6LeagyyS417iFxuz1oei/8c72741d973619982e287038ee920d0e/Screenshot_at_Oct_08_10-39-43.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/w6LeagyyS417iFxuz1oei/8c72741d973619982e287038ee920d0e/Screenshot_at_Oct_08_10-39-43.png" alt="View all properties in Hubspot "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, search for each of your newly added properties by their name and click "Add to your view" &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/VncrpJVjdu0Ltz7utVstb/31af3c8d827fb8e39fa59667936069c9/Screenshot_at_Oct_08_10-41-44.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/VncrpJVjdu0Ltz7utVstb/31af3c8d827fb8e39fa59667936069c9/Screenshot_at_Oct_08_10-41-44.png" alt="Add custom property to your Hubspot contact card view "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Great, our Hubspot is ready to go. Before moving to the next step, use that link to the form that you copied earlier to open up the form in a browser window, fill it out and submit. Use your real phone number in the international format (12223334455). This will give us some data for Zapier to use in the next step. &lt;/p&gt;

&lt;h2&gt;
  
  
  Create a custom Zapier Zap integration
&lt;/h2&gt;

&lt;p&gt;Log into your &lt;a href="https://zapier.com"&gt;`Zapier&lt;/a&gt; account. The Zap we are building is a complex multi step integration. Zapier free users only get to build two step integrations, so you will need to get the 7 day free trial of premium Zapier personal account to build this integration. &lt;/p&gt;

&lt;p&gt;Once sorted, click "Create Zap" in the upper left corner. Name the Zap and search for Hubspot as the first kick off event. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/13Et3NEsVJaGjWvC50E7gO/402593a018ee8575d0e83d60d76f5cee/Screenshot_at_Oct_08_10-47-51.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/13Et3NEsVJaGjWvC50E7gO/402593a018ee8575d0e83d60d76f5cee/Screenshot_at_Oct_08_10-47-51.png" alt="Add Hubspot as starter event to your Zapier Zap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose "new form submission" for the trigger event and hit "Continue". In the next step you will need to add a hubspot account. If you've never used one, click "+ Connect a new account". Once connected, click "Continue". Now you will be asked to set up the Trigger. Choose your Hubspot form name from the drop-down, click refresh fields and click "Continue". If you have previously filled out the Hubspot form, you should see something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/3NKHb6zJW3msDjuybmY0WZ/6110a1c8ca562a8c76cc23c62a5bd8c1/Screenshot_at_Oct_08_10-56-30.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/3NKHb6zJW3msDjuybmY0WZ/6110a1c8ca562a8c76cc23c62a5bd8c1/Screenshot_at_Oct_08_10-56-30.png" alt="Step 1 of the Zap complete "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Continue" and search for "Dasha" for Step 2. We will now connect Zapier to Dasha Conversational AI API. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/5qxujiAtEiAFwwKoKEiKJk/cd2011bf3116a42e1b819deffb2d662f/Screenshot_at_Oct_08_10-57-43.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/5qxujiAtEiAFwwKoKEiKJk/cd2011bf3116a42e1b819deffb2d662f/Screenshot_at_Oct_08_10-57-43.png" alt="Search for Dasha for Step 2 of the Zap "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Action Event Drop-down, select "Make a Call" and "Continue".  In the next "Choose account" drop-down, select your account and click "continue". &lt;/p&gt;

&lt;p&gt;On the next screen, choose "Provided by Dasha" for the dropdown "SIP Trunk to use", choose "inbound-leads" for the "Application to use" dropdown and select the upper-most value for "Application to use" dropdown. Once you select the application, two new fields should appear: "Phone" and "Name". These are the input variables required by the Dasha app. Select from the drop down appropriate fields, as collected by the Hubspot form. (Note if the fields "Name" and "Phone" do not appear, hit the "refresh fields" button). &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/3cnvOx36sp5eEH5SaoeyKw/9489d9dac272ee8d7ae86f3ec9f1ed28/Screenshot_at_Oct_08_11-02-20.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/3cnvOx36sp5eEH5SaoeyKw/9489d9dac272ee8d7ae86f3ec9f1ed28/Screenshot_at_Oct_08_11-02-20.png" alt="Almost done with Step 2 of our Zap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Test &amp;amp; Continue". You should get a call from your Dasha app. You will likely not see proper data appear in Zapier, do not fret, this seems to be the way it works. Once your Zap is complete, it will work as you want it to. &lt;/p&gt;

&lt;p&gt;Click the little plus sign below to go to the next step. &lt;/p&gt;

&lt;p&gt;In order to write data to Hubspot, we need to have the Contact ID number. Since we do not have it, we have to first make a request to Hubspot API to find the contact's ID using the contact's email (which we do have). Choose Hubspot under "action". For dropdown "Action event" look for "Find Contact". Next, select your Hubspot account. In the Set Up Action menu, select "Contact Information: Email" under "FIrst search property name" and for "First search property value" choose the email field from the first action (Hubspot form submission). &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/6rqP8v56DZlTUeMQKWKbPm/666880d5873682d400b46104fd55ab48/Screenshot_at_Oct_08_13-23-09.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/6rqP8v56DZlTUeMQKWKbPm/666880d5873682d400b46104fd55ab48/Screenshot_at_Oct_08_13-23-09.png" alt="Set up the action for retrieving contact's Object ID from Hubspot "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Continue" and then "Test &amp;amp; Continue." Now, click the + sign to create a new action. This final action will let us write the data collected by Dasha to the contact card in Hubspot. &lt;/p&gt;

&lt;p&gt;Select Hubspot and "Action event": Update contact. Hit "Continue". Choose your Hubspot account and hit "Continue" again. Under Object ID select the ID value we hav received in the previous step. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/7u6IvP2KubK6SPYmEsRolZ/cf9594bfefc80911321cbc32478848a9/Screenshot_at_Oct_08_13-37-58.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/7u6IvP2KubK6SPYmEsRolZ/cf9594bfefc80911321cbc32478848a9/Screenshot_at_Oct_08_13-37-58.png" alt="Setting up writing data to Hubspot "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, scroll down to find all the property field names we have previously added to Hubspot: &lt;br&gt;
&lt;code&gt;call_time_day_test&lt;/code&gt;&lt;br&gt;
&lt;code&gt;invoices_test&lt;/code&gt;&lt;br&gt;
&lt;code&gt;lead_source_test&lt;/code&gt;&lt;br&gt;
&lt;code&gt;software_test&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;For each, select the appropriate output data type from "Step 2 - Make a Call with Dasha", as such: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/1OqXaoPO4TmRMdcV2eOEUd/7a218cc9bbfe2a4dbeec79331bd297f2/Screenshot_at_Oct_08_13-39-55.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/1OqXaoPO4TmRMdcV2eOEUd/7a218cc9bbfe2a4dbeec79331bd297f2/Screenshot_at_Oct_08_13-39-55.png" alt="Select proper Dasha output data to be written to Hubspot "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hit "Continue" when you are done and "Turn on Zap".  &lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the Hubspot-Dasha-Hubspot Zapier integration
&lt;/h2&gt;

&lt;p&gt;Now to the fun part. Fill out your form again. Within 30 seconds you should get a call from Dasha. Give it all the information it asks for. Now, go to your lead card in Hubspot, you should see something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/1USZMvzOj00p3rqQLv2dMg/38cd3ec0235134fc43f25c2a3cdd1bd0/Screenshot_at_Oct_08_15-44-43.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/1USZMvzOj00p3rqQLv2dMg/38cd3ec0235134fc43f25c2a3cdd1bd0/Screenshot_at_Oct_08_15-44-43.png" alt="Your collected data in Hubspot "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In conclusion - you should make changes to the Dasha app, adapt it to the realities of your use case and tell us how it went in the &lt;a href="https://community.dasha.ai"&gt;Dasha community&lt;/a&gt;. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Conversational AI should be in every developer toolbox. Here's why.</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Wed, 15 Sep 2021 01:35:49 +0000</pubDate>
      <link>https://dev.to/arrrgr/conversational-ai-should-be-in-every-developer-toolbox-here-s-why-349i</link>
      <guid>https://dev.to/arrrgr/conversational-ai-should-be-in-every-developer-toolbox-here-s-why-349i</guid>
      <description>&lt;p&gt;Hi folks. I’ve posted a few conversational AI tutorial articles here. I realize that I failed to talk about one important thing - why you, as a developer, should even think about adding conversational technologies to your stack of tools. &lt;/p&gt;

&lt;p&gt;Fair warning: I work for a startup with the world’s most advanced conversational AI APIs and a studio built specifically for developers. Because of this, the examples of use cases and approaches below will be based on the art of the possible with Dasha. I will also talk to you about Google Dialogflow and Rasa AI which offer great sets of tools for some use cases. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why think about conversational voice technologies in the first place  
&lt;/h2&gt;

&lt;p&gt;Voice is the native interface for human-human communication. And that’s it. That’s your reason for why you should think about conversational AI technologies. The tactile way in which we communicate with machines today is a stepping stone. &lt;/p&gt;

&lt;p&gt;Look at science fiction to show you the way (I have been doing this since I learned to read and it hasn’t steered me wrong). HAL 5000 in 2001: A Space Odyssey, Eddie the ship's computer in HHGTTG, Jarvis in Iron Man. These are all machines that communicate with humans at a level indistinguishable from a human being. In this communication commands are born not in the simple command-response ways of today’s Alexa. &lt;/p&gt;

&lt;p&gt;These machines parse deep intent from the words of the human that is conversing with them, from their intonations, emotional tone and from the wider context of the conversation. Which is the same thing that humans do. Which makes the human feel comfortable in conversing with the machines. Which, in other words, passes the Turing test. &lt;/p&gt;

&lt;p&gt;In order for voice user interfaces to become ubiquitous, we need conversational AI that communicates at a level indistinguishable from a human, without falling into an uncanny valley trap. &lt;/p&gt;

&lt;h2&gt;
  
  
  Where is conversational voice AI today 
&lt;/h2&gt;

&lt;p&gt;What is done with conversational AI today: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chatbots. Mainly simple, often multiple-choice apps. Great for taking an order or routing a customer to the right support agent. I felt I had to mention, though the focus of this article is on voice. &lt;/li&gt;
&lt;li&gt;Basic voice user interfaces - Alexa Skills, Siri assistant and such. They are great for fulfilling a single function, for example, tell you the weather or play a song. As these are command-response interactions, they do not aim to pass the Turing test and they are limited in scope of application. &lt;/li&gt;
&lt;li&gt;Voice AI business automation. Call center automation from simple voice (not touch tone) menus to more complex outbound applications. Some of these applications (mainly outbound today) do aim to pass the Turing test and oftentimes do pass it. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’re not yet at the point where conversational AI can fully replace tactile interfaces. Yet we are getting there. Here is me giving a demo of a conversational app which I recently built: &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/46nyWBTSHgs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is a fairly simple demo. It only took me a few of hours to build from scratch. Using the same technology already today some Dasha users are building conversations with hundreds of logical nodes. In live call center environments, some apps are performing better than their human agent counterparts were before them. &lt;/p&gt;

&lt;p&gt;If you want to try building an app like the one in point 3, just look at my post history for some tutorials or pop in to our conversational AI dev &lt;a href="https://community.dasha.ai"&gt;community&lt;/a&gt;. You'll get an API key and instructions automatically upon joining. @ me in the intro channel, I’ll help where I can. &lt;/p&gt;

&lt;h2&gt;
  
  
  What will adding conversational AI to your toolbox give you, as a developer?
&lt;/h2&gt;

&lt;p&gt;It will give you two things. The ability to build voice interfaces for your apps and the ability to run automated telephone conversations with an API call. &lt;/p&gt;

&lt;h3&gt;
  
  
  Voice user interfaces
&lt;/h3&gt;

&lt;p&gt;With a deep voice interface you can let your users engage every interaction in your app with their voice. &lt;/p&gt;

&lt;p&gt;A few use cases for this: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your app is designed to be used on the go (walking, running, driving), for example, it’s a navigation app, a music app, etc.&lt;/li&gt;
&lt;li&gt;If there is a use case in which your app runs in the background, while the user switches to another app. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I think in the future, VUIs will be standard fare in most new software products. &lt;/p&gt;

&lt;p&gt;In the meantime, you can implement a voice user interface with Dasha using a connector to our Node.js SDK. Next year, we will roll out Swift and Kotlin SDKs. &lt;/p&gt;

&lt;h3&gt;
  
  
  Automated telephone conversations
&lt;/h3&gt;

&lt;p&gt;Kind of like Twilio giving developers the ability to use SMS text messages with the call of an API, a proper conversational AI API gives you the ability to conduct automated calls with the call of an API. &lt;/p&gt;

&lt;p&gt;Here are just a few use cases you might want to use this for: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Call a user who abandoned their shopping cart and ask if they need any help completing the purchase or have some questions they need answered.&lt;/li&gt;
&lt;li&gt;Call a user to verify some details or call them up as a part of an onboarding process. &lt;/li&gt;
&lt;li&gt;Set up a fully automated customer service line for your product. You can take calls through telephony or in-app using voice over GRPC.
&lt;/li&gt;
&lt;li&gt;Call back a newly generated lead in less than a minute to convert them into a user. &lt;/li&gt;
&lt;li&gt;Build a voice Discord bot that can do pretty much anything you can think of. &lt;/li&gt;
&lt;li&gt;Literally build a replacement for a call center agent and impress your boss at the big bank. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What skills do you need to build with conversational AI?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Analytical
&lt;/h3&gt;

&lt;p&gt;Analytical skills are important for two reasons. One - you need to logically structure your conversation before you begin developing it. Two - you will need to analyze live conversations that your AI app has with real human users and implement changes to improve the app. Rasa AI calls this second part Conversation Driven Development. I love this term. We at Dasha call it training the application. &lt;/p&gt;

&lt;h3&gt;
  
  
  Coding
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Google Dialogflow
&lt;/h4&gt;

&lt;p&gt;Interestingly enough, with Google Dialogflow, the analytical skill is the only one you will need to create conversations - it is an in-browser GUI for creating automated dialogues.  You can provide intents training data, create scripts,  STT and TTS comes out of the box. Two software engineers who tested all three platforms felt that their learning curve was higher with Dialogflow even though it was a no-code environment, than with Rasa or Dasha. Pros: no-code platform. Biggest cons: speech synthesis sounds very robotic, hard to make dialogue paths handle digressions. You may need a bit of technical knowledge to set up integrations through web hooks.&lt;/p&gt;

&lt;h4&gt;
  
  
  Rasa AI
&lt;/h4&gt;

&lt;p&gt;To use Rasa, you will need to have Python installed to use Rasa Open Source. Knowledge of Python will be needed as you build. You can specify intents, as a part of training data. As mentioned earlier, Rasa is a technology for chatbots. If you want to use it with voice, you will need to connect external text to speech and speech to text. Connecting to external services obviously adds delays which detracts from the conversational user experience. &lt;/p&gt;

&lt;p&gt;There are multiple dialogue policies which can be used simultaneously and which dictate conversation flow (I found this a bit confusing). Rasa has a great low-code/no-code GUI for conversational design. You describe dialogue using stories and intents using NLU data. You can also specify bot responses, forms (collecting data) and rules. The open source Rasa server runs on your machine and connects to your app. &lt;/p&gt;

&lt;p&gt;Its main pro is that you can quickly build simple, straightforward text conversations. Its main drawback is that it is a bot builder. It does not aspire to let you create conversations which are human-like in form and content.&lt;/p&gt;

&lt;h4&gt;
  
  
  Dasha AI
&lt;/h4&gt;

&lt;p&gt;To use Dasha, you will need to have Node.js installed. You will also want to know JavaScript. DashaScript is a domain-specific language which you use to script the dialogue between the machine and the user. &lt;/p&gt;

&lt;p&gt;You specify intents training data, much as you do with Rasa, but with Dasha you can also define named entities which can be used for slot filling. You define AI responses in the phrase map or right within the body of your dialogue script. You can define &lt;a href="https://dasha.ai/en-us/blog/using-digressions"&gt;digressions&lt;/a&gt; (send conversation to a specific node at any point based on what the user has said), to emulate how humans do dialogue. Human-like speech synthesis and text to speech come out of the box. Dasha SDK runs within your Node.js app, the conversation gets executed in the Dasha Cloud. &lt;/p&gt;

&lt;p&gt;Dasha’s main pro is that you can build simple human-like conversations quickly or take longer to build complex conversations of nearly unlimited depth. Its main drawback is that we are still in Beta and polishing up some details with user feedback. All the more reason to join our &lt;a href="https://community.dasha.ai"&gt;community&lt;/a&gt; and be one of the folks giving their input to this AI as a service engine. Don’t get it twisted though, we have paying customers using the product even in its Beta. Dasha AI is processing close to 10 million conversations monthly. &lt;/p&gt;

&lt;h2&gt;
  
  
  In closing
&lt;/h2&gt;

&lt;p&gt;To summarize, you’ll be able to add conversational AI to your stack of developer tools even if you have only a few months of programming experience. I’m a case in point - I started building with Dasha, then started teaching myself JavaScript with FreeCodeCamp. I have used Rasa Open Source and had no problem with it even though my Python skills are almost non-existent.&lt;/p&gt;

&lt;p&gt;You should hold some of these tools in your stack because they let you engage with users in ways that differentiate the user experience.  &lt;/p&gt;

&lt;p&gt;Have you used conversational AI dev tools before? &lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to lose a hackathon in 7 steps</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Tue, 31 Aug 2021 12:04:42 +0000</pubDate>
      <link>https://dev.to/arrrgr/how-to-lose-a-hackathon-in-7-steps-2kf0</link>
      <guid>https://dev.to/arrrgr/how-to-lose-a-hackathon-in-7-steps-2kf0</guid>
      <description>&lt;p&gt;I took part in a hackathon recently. My team lost miserably. Here are the steps we followed to secure this loss.&lt;/p&gt;

&lt;p&gt;You may find these valuable if you do want to win the next hackathon you participate in. Or if you want to lose it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Losing a hackathon
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1 - Don’t prepare until an hour or two before the event starts
&lt;/h3&gt;

&lt;p&gt;This step is absolutely key. If you ignore it you might actually have a chance of winning. We had thought about reviewing the APIs we would be working with and getting together a week prior to the hackathon. Had we done so, we might have had time to brainstorm and come up with a concept for our product. We might even have mapped out our architecture and integrations, if at a high level. Or we may have defined our areas of responsibility. Certainly we would have been one step closer to winning, so we did not do it. Instead, we got together at the official start of the hackathon, bounced some ideas around, picked the worst one (more on that below) and ran with it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 - Come to the hackathon exhausted
&lt;/h3&gt;

&lt;p&gt;This step really helps. Stay up for 12-18 hours before you begin your 24 hours of coding. Due to my current timezone constraints, I and one of my teammates were up working at 6am that day and sat down to the hackathon at 10pm. &lt;/p&gt;

&lt;p&gt;Dare I claim this feat made us more productive? Hell no. As a matter of fact, by the time we had gone to get some rest at 6am, we thought we were close to 50% done with our app but after getting some sleep, ended up having to rewrite some of the application code. We also were nowhere near finished in terms of integrating the whole thing together and deploying. I’d guess we were 20% done by the 6am mark, a far shot from the 50%.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 - Solve a problem that doesn't exist
&lt;/h3&gt;

&lt;p&gt;This one is the cherry on the cake. Instead of making sure your app solves a real world problem, create a problem out of thin air. We wanted to showcase our own technology and in our brainstorming session (see Step 1 above) we came up with two use cases. One solved a real problem (replacing call center agents). The other did not (onboarding new customers with voice) but looked cool. We picked the latter. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 - Don’t use the tech made available to you by event organizers
&lt;/h3&gt;

&lt;p&gt;Obviously this step only applies to those hackathons where organizers want participants to make use of their technologies. This one is quite self explanatory isn’t it? If the organizers want you to use their tech, make a token gesture to it. A nod. This is a sure way to lose the hackathon. &lt;/p&gt;

&lt;p&gt;We made a big mistake in picking our use case (Step 3). We picked the one which used exactly two methods in the US Bank APIs. The Brits might call this “taking the piss.” In contrast, the winner made use of what looked like 80% of the available methods.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 - Make it perfect!
&lt;/h3&gt;

&lt;p&gt;Instead of building fast and shipping a rough but enticing product, focus on polishing the user experience. This one is all me. I was the team member responsible for the user-facing conversational AI interface and I spent A LOT of time reworking it, adjusting for more and more complex pathways and running test conversations over and over. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6 - Forget about the time
&lt;/h3&gt;

&lt;p&gt;You know how you are going to have to create a presentation and practice presenting, make sure your deploys are working and data is rendering properly and actually run through the full demo a half dozen times to make sure you can fit the entire thing in five minutes? Yeah, forget about that. Instead, focus on Step 5. When you have 20 minutes left before the submission deadline, throw together a half assed deck and submit your code one minute after the cut off. Then find out that you are the second presenter in line and presentations are moved up 1.5 hours and start… right now. If you follow this step, you are guaranteed to lose. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7 - Ignore the presentation software
&lt;/h3&gt;

&lt;p&gt;WebEx never works like it’s meant to. But that’s no reason for you to worry. Yes, don’t worry about it. When it’s time for you to present, just open the thing in Safari and when you find out that you can’t share your screen, shrug it off and start telling a bad joke while the desktop version downloads. This is sure to put the judges in a good mood and not to penalize you at all. And, yes, this also really happened. &lt;/p&gt;

&lt;h2&gt;
  
  
  What we built
&lt;/h2&gt;

&lt;p&gt;Reading over this now, it looks like such a trainwreck. It’s making me ask - did we do anything right? I think we did. &lt;/p&gt;

&lt;p&gt;We split up our areas of responsibility and stuck to them, yet helped each other out where needed. We stayed in a Discord voice channel and communicated the entire time we were online and working. We were civil to each other even as the deadline approached. &lt;/p&gt;

&lt;p&gt;For our product, we built an automated voice user onboarding workflow. The user opens the app, enters their phone number, gets a call from an AI agent who asks them a series of questions, helps them to open their account, suggests they may want to create a virtual credit card and takes them through the card creation process. We also built (I think) a fairly cool app concept. &lt;/p&gt;

&lt;p&gt;We used ReactJS, HTML5 on the front-end, ExpressJS, Node.js and MongoDB on the back-end, Websocket for communications, and consumed the bank’s card as a service API. We used Dasha AI Studio to create the conversational workflow and the Dasha SDK in our Node.js back-end to make the conversational workflow an integral part of the application. Here is me giving a demo of the app for some friends after we lost (if you like the conversational part, you can join our &lt;a href="https://community.dasha.ai"&gt;developer community&lt;/a&gt; where we build AI apps): &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/FlqnbPQQfv4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Final words
&lt;/h2&gt;

&lt;p&gt;Congratulations. Now you know how to lose any hackathon. By extension, you now know what to avoid in order to increase your chances of winning a hackathon. Good luck and godspeed. &lt;/p&gt;

</description>
      <category>ai</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Make a small business owner happy by building an AI receptionist for them</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Tue, 31 Aug 2021 07:03:23 +0000</pubDate>
      <link>https://dev.to/arrrgr/make-a-small-business-owner-happy-by-building-an-ai-receptionist-for-them-1nf6</link>
      <guid>https://dev.to/arrrgr/make-a-small-business-owner-happy-by-building-an-ai-receptionist-for-them-1nf6</guid>
      <description>&lt;p&gt;I don’t know about you but for me my experience with many a business begins with a phone call. Yes, I’m old-fashioned like that. I will glance through the website but if I don’t find what I’m after in under 30 seconds, I will call and ask my questions. &lt;/p&gt;

&lt;p&gt;The best experience I get on the phone is a pickup on the second ring and a well-informed receptionist who is able to answer all my questions and (sometimes) schedule an appointment at a perfect (hopefully) time to get my beard trimmed. Okay, okay, you got me. Since COVID these appointments have been few and far between. Yet this is why a great experience (starting with the phone and ending with the coffee) is so important to me. These days - a cut is an experience in and of itself. &lt;/p&gt;

&lt;p&gt;The worst experience I get on the phone… I won’t talk about. I’m sure you have your own worst experience to roll your eyes at.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the best virtual receptionist for a small business?
&lt;/h2&gt;

&lt;p&gt;Not every small business, especially today, has the manpower for a full-time receptionist. As a matter of fact, due to a perfect storm of 2020, as many as 51% of U.S. small businesses report that they are understaffed. &lt;/p&gt;

&lt;p&gt;If you are losing customers because you lack the staff to professionally attend to your phone, you have at least a few options. The most expensive one is hiring a new receptionist. The others concern virtual receptionists. Here you have two choices - you can hire an answering agency and get the help of a human online receptionist. Or you can set up a human-like AI digital receptionist to answer your phones and… you guessed it, delight your customers. &lt;/p&gt;

&lt;h3&gt;
  
  
  Pros and cons of a human phone answering service:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flexible on the phone &lt;/li&gt;
&lt;li&gt;Sound human &lt;/li&gt;
&lt;li&gt;Can chat about the weather &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Disinterested in your business &lt;/li&gt;
&lt;li&gt;May lack access to your latest schedules/calendars&lt;/li&gt;
&lt;li&gt;May speak with an accent&lt;/li&gt;
&lt;li&gt;Any change in your service has to be communicated to management, in hopes it gets to the agents in time&lt;/li&gt;
&lt;li&gt;While cheaper than hiring internally, can be pricy &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When considering a human answering service, bear in mind that the agents are generally overworked and underpaid and highly disinterested in the service they are providing. There is a reason that the call center industry attrition rate hangs around the 120% per year mark. &lt;/p&gt;

&lt;h3&gt;
  
  
  Pros and cons of an AI phone answering service*:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never has a bad day, always as interested and excited, as the minute you launched it &lt;/li&gt;
&lt;li&gt;Actually sounds like a human and understands your customers like a human would&lt;/li&gt;
&lt;li&gt;Through integrations has direct access to your calendars and CRM &lt;/li&gt;
&lt;li&gt;Any changes to the script can be made in minutes&lt;/li&gt;
&lt;li&gt;Always on and always available (even at 4:20am)&lt;/li&gt;
&lt;li&gt;Very inexpensive&lt;/li&gt;
&lt;li&gt;Can transfer to a live person, if needed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;_&lt;em&gt;Cons _&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It will only respond and interact with the customer on pre-programmed pathways &lt;/li&gt;
&lt;li&gt;At the end of the day it is limited by its programming and interactions&lt;/li&gt;
&lt;li&gt;It is not a human &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** This section is referring to Dasha AI phone answering app, because our tech is the only one we feel we know enough about to speak of. *&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set up your AI phone answering service using Dasha AI
&lt;/h2&gt;

&lt;p&gt;So you are thinking about an AI digital receptionist to answer phone calls for you. Companies already use Dasha AI to automate their inbound customer service conversations, including with AI answering services. The cool thing about our tech is you can start testing it and using it a low volume with no contracts or payments.&lt;/p&gt;

&lt;p&gt;If you are not a programmer, this section may look daunting at first. I understand because I, too, am not a software developer, but a marketer. Yet I found myself writing AI apps with Dasha in under two hours. The language syntax is self-explanatory and the entire low-code studio is designed in such a way, as to let any citizen developer* use it with minimal difficulties. &lt;/p&gt;

&lt;p&gt;** A &lt;a href="https://dasha.ai/en-us/blog/citizen-development"&gt;citizen developer&lt;/a&gt; is any person who uses low-code/no-code development environments to create simple applications that directly solve for business needs, without resorting to the help of a professional software developer *&lt;/p&gt;

&lt;p&gt;Here are the steps that we will go through: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Dasha Studio and load an app &lt;/li&gt;
&lt;li&gt;Modify the app&lt;/li&gt;
&lt;li&gt;Test the app
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Installing Dasha Studio and loading a pre-built AI virtual receptionist app
&lt;/h3&gt;

&lt;p&gt;Head over to &lt;a href="https://nodejs.org/en/download/"&gt;https://nodejs.org/en/download/&lt;/a&gt; and download and install the latest version of Node.js. Node.js is one of the world’s most common JavaScript frameworks. You won’t need to do anything with it but it will need to be installed on your machine for Dasha Studio to run its code. &lt;/p&gt;

&lt;p&gt;Now go to &lt;a href="https://code.visualstudio.com"&gt;https://code.visualstudio.com&lt;/a&gt; and download the latest version of Visual Studio Code for your machine. &lt;/p&gt;

&lt;p&gt;Finally, go to &lt;a href="http://community.dasha.ai"&gt;http://community.dasha.ai&lt;/a&gt; and join Dasha’s developer community. A team member will reach out to you and give you instructions on how to install Dasha Studio, as well as receive your API key. We are issuing API keys manually for now, as we are in closed beta, and want to be sure each new developer (or citizen developer) has access to our Customer Success engineering team to answer any questions they may have.&lt;/p&gt;

&lt;p&gt;Click through to the Dasha Code Sample repository on GitHub. You are looking for the SMB receptionist sample app: &lt;a href="https://github.com/dasha-samples/dasha-smb-receptionist-demo"&gt;https://github.com/dasha-samples/dasha-smb-receptionist-demo&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Click on the green “download Code” button and select “Download Zip”, as illustrated below. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/1Q9Dw5KIRkZvpAAyNMgXhg/84137355e872a7af30b855e612e71d8e/Click_-download-.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/1Q9Dw5KIRkZvpAAyNMgXhg/84137355e872a7af30b855e612e71d8e/Click_-download-.png" alt="Click 'download'"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unzip the archive into a folder. Now, open your Visual Studio Code and click File &amp;gt;&amp;gt; Open &amp;gt;&amp;gt; your folder. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/60HYOwdIoRjBtKRpjUoQGN/0fea9e7fb6916fffec23bf8a98a7eb32/Click_File_-_Open_-_your_folder.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/60HYOwdIoRjBtKRpjUoQGN/0fea9e7fb6916fffec23bf8a98a7eb32/Click_File_-_Open_-_your_folder.png" alt="Click File - Open - your folder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Voila, you have opened the Dasha SMB Receptionist conversational AI app. Now, make sure that you have Dasha Studio extension installed in your Visual Studio Code. Navigate to extensions on the left side bar, type in Dasha Studio, click on Dasha Studio 1.2.3 and hit the Install button. (since I already have it installed, my button says “disable”). &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/6GE8MFwuYYCsZyEMwrgxkd/275de03259c4538441896abd956f5b26/Click_-disable-.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/6GE8MFwuYYCsZyEMwrgxkd/275de03259c4538441896abd956f5b26/Click_-disable-.png" alt="Click 'disable'"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, turn on your terminal. The Terminal (sometimes referred to as the command line or console), lets you run tasks and commands without using a graphical user interface (GUI). You will use your terminal to test Dasha apps. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/6PUsmYhmk5ak9J0GH1iOjt/7fe291a913aef1afd67c5b32a77e4480/Click_-new_terminal-.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/6PUsmYhmk5ak9J0GH1iOjt/7fe291a913aef1afd67c5b32a77e4480/Click_-new_terminal-.png" alt="Click 'new terminal'"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Perfect, now you’re all set and we get to the fun part. &lt;/p&gt;

&lt;p&gt;In the terminal type in: &lt;br&gt;
&lt;strong&gt;npm i -g "@dasha.ai/cli"&lt;/strong&gt;&lt;br&gt;
This will install the Dasha CLI (command-line interface). &lt;em&gt;if you are on MacOS, you may need to preface the command with &lt;strong&gt;sudo&lt;/strong&gt; - this will let your machine know to run the command, as top-level administrator user with full access rights. The full command will be&lt;/em&gt; &lt;strong&gt;sudo npm i -g "@dasha.ai/cli"&lt;/strong&gt; &lt;em&gt;and once you run it, will ask for your password. This is the password you use to log into your machine.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Perfect. The Command line interface is installed and initiated. Now type in the command &lt;strong&gt;npm i.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You’re all set. Now let’s figure out how the whole thing works. I promise - it’s not too complex. &lt;/p&gt;
&lt;h3&gt;
  
  
  Understanding the DashaScript code and making changes to the AI virtual receptionist app
&lt;/h3&gt;

&lt;p&gt;First - click on &amp;gt; app in the left-hand menu and doubleclick on &lt;strong&gt;main.dsl&lt;/strong&gt; and &lt;strong&gt;intents.json&lt;/strong&gt;. These two are the most important files you will work with. Main.dsl is literally the actual conversion script. Intents.json lets you train the neural network on which responses signify which &lt;/p&gt;

&lt;p&gt;Now, if you click on &lt;strong&gt;main.dsl&lt;/strong&gt;, you will see a little icon off to the right that looks like a dialogue pathway. Click that.  Now you should see this: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/5xMbjZVAgVplFEMSOezc44/c9ec853fd17ad1314ffb5ffe0ff61d50/Dialogue_pathway.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/5xMbjZVAgVplFEMSOezc44/c9ec853fd17ad1314ffb5ffe0ff61d50/Dialogue_pathway.png" alt="Dialogue pathway"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This map is a visualized dialogue pathway of the AI receptionist app. Here we only see the high-level nodes. To get into the nitty gritty of their behavior, we need to look at the code in main.dsl. Do refer back to the map, as you study the application code in main.dsl to help you better understand the flow. &lt;/p&gt;

&lt;p&gt;Let me help you to understand what is happening in the code. &lt;/p&gt;

&lt;p&gt;Lines 7-16&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
   do
   {
       #connectSafe($phone);
       #waitForSpeech(1000);
       #sayText("Church's Barbershop and Sodapop! How can I help you?");
       wait *;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the root node, the first node. This is where the conversation begins. When the connection is safely established to the phone number specified, the AI receptionist waits for 1000 milliseconds. If it hears speech within 1000ms, it responds with "Church's Barbershop and Sodapop! How can I help you?”  If it hears silence on the other end of the line, after 1000 ms (1 second), it states the same greeting. Then it waits for a response.&lt;/p&gt;

&lt;p&gt;This is a very straightforward sample app and the AI is really expecting a single type of response back - the user wants to come in for a hair appointment. &lt;/p&gt;

&lt;p&gt;Let’s navigate over to intents.json file to understand what types of interactions our AI is prepared for. &lt;/p&gt;

&lt;p&gt;There are two major parts to this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"includes": {
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refer to phrases that elicit a response in the AI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"excludes": {
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refer to phrases that the AI ignores. &lt;/p&gt;

&lt;p&gt;We have the following intents in the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   "schedule_haircut"
   "cancel_appt"
   "bye"
   "monday"
   "tuesday”
   "wednesday"
   "thursday"
   "friday"
   "saturday"
   "sunday" 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can guess - the intent &lt;em&gt;&lt;strong&gt;cancel_appt&lt;/strong&gt;&lt;/em&gt; tells the phone answering software that the customer wants to cancel their appointment, &lt;em&gt;&lt;strong&gt;bye&lt;/strong&gt;&lt;/em&gt; is the intent that tells the AI that the customer wants to end the conversation, the days of the week tell the AI when the user wants to come in and &lt;strong&gt;&lt;em&gt;schedule_haircut&lt;/em&gt;&lt;/strong&gt; tells the AI phon answering app that the customer wants to schedule a haircut.&lt;/p&gt;

&lt;p&gt;Let’s look at that last one to understand how the neural network sorting intent is programmed. You, as the user, need to specify a few variations of the phrase that the customer might use in conveying their intentions to the AI. In this case, we have specified six ways of saying the same thing. This is most of the time enough data to train the neural network to recognize a variety of variations in which the customer might go about requesting the same thing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"schedule_haircut": [
     "I need a haircut",
     "I want my hair cut",
     "schedule haircut",
     "can I have a haircut",
     "schedule an appointment",
        "haircut"
   ], 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s try and add a new intent to the file. The AI virtual receptionist introduced itself as “Church’s barber and soda fountain.” How about we ask what sodapop is available on tap.&lt;/p&gt;

&lt;p&gt;To do this we will need to copy one of the existing intents and paste it right below. Then we need to change the name of the intent to &lt;em&gt;&lt;strong&gt;soda_on_tap&lt;/strong&gt;&lt;/em&gt; and add a few definitions of the intent for the neural network to train itself. &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/1sWTVcUv2lCagABdUZv4eo/61a870f87c20acdaa9438aed1da4d62b/soda-on-tap.gif" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/1sWTVcUv2lCagABdUZv4eo/61a870f87c20acdaa9438aed1da4d62b/soda-on-tap.gif" alt="soda-on-tap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the resulting code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     "soda_on_tap": [
     "what soda do you have?",
     "what sodas do you have on tap?",
     "can I get a soda?",
     "what about soda",
     "soda?"
   ], 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now hit Control+S or Cmd+S to save the file. (Your Visual Studio Code likely has auto save features, however, we want to be on the safe side. &lt;/p&gt;

&lt;p&gt;Well done - you have created your first intents. In a bit, you will instruct Dasha AI Platform to train a neural network to recognize them. How cool is that? &lt;/p&gt;

&lt;p&gt;Anyway, now we need to use these intents in the course of the conversation. Our conversation structure (the script) is kept in the main.dsl file. Click it now. &lt;/p&gt;

&lt;p&gt;You already met &lt;em&gt;&lt;strong&gt;node root&lt;/strong&gt;&lt;/em&gt; (lines 7-16). Now if you look at lines 18-31, you see &lt;em&gt;&lt;strong&gt;digression&lt;/strong&gt;&lt;/em&gt; &lt;em&gt;_&lt;em&gt;schedule_haircut _&lt;/em&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can probably tell, this piece of code is called upon when the customer wants to schedule a haircut. Yet, you may have noticed it is called a “digression” and not a “node” What is the difference between a Digression and a Node? A Digression is a node that can be called up by the customer at any point in the conversation. Sort of like, when you’re speaking with your friend and at any point in the conversion, irrespective of what you’re talking about, you could say “oh by the way, how is the weather where you are?” and your friend will understand the question and respond. By the same token, a Digression prepares Dasha AI to answer a given question at any point in the conversation. &lt;/p&gt;

&lt;p&gt;This is a very useful function for our purposes. As we saw when we looked at &lt;strong&gt;intents.json&lt;/strong&gt; the app is now trained to answer three requests - scheduling a haircut, cancelling an appointment or ending the conversation. However, with adding a new intent &lt;em&gt;&lt;strong&gt;soda_on_tap&lt;/strong&gt;&lt;/em&gt;  we need to add a new digression, to make use of the intent. &lt;/p&gt;

&lt;p&gt;To do this we need to copy lines 18-31 and paste them into the file. Right below, at line 32 is fine. Great. Now, let’s go through the code line by line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digression schedule_haircut
{
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line specifies that the code that follows within the curly brackets is a digression and names the digression, in this case &lt;em&gt;&lt;strong&gt;schedule_haircut&lt;/strong&gt;&lt;/em&gt; let’s change that name to &lt;em&gt;&lt;strong&gt;soda_on_tap&lt;/strong&gt;&lt;/em&gt; since this is what we called our intent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conditions {on #messageHasIntent("soda_on_tap");}
   do
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we instruct the AI receptionist app to do a specific action when it recognizes a specific intent. In other words, if the AI app recognizes an intent, this digression is launched and the action is performed. &lt;br&gt;
Since the intent we created earlier is called &lt;em&gt;&lt;strong&gt;soda_on_tap&lt;/strong&gt;&lt;/em&gt;, this is what we replace the intent name with&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;note: digression name and intent name can be different. I’m using the same here to make it easier on us
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;do
   {
       #sayText("You want to get a haircut, did I hear you correctly?");
       wait *;
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, we instruct the AI app what action to take. In this case - say a specific text and wait for the customer to respond. Let’s tell the customer about our soda options and ask if they want a haircut. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;We’ve got Dr. Pepper, Coke Zero, Raspberry Sprite and a mystery flavor. You’re welcome to unlimited soda. Would you like to book your haircut appointment now?&lt;/strong&gt;&lt;/em&gt; You can use this text, or write your own version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;transitions
   {
       schedule_haircut_day: goto schedule_haircut_day on #messageHasSentiment("positive");
       this_is_barbershop: goto this_is_barbershop on #messageHasSentiment("negative");
   } 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We had the AI virtual receptionist ask the customer if they want to go ahead and book their haircut appointment now. In this block of code here, we instruct the AI app what to do if the customer says “yes” or “no”. Note that we did not have an intent for “yes” or “no” in the intents.json file. That is because positive and negative sentiment is recognized at the native level by the platform. To call a upon it, the function &lt;em&gt;&lt;strong&gt;#messageHasSentiment("sentiment")&lt;/strong&gt;&lt;/em&gt;;  is used. In this case, if the sentiment is positive, the AI app goes to node &lt;em&gt;&lt;strong&gt;schedule_haircut_day&lt;/strong&gt;&lt;/em&gt; to ask the customer what day they want to come in. If the sentiment is negative, the AI app goes to &lt;em&gt;&lt;strong&gt;can_help_then&lt;/strong&gt;&lt;/em&gt;, a node that asks the customer how they can be helped. &lt;br&gt;
We will not change anything in this code, because it does exactly what we want it to do. &lt;/p&gt;

&lt;p&gt;Here is the code we just created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digression soda_on_tap
{
   conditions {on #messageHasIntent("soda_on_tap");}
   do
   {
       #sayText("We’ve got Dr. Pepper, Coke Zero, Raspberry Sprite and a mystery flavor. As you get barbered, you’re welcome to unlimited soda. Want to book your haircut now? And before you ask - we do have a restroom.");
       wait *;
   }
   transitions
   {
       schedule_haircut_day: goto schedule_haircut_day on #messageHasSentiment("positive");
       this_is_barbershop: goto can_help_then on #messageHasSentiment("negative");
   }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations - you have successfully created your first Dasha AI app - a virtual receptionist. &lt;/p&gt;

&lt;h2&gt;
  
  
  Talking to the AI phone answering software
&lt;/h2&gt;

&lt;p&gt;Now, you’ll want to talk to the the Dasha AI app you have just created. To speak to the AI, type into the terminal &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;npm start phone_number&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Where phone_number is your number starting with country code. For example, for mine it looks like this: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;npm start 19733588889&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you are building and testing, you may want to just chat to the AI, to save time. To do that, type into the terminal: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;npm start chat&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Parting words
&lt;/h3&gt;

&lt;p&gt;As a non-developer, I tried my best to make this tutorial as easy to understand as possible. If you want to get deeper knowledge of building with Dasha ai - check out our documentation docs.dasha.ai or keep an eye peeled for content here on the blog or in our &lt;a href="https://twitter.com/_dashaai"&gt;Twitter&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you found this tutorial helpful - let me know: &lt;a href="mailto:arthur@dasha.ai"&gt;arthur@dasha.ai&lt;/a&gt;. If you didn’t find it helpful - all the more reason to let me know. &lt;/p&gt;

&lt;p&gt;Good luck and godspeed.&lt;/p&gt;

</description>
      <category>ai</category>
    </item>
    <item>
      <title>Teach an AI to call any inbound lead instantly and qualify them</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Fri, 27 Aug 2021 12:52:25 +0000</pubDate>
      <link>https://dev.to/arrrgr/teach-an-ai-to-call-any-inbound-lead-instantly-and-qualify-them-539h</link>
      <guid>https://dev.to/arrrgr/teach-an-ai-to-call-any-inbound-lead-instantly-and-qualify-them-539h</guid>
      <description>&lt;p&gt;Business ops already automate the emails going out to the newly generated leads, why not automate the calls, if you can do it at a level indistinguishable from a human being? Also, it's a fun build. &lt;/p&gt;

&lt;p&gt;Read on for: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to prepare to build your app &lt;/li&gt;
&lt;li&gt;How to build your app &lt;/li&gt;
&lt;li&gt;How to test your app &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Designing your inbound lead qualification conversational AI app
&lt;/h2&gt;

&lt;p&gt;Start off by mapping your conversational app. Here are &lt;a href="https://dasha.ai/en-us/blog/build-conversational-AI-app-1"&gt;detailed instructions&lt;/a&gt; on how to go about it. Here is the file that was the outcome of my conversation mapping for this super simple qualification script. &lt;/p&gt;

&lt;p&gt;The basis of the script is as follows - we’re a company in invoicing software. We get an inbound lead, we call them back, ask if now is a good time to talk, ask 3 qualifying questions, then set a day and time for a call. There are a few digressions (tangents) at play here, to address things such as the prospect asking what the call is about or for a reminder of who called them.  &lt;/p&gt;

&lt;p&gt;Here is a &lt;a href="https://docs.google.com/spreadsheets/d/1pK9IYIRvQeotHUB0_iuSxiTXLUyHYOQ9h0MtV7FBhmo/edit#gid=0"&gt;copy of the file&lt;/a&gt; I ended up with as a result of the mapping exercise (instructions above). Do copy to your Google Drive or download as Excel file to make use of it. &lt;/p&gt;

&lt;p&gt;The cool thing about the conversational map, is you can go back to it to expand upon the basiс structure of the conversation. And make no mistake, the app I built here (and you will too), in just a couple of hours is quite basic. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to qualify inbound leads with conversational AI: build your first app
&lt;/h2&gt;

&lt;p&gt;Is this your first rodeo? Then kick it off by reading Angelika’s getting started building conversational apps with Dasha conversational AI guide &lt;a href="https://dasha.ai/en-us/blog/conversational-ai-app-creation-guide"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Now, kick this off by cloning this (simple app)[&lt;a href="https://github.com/dasha-samples/dasha-first-app"&gt;https://github.com/dasha-samples/dasha-first-app&lt;/a&gt;] from our code sample GitHub repo. You can clone directly from your terminal or download, unzip and open the folder in Visual Studio Code. &lt;/p&gt;

&lt;p&gt;Now, open up main.dsl and intents.json. These are the two main files that we will be working with in the course of this tutorial. &lt;/p&gt;

&lt;p&gt;Let’s get to work by building the key workflow in main.dsl. The ideal workflow is - get confirmation that lead can talk now, ask 3 qualifying questions and book a time to meet. &lt;/p&gt;

&lt;p&gt;Here is the workflow in the conversation map: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/13iVQXsMT0zeEPrbfuXy59/b989e244dba9a617da6bf301bea10b62/Screenshot_at_Jul_05_13-05-09.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/13iVQXsMT0zeEPrbfuXy59/b989e244dba9a617da6bf301bea10b62/Screenshot_at_Jul_05_13-05-09.png" alt="Conversation map: perfect world workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take a look at Variables column. Since in the course of this conversation we are asking questions of the user and then storing their responses, we need to use some variables to store the data. We need to start off by initializing these variables. &lt;/p&gt;

&lt;p&gt;Open up main.dsl in Visual Studio Code. We need to start off by declaring and initializing the variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;context
{
   input phone: string;
   input name: string = "";

   software: {[x:string]:string;}[]?=null;
   invoices: {[x:string]:string;}[]?=null;
   lead_source: {[x:string]:string;}[]?=null;
   calltime: {[x:string]:string;}[]?=null;
   callday: {[x:string]:string;}[]?=null;
   callback: {[x:string]:string;}[]?=null;

   visitedNodeTime: boolean = false;
   visitedNodeQuestion1: boolean = false;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ve got three sets of variables here. &lt;/p&gt;

&lt;p&gt;Set 1 - input variables are what you start the conversation off with. In this case, we presume that there is a phone number of the person who left the website form request and their name. You can input these variables as you launch your test call in the Terminal.&lt;/p&gt;

&lt;p&gt;Set 2 - variables we will use for storing data collected from the user in the course of the conversation. Note that we are initializing them as arrays because that is the type of data which is collected by the named entity recognition function. &lt;/p&gt;

&lt;p&gt;Set 3 - “visited” variables are used to denote a node which has previously been visited by the user. We will use this variable to let the Dasha Platform know to use a different phrase when coming back to the node versus the one we’ve already used. &lt;/p&gt;

&lt;p&gt;Now that we have got the variables, let’s begin the conversation. &lt;/p&gt;

&lt;p&gt;We start the conversation off with &lt;strong&gt;&lt;code&gt;node root&lt;/code&gt;&lt;/strong&gt; - the root node (duh).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
   do
   {
       #preparePhrase("greeting", {name:$name});
       #connectSafe($phone);
       // Wait for 5 seconds or until speech is detected.
       #waitForSpeech(5000);
       #sayText("Hi " + $name + " this is Dasha with Acme Software. I just received a request for a demo from you. Do you have two minutes now?");
       wait*;
   }
   transitions
   {
       question_1: goto question_1 on #messageHasIntent("yes");
       call_back: goto call_back on #messageHasIntent("no");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty self explanatory. Dasha connects to the user’s phone, waits for 5 seconds, then speaks. Or speaks after it hears the user’s greeting. Dasha asks whether the user has a minute now, and either progresses on our perfect world flow or goes off into the call back node. For now, let’s get through the perfect world flow which means we are successfully qualifying inbound leads. &lt;/p&gt;

&lt;p&gt;Node 2 is &lt;strong&gt;&lt;code&gt;node question_1&lt;/code&gt;&lt;/strong&gt;. Right, this is the first question we ask.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node question_1
{
   do
   {
       if ($visitedNodeQuestion1==false) #sayText("Great! I will book you in for a discovery call with an account executive but first, I'll have to ask you a couple of questions . Question 1 - are you using any other software at the moment that solve for invoicing?");
       else #sayText("Going back to the question 1 - are you using any other software at the moment that solve for invoicing?");
       set $visitedNodeQuestion1=true;
       wait *;
   wait*;
   }
   transitions
   {
       question_1_a: goto question_1_a on #messageHasIntent("yes");
       question_2: goto question_2 on #messageHasIntent("no");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that we are making use of the &lt;strong&gt;&lt;code&gt;$visitedNodeQuestion1&lt;/code&gt;&lt;/strong&gt;  variable here. Good reason for that - in the course of the conversation you may have to come back to this node, in which case you will want to say something different, not the same thing that you have said previously, amirite? Otherwise it won’t sound realistically human to your user. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pro tip: there is a better way to solve this with the **phrasemap&lt;/em&gt;&lt;em&gt;, for the purposes of this tutorial I am using &lt;strong&gt;&lt;code&gt;#sayText&lt;/code&gt;&lt;/strong&gt; - a function of &lt;strong&gt;main.dsl&lt;/strong&gt;. I will do a write up on using &lt;strong&gt;phrasemap&lt;/strong&gt; later.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If the user says that they are presently using invoicing software, we are sent to &lt;strong&gt;&lt;code&gt;node question_1_a&lt;/code&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node question_1_a
{
   do
   {
       #sayText("Great and what software are you using?");
       wait *;
   }
   transitions
   {
      question_2: goto question_2 on #messageHasData("software");
   }
   onexit
   {
       question_2: do {
       set $software = #messageGetData("software", { value: true })[0]?.value??"";
      }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you instruct Dasha to ask a question and, upon hearing a response which fits to the instructions provided to it in our &lt;strong&gt;data.json&lt;/strong&gt; file, to go to &lt;strong&gt;&lt;code&gt;node question_2&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;What instructions are these? These are the named entity recognition training data. Let’s take a look.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"v2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;“entities”:&lt;/span&gt;&lt;span class="w"&gt; 
&lt;/span&gt;&lt;span class="nl"&gt;"software"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"open_set"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"values"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Xero"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Xero"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Quickbooks"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Quickbooks"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Quicken"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Quicken"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Stripe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Stripe"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Square"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Square"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"We use (Quicken)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"We mainly use (Stripe)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"Just (Quickbooks)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Square)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Xero)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Stripe)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Quickbooks)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Square)[software]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Xero)[software]"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this code snippet we provide a set of training data to train Dasha’s Named Entity neural networks in recognizing when the user mentions a software that they are using. Please note that the &lt;strong&gt;&lt;code&gt;open_set&lt;/code&gt;&lt;/strong&gt; parameter is set as &lt;strong&gt;&lt;code&gt;true&lt;/code&gt;&lt;/strong&gt; this means that if the user names a software which we did not list as part of the training data, it will still be recognized as &lt;strong&gt;&lt;code&gt;software&lt;/code&gt;&lt;/strong&gt; and written to our variable &lt;strong&gt;&lt;code&gt;$software&lt;/code&gt;&lt;/strong&gt; as per instructions in &lt;strong&gt;&lt;code&gt;node question_1_a&lt;/code&gt;&lt;/strong&gt; in &lt;strong&gt;main.dsl&lt;/strong&gt; above. Dasha conversational AI API provides the AI as a service of the platform. &lt;/p&gt;

&lt;p&gt;To learn more about Named Entity Recognition and Intent recognition, take a look at Ilya’s posts &lt;a href="https://dasha.ai/en-us/blog/named-entity-recognition"&gt;here&lt;/a&gt; and &lt;a href="https://dasha.ai/en-us/blog/intent-classification"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;With these code samples you are equipped to write the nodes for &lt;strong&gt;&lt;code&gt;node question_2&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;node question_3&lt;/code&gt;&lt;/strong&gt;, and even. Note that in &lt;strong&gt;&lt;code&gt;node time&lt;/code&gt;&lt;/strong&gt; you will need to collect two variables -  &lt;strong&gt;&lt;code&gt;callday&lt;/code&gt;&lt;/strong&gt; and  &lt;strong&gt;&lt;code&gt;time&lt;/code&gt;&lt;/strong&gt;. To collect the time, we will use a native function of Dasha called &lt;strong&gt;&lt;code&gt;numberword&lt;/code&gt;&lt;/strong&gt;. Here is what it will look like: &lt;strong&gt;&lt;code&gt;set $calltime = #messageGetData("numberword", { value: true })[0]?.value??"";&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have trouble putting these together, here is the &lt;a href="https://github.com/arrrgr/inbound-lead-qualification"&gt;application source code&lt;/a&gt; to help you along. &lt;/p&gt;

&lt;p&gt;Great. Now that we’ve collected all the data, let’s make sure that we got the call time correctly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node time_confirm
{
   do
   {
       #sayText("Perfect. Let's confirm, you can take a call on " + $callday + " at " +$calltime + " is that right?");
       wait *;
   }
    transitions
   {
       correct: goto success on #messageHasIntent("yes");
       incorrect: goto time on #messageHasIntent("no");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here Dasha will read out the results to the user. If the user confirms, we got to &lt;strong&gt;&lt;code&gt;node success&lt;/code&gt;&lt;/strong&gt;, if the user does not confirm, we go back to &lt;strong&gt;&lt;code&gt;node time&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Success is pretty straightforward (in the context of DashaScript). I’ll still list it here so that you can reuse it to close the conversation in other points (e.g. &lt;strong&gt;&lt;code&gt;node bye&lt;/code&gt;&lt;/strong&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node success
{
   do
   {
       #sayText("Perfect. You will have an invite later today. Thank you so much! We'll speak soon! Bye!");
       exit;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alright. So we got through the perfect world workflow and your conversational AI app is midway done. &lt;/p&gt;

&lt;p&gt;Now, let’s  address the workflow where the user says they can’t talk right now and asks to call them back. We need to instruct Dasha to ask when to call the user back and to collect the user’s response. &lt;/p&gt;

&lt;p&gt;Here is how this code will look like in DSL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node call_back
{
   do
   {
       #sayText("No worries, when may we call you back?");
       wait *;
   }
   transitions
   {
      callback_confirm: goto callback_confirm on #messageHasData("callback");
   }
   onexit
   {
       callback_confirm: do
       {
       set $callback = #messageGetData("callback", { value: true })[0]?.value??"";
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are the training data I put together for the purpose of identifying &lt;strong&gt;&lt;code&gt;callback&lt;/code&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="nl"&gt;"callback"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"open_set"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="nl"&gt;"values"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tomorrow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tomorrow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"next day"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tomorrow at the same time"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"same time tomorrow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tomorrow same time"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"the day after tomorrow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"In two days"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Day after tomorrow"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"in an hour"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"in an hour"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"in two hours"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"later today"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
           &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"later today"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="s2"&gt;"call me back at (tomorrow)[callback]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="s2"&gt;"(tomorrow)[callback]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="s2"&gt;"(the day after tomorrow)[callback]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="s2"&gt;"(tomorrow)[callback] is fine"&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will let you write the confirmation node on your own - you can reuse some of the code we used for &lt;strong&gt;&lt;code&gt;node time_confirm&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;success&lt;/code&gt;&lt;/strong&gt; earlier. &lt;/p&gt;

&lt;h2&gt;
  
  
  Use digressions to add human-like realism to the conversation
&lt;/h2&gt;

&lt;p&gt;Digressions. You should have noticed them in the conversation map: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/63UiZji1MZy8e4Oqx7BFRQ/e07055ae4af5d62943102f45e17642f3/Screenshot_at_Jul_05_13-05-53.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/63UiZji1MZy8e4Oqx7BFRQ/e07055ae4af5d62943102f45e17642f3/Screenshot_at_Jul_05_13-05-53.png" alt="Conversation map: digressions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The purpose of digressions is to account for the unpredictable human behavior. At any point in time a person you are talking to might ask about the weather or a million other things. Digressions are how you prepare your AI app to handle these seemingly random requests. More on digressions you can find in this &lt;a href="https://dasha.ai/en-us/blog/using-digressions"&gt;post&lt;/a&gt;. The cool thing is - you can predict some or maybe even most digressions but not all of them. You get to find out what all the ones you did not predict are in live conversations that your AI app has with real human beings, once you begin training it. More on that later. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Digressions&lt;/strong&gt; are activated by &lt;strong&gt;intents&lt;/strong&gt;. Just like you defined named entities in data.json, you define intents in the same file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"intents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"who_call"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"who is this again?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"who is calling?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"what is this about?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"who are you?"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"what_do"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"what does your company do?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"what company is this again?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"what do you do?"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And so on. &lt;/p&gt;

&lt;p&gt;Here is how the digressions for these intents look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digression who_call
{
   conditions {on #messageHasIntent("who_call");}
   do
   {
       #sayText("This is Dasha with Acme Software. You reached out to us a few minutes ago on our website.");
       return;
   }
}

digression what_do
{
   conditions {on #messageHasIntent("what_do");}
   do
   {
       #sayText("Acme Software provides invoicing software as a service for SMB. ");
       return;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What happens here is simple - the user calls up a digression at any place in the conversation, Dasha responds, and goes back to the node from which the digression was called. Equipped with this code, you can construct the other digressions as well. &lt;/p&gt;

&lt;p&gt;And really that’s it. &lt;/p&gt;

&lt;h2&gt;
  
  
  launching and testing your inbound lead qualification conversational AI app
&lt;/h2&gt;

&lt;p&gt;Once you get through putting together the rest of the app, you will end up with code that is similar to what you’ll find in this &lt;a href="https://github.com/arrrgr/inbound-lead-qualification"&gt;repository&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;To run a test conversation, type into your terminal &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;npm i&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;And then &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;npm start chat Jane&lt;/code&gt;&lt;/strong&gt; where Jane is any name you want to give your user. This will launch a text chat. To launch a voice call, type: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;npm start 12223334455 Jane&lt;/code&gt;&lt;/strong&gt; where 12223334455 is any phone number in the international format without the + symbol. &lt;/p&gt;

&lt;p&gt;Congats. You’ve got the base from which you can build your super fly inbound lead qualification app. In the next installment we’ll talk about connecting this application to external services to initiate calls and to store collected data. &lt;/p&gt;

&lt;p&gt;You can access the full application &lt;a href="https://github.com/arrrgr/inbound-lead-qualification"&gt;source code&lt;/a&gt; to get you started.&lt;/p&gt;

&lt;p&gt;Stay tuned. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Take an hour to build a deeply conversational chatbot for Intercom </title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Fri, 27 Aug 2021 03:59:20 +0000</pubDate>
      <link>https://dev.to/arrrgr/take-an-hour-to-build-a-deeply-conversational-chatbot-for-intercom-41l</link>
      <guid>https://dev.to/arrrgr/take-an-hour-to-build-a-deeply-conversational-chatbot-for-intercom-41l</guid>
      <description>&lt;p&gt;Co-authored by Aleksandr Aleksashin&lt;/p&gt;

&lt;p&gt;Intercom lets businesses communicate with customers or prospective customers in-app or on-website. Intercom is used to initiate support conversations, as well as sales conversations. On the business side, Intercom is generally manned by an employee, although it lets users (businesses) create simple bots.&lt;/p&gt;

&lt;p&gt;It’s a great technology. I think it can be made greater yet if one could automate the customer conversations that happen through it at a human level. &lt;/p&gt;

&lt;h2&gt;
  
  
  How Intercom does bots today
&lt;/h2&gt;

&lt;p&gt;Intercom offers chatbot building functionality out of the box with a drag-and-drop, no code interface. These are rather simplistic command-response/multiple choice chat bots.&lt;/p&gt;

&lt;p&gt;Here is what a conversation with an Intercom bot might look like today: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/4KSZiIfkX2aU6HHaOx440P/e5ecb09885c9f2c862981908cce68f00/Screenshot_at_Jul_22_13-48-04.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/4KSZiIfkX2aU6HHaOx440P/e5ecb09885c9f2c862981908cce68f00/Screenshot_at_Jul_22_13-48-04.png" alt="Intercom chat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might ask “what’s wrong with multiple choices”. They are great for taking the cream off the top. However, if a user’s request does not fit within the bounds of the commands served up by the bot, the user will quickly become frustrated and seek to speak with a human agent. The problem with human agents is that they are often unavailable or take a while to respond. &lt;/p&gt;

&lt;p&gt;Importantly, according to Intercom’s &lt;a href="https://www.intercom.com/blog/the-state-of-chatbots/"&gt;own research&lt;/a&gt; only 15% of customers would prefer talking to a bot over a human agent. &lt;/p&gt;

&lt;p&gt;So we got to thinking. What if we can deploy a conversational AI app that can communicate through Intercom and provide a truly human-like experience to the customer? How would customers feel about a thing like that? How would it impact their perception of the brand? &lt;/p&gt;

&lt;p&gt;Also, we just think it’s a cool little project. Here is the &lt;a href="https://github.com/dasha-samples/intercom-dasha-integration"&gt;repository&lt;/a&gt; with the source code for your reference. &lt;/p&gt;

&lt;h2&gt;
  
  
  Dasha AI
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dasha.ai"&gt;Dasha&lt;/a&gt; conversational AI platform is a suite of developer tools. Using Dasha Studio, SDK and Cloud Platform, any developer can design, build, train and deploy fully human-like, deeply conversational AI applications. DashaScript is a derivative of TypeScript, the SDK is Node.js. No ML or AI experience is required.  It’s a perfect platform to create a human-like chatbot for Intercom. &lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges to overcome
&lt;/h2&gt;

&lt;p&gt;Here is what we need to make happen for this thing to start talking to customers: &lt;/p&gt;

&lt;p&gt;Integrate a Dasha AI app with Intercom &lt;br&gt;
Design and develop the Dasha conversational AI app &lt;br&gt;
Deploy and test the app&lt;/p&gt;

&lt;p&gt;In our journey we will create a simple conversational bot for customer support via Dasha platform. In terms of the conversational app functionality - we will keep it exceedingly simple for the purposes of this tutorial, yet will illustrate all the features of Dasha platform that you can use to create fully human-like conversational applications. &lt;/p&gt;

&lt;p&gt;Before we go any further, let’s make sure that you are equipped with the tools to use Dasha conversational AI. Firstly, you’ll want to head over to our &lt;a href="https://community.dasha.ai"&gt;developer community&lt;/a&gt;, where you will get instructions on how to get your API key. Secondly, download and install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=dasha-ai.dashastudio-beta"&gt;Dasha Studio extension&lt;/a&gt; for Visual Studio Code. Thirdly, you’ll want to install the Dasha CLI&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;npm i -g "@dasha.ai/cli"&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
. For more on our command line interface, read this &lt;a href="https://dasha.ai/en-us/blog/dasha-cli"&gt;post&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;And finally, you want to clone and open a copy of &lt;a href="https://github.com/dasha-samples/intercom-dasha-integration"&gt;the source code&lt;/a&gt; for the app we are building togay, so that you can follow along the instructions in the tutorial. &lt;/p&gt;
&lt;h2&gt;
  
  
  Integration
&lt;/h2&gt;

&lt;p&gt;Our Dasha AI app has to be able to do the following things through Intercom: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Be notified of newly-initiated conversations that have yet to be responded to by a human agent &lt;/li&gt;
&lt;li&gt;Read the content of the customer’s communication.&lt;/li&gt;
&lt;li&gt;Notify the customer that their message(s) have been read.&lt;/li&gt;
&lt;li&gt;Decipher the customer’s intent and select an appropriate response. &lt;/li&gt;
&lt;li&gt;Respond to the customer in the conversation. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To integrate, we will look at intercom API and search for a library that can perform the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search conversation by parameters;&lt;/li&gt;
&lt;li&gt;Reply to a specific conversation;&lt;/li&gt;
&lt;li&gt;Create/open/close/reopen conversations;&lt;/li&gt;
&lt;li&gt;Read messages from any given conversation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since clients for Dasha SDK are currently written only in JavaScript (TypeScript), we need a JavaScript library for Intercom. Intercom has a Node.js SDK in their API references (&lt;a href="https://github.com/intercom/intercom-node"&gt;https://github.com/intercom/intercom-node&lt;/a&gt;). Unfortunately, this library cannot create new conversations.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step one. Getting the access token for Intercom
&lt;/h3&gt;

&lt;p&gt;First off we need to get acquainted with the &lt;a href="https://developers.intercom.com/intercom-api-reference"&gt;Intercom API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As we can see, all requests must have an access token. To get your access token, go &lt;a href="https://app.intercom.com/"&gt;here&lt;/a&gt; and to settings-&amp;gt;developers-&amp;gt;developer-hub and click “New app” to create a new application.&lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/59cWy3MsdX2FCZvM9qqRhH/acbef4a660af368cb429738e0af8e5f7/Screenshot_at_Jul_22_14-32-08.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/59cWy3MsdX2FCZvM9qqRhH/acbef4a660af368cb429738e0af8e5f7/Screenshot_at_Jul_22_14-32-08.png" alt="Intercom developer portal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you create your application, head over to App &amp;gt; Configure &amp;gt; Authentication to find your access token. &lt;/p&gt;

&lt;p&gt;Equipped with the access token, we can start sending requests to the Intercom rest API. For our HTTP client we will use Axios. &lt;/p&gt;
&lt;h3&gt;
  
  
  Step two. Apply integration to your code
&lt;/h3&gt;

&lt;p&gt;We are using TypeScript to write our app. Open up main.ts. First, we need to import the intercom integration library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;IntercomClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/intercomClient&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we need to create an instance of a Dasha application and an instance of an intercom client. On the creation of the Intercom client instance we should pass the access token and url for Intercom as arguments of the function.&lt;/p&gt;

&lt;p&gt;We are creating both within the function &lt;strong&gt;&lt;code&gt;main&lt;/code&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;application&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./graph&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;groupName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Default&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;intercom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;IntercomClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.intercom.io&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="na"&gt;accessToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTERCOM_APIKEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we instruct the Dasha application how and where to execute the conversation and to let us know all is going well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connectionProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
     &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createConsoleChat&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
   &lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setExternal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;send_report_on_manager&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;set_args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;conversation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ok&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to connect the Intercom client with the Dasha SDK application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;intercom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;simpleConnectToDashaApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And set a logger to log the actions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt; &lt;span class="nx"&gt;intercom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Details of Intercom integration library
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Function for connecting Dasha application to Intercom
&lt;/h3&gt;

&lt;p&gt;We use the “simpleConnectToDashaApp” function in our code. Let’s take a look at its implementation. Go to .src/intercomClient.ts, line 412.&lt;/p&gt;

&lt;p&gt;Look at the signature of this method. This method has one argument - an instance of   platform application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;simpleConnectToDashaApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
     &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the first part of the function below we prepare to interact with the integration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isSimpleUsed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isSimpleUsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;closeTrigger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;conversations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;IntercomConversation&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next part of the function, we set up a callback to become active on certain events in the application.&lt;br&gt;
On the "starting" event, it is necessary to check that the incoming conversation has not been started yet. After this you need to execute the function for connecting intercom and application chats, and accept this job. Let’s check out the implementation of this callback:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;     &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dashaChat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createChat&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
     &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;runChatInConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="na"&gt;closeAfter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="na"&gt;messageOnClose&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
             &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Conversation was closed because dialog was finished&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="p"&gt;},&lt;/span&gt;
         &lt;span class="na"&gt;periodReading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="na"&gt;startOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="na"&gt;skipLastMessage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
             &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
           &lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="p"&gt;},&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Third step is to connect the intercom client to Dasha application chat.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;     &lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dashaChat&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dashaChat&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;};&lt;/span&gt;

   &lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ready&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Got new starting conversation ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;').`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

     &lt;span class="c1"&gt;// Checking that the conversation belongs to this intercom client instance&lt;/span&gt;
     &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
         &lt;span class="s2"&gt;`Try starting conversation from not this instance of intercom client new conversation ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;'). `&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
           &lt;span class="s2"&gt;`Conversation was been rejected`&lt;/span&gt;
       &lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Prepare intercom conversation for chat ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;').`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="s2"&gt;`Connecting to dasha sdk chat protocol for conversation ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;').`&lt;/span&gt;
     &lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="na"&gt;continueConversation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fourth step is to reply to Dasha SDK that the conversation can be started.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;     &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;transcription&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transcription&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onTransctiption&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onTransctiption&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;transcription&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;});&lt;/span&gt;
     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Conversation was been accepted ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;').`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The events "failed", "completed", "timeOut" have the same implementation up to the call of the corresponding functions. Look at the implementation for conversation &lt;strong&gt;&lt;code&gt;result&lt;/code&gt;&lt;/strong&gt; event:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;       &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
       &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Conversation finish ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;').`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onCompletedJob&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onCompletedJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly you will see functionality for rejected, timed out and failed conversations. At line 523 we begin a loop where we search for new conversations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;watchConversations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="c1"&gt;// Checking that a conversation is already in progress&lt;/span&gt;
         &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
         &lt;span class="p"&gt;}&lt;/span&gt;

         &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Got new conversation ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;')`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
         &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;notBefore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;notAfter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
           &lt;span class="s2"&gt;`Conversation ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;') was enqueued into dasha sdk`&lt;/span&gt;
         &lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
           &lt;span class="s2"&gt;`Could not enqueue conversation ('&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;') into dasha sdk`&lt;/span&gt;
         &lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;},&lt;/span&gt;
     &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;closeTrigger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isSimpleUsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See how we change the state of the instance to start a new simple conversation with &lt;code&gt;this.isSimpleUsed = false;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The function that lets us search ouyt a new conversation
&lt;/h3&gt;

&lt;p&gt;We use the “watchConversations” function in our code. Let’s see their implementation. Write simple checking conversations to have a new one or a not replied one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;watchConversations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="c1"&gt;// We need callback to start work with conversation&lt;/span&gt;
   &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IntercomConversation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="c1"&gt;// Hook, for end watching conversations&lt;/span&gt;
   &lt;span class="nx"&gt;stopTrigger&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;
 &lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// Search over all conversation and find only those which have not replied message&lt;/span&gt;
   &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;stopTrigger&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c1"&gt;// take first 20 conversation from first page in listing method&lt;/span&gt;
     &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;conversation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="c1"&gt;// skip all conversation which was been replied by admin&lt;/span&gt;
     &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;conversation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
         &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statistics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_contact_reply_at&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statistics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_admin_reply_at&lt;/span&gt;
     &lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// send new potential conversation for working&lt;/span&gt;
       &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="c1"&gt;// now we go over all other conversation and do same action like above&lt;/span&gt;
     &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conversation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;total_pages&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;conversation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nx"&gt;conversation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
         &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="nx"&gt;conversation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
       &lt;span class="p"&gt;);&lt;/span&gt;

       &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;conversation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
         &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
           &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statistics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_contact_reply_at&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
           &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statistics&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_admin_reply_at&lt;/span&gt;
       &lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="c1"&gt;// timeout in order not to spam requests&lt;/span&gt;
     &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can work with applications and conversations, but we cannot start conversations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Function for start chatting
&lt;/h3&gt;

&lt;p&gt;These methods prepare Intercom for conversation and to start a chat. This function has two logical parts. In part one, we prepare the client for the conversation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;runChatInConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="c1"&gt;// is the conversation open at the moment&lt;/span&gt;
   &lt;span class="nx"&gt;conversationWasOpen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c1"&gt;// if define than conversation after and need close&lt;/span&gt;
     &lt;span class="c1"&gt;// else conversation does not closing&lt;/span&gt;
     &lt;span class="nl"&gt;closeAfter&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;messageOnClose&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;};&lt;/span&gt;
     &lt;span class="c1"&gt;// if nod defined than used first available user message in conversation&lt;/span&gt;
     &lt;span class="c1"&gt;// else use last available user message in conversation&lt;/span&gt;
     &lt;span class="nl"&gt;startOptions&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// ignore last message, and awaiting new message&lt;/span&gt;
       &lt;span class="na"&gt;skipLastMessage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="p"&gt;};&lt;/span&gt;
     &lt;span class="c1"&gt;// period of receiving new messages from the api intercom&lt;/span&gt;
     &lt;span class="nl"&gt;periodReading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IIntercomChat&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// Create client for each conversation&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;intercomConversationClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;IntercomConversationClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startOptions&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;
       &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getLastTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
           &lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;skipLastMessage&lt;/span&gt;
         &lt;span class="p"&gt;),&lt;/span&gt;
     &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;periodReading&lt;/span&gt;
   &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In next part we use a hook to start the conversation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="c1"&gt;// hook which was triggered when conversation was started on the dasha platform.&lt;/span&gt;
     &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Chat&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="c1"&gt;// open conversation if it`s needed&lt;/span&gt;
         &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;conversationWasOpen&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;openConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="p"&gt;}&lt;/span&gt;

         &lt;span class="c1"&gt;// run conversation chat&lt;/span&gt;
         &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;intercomConversationClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="c1"&gt;// close conversation if it`s need&lt;/span&gt;
         &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;closeAfter&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
             &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;closeConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
               &lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;closeAfter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messageOnClose&lt;/span&gt;
             &lt;span class="p"&gt;);&lt;/span&gt;
           &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
             &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_logger&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
           &lt;span class="p"&gt;}&lt;/span&gt;
         &lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="p"&gt;};&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Implementing a class to chat within a single conversation.
&lt;/h3&gt;

&lt;p&gt;This is the magic class which lets the Dasha conversational AI chat with Intercom. Go to &lt;strong&gt;intercomConversationClient.ts&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Let’s take a look at the construction of this class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;IntercomConversationClient&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;IIntercomChat&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="c1"&gt;// Id of conversation on Intercom.&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="c1"&gt;// Used Intercom client.&lt;/span&gt;
 &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IIntercomClient&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="c1"&gt;// Delay for reading new messages from Intercom conversation.&lt;/span&gt;
 &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;delayReading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="c1"&gt;// This property indicate that this client in a close state.&lt;/span&gt;
 &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;close&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="c1"&gt;//Creation time of the last message we read from Intercom conversation.&lt;/span&gt;
 &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;lastTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IIntercomClient&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;lastTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;delayReading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;lastTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;delayReading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;delayReading&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This class should have two functions. The first of them needs to run and control the conversation flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Chat&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;// listen message from dasha sdk application and write into intercom&lt;/span&gt;
   &lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;close&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,()&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;close&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;close&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chat error:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="c1"&gt;// listen message from intercom and write into dasha sdk chat channel&lt;/span&gt;
   &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next function reads messages from the conversation and sends them to the Dasha application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt; &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;readConversation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Chat&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;close&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;delayReading&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
     &lt;span class="c1"&gt;// read new messages in intercom conversation&lt;/span&gt;
     &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readMessages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastTime&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

     &lt;span class="c1"&gt;// mark conversation as read. This see user in intercom&lt;/span&gt;
     &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;markAsRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;conversationId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

     &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lastTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
     &lt;span class="c1"&gt;// send new message from intercom into dasha sdk application&lt;/span&gt;
     &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;chatChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sendText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quite simple. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Dasha conversational AI app
&lt;/h2&gt;

&lt;p&gt;On to the fun part. Let’s look at the conversational AI app that will interact with our Intercom customer/user. &lt;/p&gt;

&lt;p&gt;You will need to open the following files: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;.graph/main.dsl&lt;/strong&gt; is the DashaScript file which you use to construct the conversational pathway that Dasha is to take. Here you can make your conversation as absolutely complex or simple as you wish. For the purposes of this tutorial we will opt for simple.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;data.json&lt;/strong&gt; is the file where you store data that is used to train the neural networks to properly understand the customer’s/user’s intent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;phrasemap.json&lt;/strong&gt;  is where you store all the phrases to be used by Dasha AI in the context of the conversation. (tip: you can list phrases directly in &lt;strong&gt;main.dsl&lt;/strong&gt; by using the &lt;strong&gt;&lt;code&gt;#sayText()&lt;/code&gt;&lt;/strong&gt; function. Using the phrase map for it is, however, the better way for scalable apps.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will be discussing the following concepts in this part of the tutorial: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node&lt;/strong&gt; is literally just that - a node in the conversation. It’s a point of interaction between the user and the AI. A node must always have another node or digression leading into it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Digression&lt;/strong&gt; is, in essence, a node that does not have to have anything lead into it. A digression can be called up by the user at any point in the conversation. Digressions are used to imitate the way a human might adapt when the person they are talking to suddenly throws them off on a tangent. Read this for a &lt;a href=""&gt;deeper dive&lt;/a&gt; on &lt;strong&gt;digressions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intent&lt;/strong&gt; refers to the meaning behind the user/customer’s phrases. When you are speaking to someone you figure out the meaning of their words and phrases and sentences based on context, a variety of clues and previous experience. Right now Dasha AI interprets meaning solely from text (we are working on emotional analysis). Intents refer to the . The Dasha Cloud Platform has neural networks dedicated to training for user intents and to analysing said intents in the course of a conversation. &lt;a href=""&gt;Take a look here&lt;/a&gt; for more on &lt;strong&gt;intents&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Named entities&lt;/strong&gt; are fields referring to names, place names, objects, etc. that you need Dasha AI to identify within the customer/user’s responses. &lt;strong&gt;Named entities&lt;/strong&gt; are also processed by neural networks and you provide training data using &lt;strong&gt;data.json&lt;/strong&gt; in a format similar to &lt;strong&gt;intent&lt;/strong&gt; training data. For more on &lt;strong&gt;named entities&lt;/strong&gt; you can read &lt;a href=""&gt;this piece&lt;/a&gt; from the leader of the team which constructed the neural networks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s look at &lt;strong&gt;main.dsl&lt;/strong&gt;. We start by importing common functions. In the case of Dasha this means common digressions and ways of responding to them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "commonReactions/all.dsl";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to declare some variables for context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;context
{
   input conversationId: string;
   input continueConversation: boolean;
   last_message: string = "";
   can_say: boolean = false;
   output status: string?;
   output serviceStatus: string?;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to declare an external function. This is a way for a DashaScript app to call out to an external application to send or receive data. In this case the app is &lt;strong&gt;main.ts&lt;/strong&gt; and we are sending the customer’s phrase data which refers to a manager who led to a dissatisfied customer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;external function send_report_on_manager(report: string): unknown;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s look at the first node - &lt;strong&gt;&lt;code&gt;node root&lt;/code&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
   do
   {
       #connectSafe("");
       if(!$continueConversation)
       {
           #say("greeting", repeatMode: "ignore");
           #say("how_can_i_help_you");
       }
       goto hub;
   }
   transitions
   {
       hub: goto hub;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we connect to the chat instance if check if our conversation should be continued, as per the code we wrote previously in the integration. If we continue the conversation, we greet the customer and ask how they can be helped. &lt;/p&gt;

&lt;p&gt;It is expected that in most cases the customer will state the problem with which they are calling. &lt;/p&gt;

&lt;p&gt;Here is where &lt;strong&gt;digressions&lt;/strong&gt; come in. Let’s say the customer says “I have a problem with my phone.” If you look at the &lt;strong&gt;intents.json&lt;/strong&gt;, you will find a &lt;strong&gt;&lt;code&gt;"problem_with_phone"&lt;/code&gt;&lt;/strong&gt; intent on line 98:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"problem_with_phone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="s2"&gt;"I can't seem to make a phone call"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="s2"&gt;"I have a problem with my phone"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="s2"&gt;"I'm afraid I broke my phone"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="s2"&gt;"Phone problem"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you scroll down to line 144 in &lt;strong&gt;main.dsl&lt;/strong&gt;, you will see this digression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digression problem_dig
{
   conditions
   {
       on #messageHasAnyIntent(["problem_with_phone", "problem_with_manager", "have_problem"]);
   }
   do
   {
       digression disable problem_dig;
       goto problem;
   }
   transitions
   {
       problem: goto problem;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The digression comes into play when any of the intents &lt;strong&gt;&lt;code&gt;"problem_with_phone", "problem_with_manager", "have_problem"&lt;/code&gt;&lt;/strong&gt; are identified. If they are identified, the conversation goes to &lt;strong&gt;&lt;code&gt;node problem&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;There are a variety of exciting funcitons of DashaScript that you should learn about if you want to develop further on it. The best place to go is our &lt;a href="https://docs.dasha.ai"&gt;documentation&lt;/a&gt;. You can also make your way through a detailed tutorial, such as &lt;a href="https://dasha.ai/en-us/blog/customer-feedback-survey"&gt;this one&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Launching and testing the Intercom conversation
&lt;/h2&gt;

&lt;p&gt;Now that you’ve got the integration built out and the app is developed as well, let’s launch a test convo. &lt;/p&gt;

&lt;p&gt;To do this, type &lt;strong&gt;&lt;code&gt;npm i&lt;/code&gt;&lt;/strong&gt; in the terminal and then &lt;strong&gt;’npm run build`&lt;/strong&gt; and  &lt;strong&gt;’npm run start`&lt;/strong&gt;. The app should now be deployed. &lt;/p&gt;

&lt;p&gt;Now, you need to launch a test conversation with Dasha. It’s a two step process. Step 1 - head over to the Intercom &lt;a href="https://developers.intercom.com"&gt;Developer Hub&lt;/a&gt; &amp;gt; Your apps. Select your app and click on it. Your address bar will read something of this sort: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/102j4gpbksQriKKPYl8285/109d538ba68e8867303f2de72c3a3ef8/Screenshot_at_Jul_26_17-31-28.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/102j4gpbksQriKKPYl8285/109d538ba68e8867303f2de72c3a3ef8/Screenshot_at_Jul_26_17-31-28.png" alt="Address bar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You want to copy the number after &lt;strong&gt;/apps&lt;/strong&gt; - this is your Intercom application ID. &lt;/p&gt;

&lt;p&gt;Now, copy and paste this line into your address bar &lt;a href="https://app.intercom.com/a/apps/yourAppIDgoesHere/test-conversation"&gt;https://app.intercom.com/a/apps/yourAppIDgoesHere/test-conversation&lt;/a&gt; and replace &lt;em&gt;yourAppIDgoesHere&lt;/em&gt; with your application ID. I know, it’s complicated and, yes this is the solution recommended by Intercom.&lt;/p&gt;

&lt;p&gt;Now, you will be able to send a message from the chat interface and get a reply from Dasha. In this way you can test any conversation that your users can have with Dasha.&lt;/p&gt;

&lt;p&gt;Let me know if this was helpful in the comments or in our &lt;a href="http://community.dasha.ai"&gt;developer community&lt;/a&gt; .&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to run automated telephone conversations through a telephony vendor</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Thu, 26 Aug 2021 11:47:01 +0000</pubDate>
      <link>https://dev.to/arrrgr/how-to-run-automated-telephone-conversations-through-a-telephony-vendor-go7</link>
      <guid>https://dev.to/arrrgr/how-to-run-automated-telephone-conversations-through-a-telephony-vendor-go7</guid>
      <description>&lt;h2&gt;
  
  
  Why use your own telephony for your Dasha apps
&lt;/h2&gt;

&lt;p&gt;The goal of any development is to deliver some type of business value. In the case of Dasha conversational AI apps, the business value that our customers pursue varies. Yet in over 95% of cases today, it is delivered through the telephone channel. In that sense, most of our customers in production use Dasha to automate some part of their telephone communications with customers. &lt;/p&gt;

&lt;p&gt;Most of these companies have a telephony vendor. Connecting the Dasha application to their existing telephony means that Dasha can seamlessly transfer calls to a live agent, if such a need arises. It also means that Dasha can make phone calls from phone numbers reserved for this company, and answer inbound phone calls which are directed to the company phone number. &lt;/p&gt;

&lt;p&gt;In this tutorial we will go over connecting Dasha for both inbound and outbound telephone communication using &lt;a href="https://voximplant.com"&gt;Voximplant&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to use Dasha with a third party telephony vendor?
&lt;/h2&gt;

&lt;p&gt;First, you need to know if your vendor supports SIP Trunk connections. Here is a simple decision tree flowchart to help you navigate: &lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/42LZsmJaoIqCNtN7P0emln/4ef3e05786fdb56042d71cf68657e948/Yes__2_.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/42LZsmJaoIqCNtN7P0emln/4ef3e05786fdb56042d71cf68657e948/Yes__2_.png" alt="Decision making flowchart"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To give you an idea of how the integration happens, read below for instructions to integrate Dasha with the telephony vendor Voximplant via a SIP Trunk connection. &lt;/p&gt;

&lt;h3&gt;
  
  
  Preparatory actions on the Dasha side
&lt;/h3&gt;

&lt;p&gt;Make sure you have node.js version 13+ and npm installed. You will also want the latest version of Visual Studio Code running to edit and test the Dasha app.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Join &lt;a href="https://community.dasha.ai"&gt;Dasha Community&lt;/a&gt; - you will get your API key here automatically&lt;/li&gt;
&lt;li&gt;Open VSCode and install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=dasha-ai.dashastudio&amp;amp;ssr=false"&gt;Dasha Studio Extension&lt;/a&gt; from the extension store.  You’ll get all the DSL syntax highlighting and a GUI interface for debugging your conversation flow.&lt;/li&gt;
&lt;li&gt;Run &lt;strong&gt;&lt;code&gt;npm i -g "@dasha.ai/cli@latest"&lt;/code&gt;&lt;/strong&gt; to install the latest Dasha CLI.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You’ll want to load up a Dasha conversational AI app. For the purposes of this tutorial, you may want to load up either the &lt;a href="https://github.com/dasha-samples/inbound-voximplant-telephony-test"&gt;inbound tester app&lt;/a&gt; for inbound calls.  Or the &lt;a href="https://github.com/arrrgr/outbound-voximplant-telephony-test"&gt;outbound tester app&lt;/a&gt; for outbound calls. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting things up on the side of Voximplant (telephony vendor)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://manage.voximplant.com/auth"&gt;Login to your Voximplant account&lt;/a&gt; or &lt;a href="https://manage.voximplant.com/auth/sign_up"&gt;create an account&lt;/a&gt; if you don’t have one.&lt;/li&gt;
&lt;li&gt;Create a Voximplant &lt;a href="https://manage.voximplant.com/applications"&gt;application&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Purchase a Voximplant phone number in the &lt;a href="https://manage.voximplant.com/numbers/my_numbers"&gt;Numbers&lt;/a&gt; section of the control panel and attach it to the app. This number will be used as callerid. &lt;/li&gt;
&lt;li&gt;Go to your &lt;a href="https://manage.voximplant.com/applications"&gt;applications&lt;/a&gt;, click on the app you had created. Click on Numbers &amp;gt; Available and "attach". This number will be used as &lt;strong&gt;callerid&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/5VsgkVKdqS3K32OFvzT3Nb/057bf2a7de7b97ce80ec27d11e13e03f/Screenshot_at_Jul_27_21-26-49.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/5VsgkVKdqS3K32OFvzT3Nb/057bf2a7de7b97ce80ec27d11e13e03f/Screenshot_at_Jul_27_21-26-49.png" alt="Voximplant dashboard "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  For Outbound calls:
&lt;/h3&gt;

&lt;p&gt;Go to Scenarios &amp;gt; Create Scenario, name the Scenario and hit the “plus” sign. You will need to paste the code below in the scenario.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;callerid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;number_you_bought&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="nx"&gt;VoxEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AppEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CallAlerting&lt;/span&gt;&lt;span class="p"&gt;,(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a call from &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callerid&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// an inbound SIP call from Dasha (the first call leg)&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;inc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// an outbound call to PSTN (the second call leg)&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;VoxEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callPSTN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callerid&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CallEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Connected&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// answering the call&lt;/span&gt;
            &lt;span class="nx"&gt;inc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="c1"&gt;// adding default event listeners to pass signaling information between two calls&lt;/span&gt;
        &lt;span class="nx"&gt;VoxEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;easyProcess&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;inc&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This scenario be run from the Dasha integration. On an incoming SIP call from Dasha, the phone number which we want to call is passed to the callPSTN method. This is how we connect two calls. Once the call is answered, Dasha will start the conversation. If you want to handle inbound calls to SIP, use your SIP URI as &lt;strong&gt;&lt;code&gt;callerid&lt;/code&gt;&lt;/strong&gt; and replace the &lt;a href="https://voximplant.com/docs/references/voxengine/voxengine/callpstn"&gt;callPSTN&lt;/a&gt; method with &lt;a href="https://voximplant.com/docs/references/voxengine/voxengine/callsip"&gt;callSIP&lt;/a&gt;. If you are using SIP Registrations on your PBX, you need to create a SIP Registration and use it instead of the SIP URI.&lt;/p&gt;

&lt;p&gt;Next,go to the &lt;strong&gt;Users&lt;/strong&gt; section and create a new user. Remember the username and password, they will be used for Dasha's config in the next step.&lt;/p&gt;

&lt;p&gt;Now, click on &lt;strong&gt;Routing&lt;/strong&gt; in the left hand menu. Create a new rule (leave the pattern as default), and attach your scenario to this rule.&lt;/p&gt;

&lt;p&gt;&lt;a href="//images.contentful.com/pzhspng2mvip/3J0JTIMb8Zx0V0qtVtg6UX/3a2e3ba2b2193a1a06b282e30858b849/Screenshot_at_Jul_27_21-45-38.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.contentful.com/pzhspng2mvip/3J0JTIMb8Zx0V0qtVtg6UX/3a2e3ba2b2193a1a06b282e30858b849/Screenshot_at_Jul_27_21-45-38.png" alt="Create new rule in Voximplant dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, Connect your sip trunk with Dasha's using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dasha sip create-outbound &lt;span class="nt"&gt;--server&lt;/span&gt; &amp;lt;ip_or_dns_of_server:port&amp;gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--domain&lt;/span&gt; &amp;lt;domain_name&amp;gt;] &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--ask-password&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="nt"&gt;--account&lt;/span&gt; &amp;lt;accountName&amp;gt; &lt;span class="nt"&gt;--transport&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;tcp|udp] &amp;lt;config_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;accountName&lt;/code&gt; is the username you created in the Voximplant panel;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ip_or_dns_of_server:port&lt;/code&gt; is the name of our Voximplant app;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;config_name&lt;/code&gt; is the name of the config we’ll use in the next step.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dasha sip create-outbound &lt;span class="nt"&gt;--server&lt;/span&gt; exampleApp.exampleAcc.n4.voximplant.com &lt;span class="nt"&gt;--account&lt;/span&gt; exampleUsername &lt;span class="nt"&gt;--ask-password&lt;/span&gt; vox_outbound
password: enter_your_password_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  For Inbound calls:
&lt;/h3&gt;

&lt;p&gt;Connect your sip trunk with Dasha's using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dasha sip create-inbound &lt;span class="nt"&gt;--application-name&lt;/span&gt; &amp;lt;your_app_name&amp;gt; &amp;lt;config_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;your_app_name&lt;/code&gt; is your Voximplant application name;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;config_name&lt;/code&gt; is the name of the config we’ll use later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dasha sip create-inbound &lt;span class="nt"&gt;--application-name&lt;/span&gt; exampleApp vox_inbound
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will give us a Dasha’s SIP URI to call. For example: sip:&lt;a href="mailto:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@sip.us.dasha.ai"&gt;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@sip.us.dasha.ai&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see the URI, write: &lt;code&gt;dasha sip list-inbound&lt;/code&gt;.&lt;br&gt;
Let’s put it in our Voximplant scenario instead of "your_SIP_URI".&lt;/p&gt;

&lt;p&gt;Create a scenario inside the app by pressing a plus icon and paste this code in there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// SIP URI that we get in the next step&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sipURI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;your_SIP_URI&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;VoxEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AppEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CallAlerting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;call&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CallEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Connected&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;callToDasha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;VoxEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;callSIP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sipURI&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;VoxEngine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;easyProcess&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callToDasha&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the scenario that will be run when we set everything up. We use the &lt;a href="https://voximplant.com/docs/references/voxengine/voxengine/callsip"&gt;callSIP&lt;/a&gt; method to make a call to our SIP URI. On an incoming SIP call from Voximplant, the SIP URI that we want to call is passed to the callSIP method. This is how we connect two call legs. Once the call is answered, Dasha will start a conversation.&lt;/p&gt;

&lt;p&gt;If you are using SIP Registrations on your PBX, you need to create a &lt;a href="https://voximplant.com/docs/howtos/integration/sip/registration"&gt;SIP Registration&lt;/a&gt; and use it instead of the SIP URI.&lt;/p&gt;

&lt;p&gt;Click on &lt;strong&gt;Routing&lt;/strong&gt; in the left hand menu. Create a new rule (leave the pattern as default), and attach your scenario to this rule.&lt;/p&gt;

&lt;p&gt;&lt;a href="//images.ctfassets.net/pzhspng2mvip/3J0JTIMb8Zx0V0qtVtg6UX/3a2e3ba2b2193a1a06b282e30858b849/Screenshot_at_Jul_27_21-45-38.png" class="article-body-image-wrapper"&gt;&lt;img src="//images.ctfassets.net/pzhspng2mvip/3J0JTIMb8Zx0V0qtVtg6UX/3a2e3ba2b2193a1a06b282e30858b849/Screenshot_at_Jul_27_21-45-38.png" alt="Create new rule in Voximplant dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Get your backend in order and start calling
&lt;/h2&gt;

&lt;p&gt;The setup is ready, now we need a local app or backend to run our Voximplant scenario using Dasha.&lt;/p&gt;

&lt;h3&gt;
  
  
  Placing outbound calls:
&lt;/h3&gt;

&lt;p&gt;Open your VS Code Dasha conversational AI app project. Open up &lt;strong&gt;index.js&lt;/strong&gt; file and replace &lt;strong&gt;configName&lt;/strong&gt; in &lt;strong&gt;&lt;code&gt;dasha.sip.Endpoint&lt;/code&gt;&lt;/strong&gt; with your config name. Do the same with the &lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt; field in package.json. To see all the available configs for sip outbound, run the &lt;strong&gt;&lt;code&gt;dasha sip list-outbound&lt;/code&gt;&lt;/strong&gt; command.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;*.dashaapp&lt;/strong&gt; file, change the &lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt; field so it matches our config name.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;outbound calls&lt;/strong&gt;, run: &lt;strong&gt;&lt;code&gt;node index.js &amp;lt;the number to call in international format e.g. 12223334455&amp;gt;&lt;/code&gt;&lt;/strong&gt;. Now you can watch the application deployment and registration process in the console.&lt;/p&gt;

&lt;h3&gt;
  
  
  Taking inbound calls:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open up your VS Code with the Dasha project open.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;package.json&lt;/strong&gt; file, replace the &lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt; field with your config name. To see all the available configs for sip inbound, run the &lt;strong&gt;&lt;code&gt;dasha sip list-inbound&lt;/code&gt;&lt;/strong&gt; command.
In the inbound.dashaapp file, change the &lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt; field so that it matches your config name.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To test the integration, run npm i from your folder.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;inbound calls&lt;/strong&gt;, run: &lt;strong&gt;&lt;code&gt;node main.js&lt;/code&gt;&lt;/strong&gt;. Now you can call to the phone number which you purchased in Voximplant’s dashboard. &lt;/p&gt;

&lt;p&gt;You’ll be able to track application deployment in the console. &lt;/p&gt;

&lt;h2&gt;
  
  
  In conclusion
&lt;/h2&gt;

&lt;p&gt;Congrats, you’ve successfully connected your Dasha conversational AI app to your custom telephony. This is exciting. You can now call anyone in the world. &lt;br&gt;
If you haven’t yet, you can join &lt;a href="https://community.dasha.ai"&gt;Dasha community&lt;/a&gt; and let us know how useful this was to you. If you want a super quick answer - ask your questions on &lt;a href="https://stackoverflow.com"&gt;StackOverflow&lt;/a&gt;, using the #dasha hashtag.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Build a human-like conversational AI app in an hour</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Thu, 26 Aug 2021 11:20:32 +0000</pubDate>
      <link>https://dev.to/arrrgr/build-a-human-like-conversational-ai-app-in-an-hour-3031</link>
      <guid>https://dev.to/arrrgr/build-a-human-like-conversational-ai-app-in-an-hour-3031</guid>
      <description>&lt;p&gt;Folks who work in insurance will tell you that it’s about as far from a sexy industry as one can get. Call me narrow-minded but I think any industry can be made sexier with a bit of AI. In today’s tutorial we will do just that: build a conversational AI app that will take a customer’s call, check their policy number and answer a few questions. &lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-start
&lt;/h2&gt;

&lt;p&gt;If this is your first time building a conversational AI app with Dasha, you want to join our &lt;a href="https://community.dasha.ai" rel="noopener noreferrer"&gt;developer community&lt;/a&gt;. This is where you will find all the answers to all of your questions (42). Also, as we are in a closed developer beta right now, this is where we will give you your API key to use Dasha. &lt;/p&gt;

&lt;p&gt;This is the app you will build today: &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/46nyWBTSHgs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;To begin building with Dasha you will need to have Visual Studio Code, NPM and Node.js installed, ideally in their latest versions. Now do the following: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=dasha-ai.dashastudio&amp;amp;ssr=false" rel="noopener noreferrer"&gt;Dasha Studio&lt;/a&gt; VSCode extension&lt;/li&gt;
&lt;li&gt;Open the terminal in VSCode and install Dasha command line interface &lt;code&gt;npm i -g "@dasha.ai/cli"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Now, run the command &lt;code&gt;dasha account login&lt;/code&gt; and follow the browser prompt when it pops up. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You should probably join our &lt;a href="https://community.dasha.ai" rel="noopener noreferrer"&gt;developer community&lt;/a&gt; we obsess over answering all our community members ASAP.&lt;/p&gt;

&lt;p&gt;If you prefer video tutorials, here you go: &lt;/p&gt;

&lt;p&gt;%[&lt;a href="https://www.youtube.com/watch?v=H22H-WBdZko" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=H22H-WBdZko&lt;/a&gt;]&lt;/p&gt;

&lt;h2&gt;
  
  
  Conversation structure
&lt;/h2&gt;

&lt;p&gt;In order for you to better understand the conversation flow of what we are building, here is the basic structure of the conversational AI app. &lt;/p&gt;

&lt;h3&gt;
  
  
  Perfect world conversation
&lt;/h3&gt;

&lt;p&gt;The user/customer calls in and asks to confirm some information about the insurance policy. &lt;/p&gt;

&lt;p&gt;The AI asks for their policy number. The AI then reads the policy number back out to the user to confirm it. If the number is confirmed, Dasha looks up account details. If such an account exists, it tells the user as much and asks what they are after. If no such account exists, it tells the user as much. &lt;/p&gt;

&lt;p&gt;The user may then proceed to ask one of a number of questions, such as, “does my policy cover accidents” or “what is the status of my claim”.&lt;/p&gt;

&lt;p&gt;That’s pretty much it. Sounds simple enough. Before we get to the app, let’s go over the Dasha AI Platform architecture. &lt;/p&gt;

&lt;h2&gt;
  
  
  Dasha AI Platform architecture
&lt;/h2&gt;

&lt;p&gt;There are three main parts to the product which makes building, training, developing and maintaining your human-like conversational apps possible. They are - Dasha Studio, Dasha SDK and Dasha Platform. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fizs76ymbgie7807bel0t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fizs76ymbgie7807bel0t.png" alt="Dasha architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Dasha Studio
&lt;/h3&gt;

&lt;p&gt;Is an extension to VSCode. You use the Studio to create your conversational workflow, provide data to train the neural networks to recognize intents, define ways in which the AI is to respond to the user, as it is talking to the user. The Studio lets you create these apps using DashaScript, an event-driven, domain-specific language derived from TypeScript. In essence, DashaScript is a collection of commands which tell the AI services in the Dasha Cloud Platform how to behave in various situations. &lt;/p&gt;

&lt;h3&gt;
  
  
  Dasha SDK
&lt;/h3&gt;

&lt;p&gt;Is a library used to integrate your applications or services to the Dasha Cloud. It uses GRPC for two way communication between your application and Dasha Cloud Platform &lt;/p&gt;

&lt;h3&gt;
  
  
  Dasha Cloud Platform
&lt;/h3&gt;

&lt;p&gt;The Dasha Cloud is where the magic happens. It provides the AI-as-a-Service components which enable you to create apps that are wildly human-like in the way they interact with users. Best in class speech to text, text to speech, natural language processing, understanding and generation, all come as a service of the Dasha Platform. And we are constantly improving existing services and building new ones. With any application you build using our technology, you will have access to all the newest updates. For more details on the Cloud Platform’s services, peek &lt;a href="https://dasha.ai/en-us/blog/dasha-conversational-ai-as-a-service" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The insurance customer service conversational AI app
&lt;/h2&gt;

&lt;p&gt;Go ahead and open the &lt;a href="https://github.com/arrrgr/insurance-customer-service-demo" rel="noopener noreferrer"&gt;source code&lt;/a&gt; to the application in your VSCode. You can either clone and open the app in your terminal or download, unzip and open the folder in VSCode using File &amp;gt; Open. &lt;/p&gt;

&lt;p&gt;You will now want to open four files. These are essentially what make your conversational AI app built with Dasha possible. &lt;/p&gt;

&lt;h3&gt;
  
  
  index.js
&lt;/h3&gt;

&lt;p&gt;This is the Node.js file from which your conversational AI application is launched. You use index.js to load the Dasha SDK. By the same token, you can incorporate this file, or the code which launches your application into any other Node.js project, from whence you wish to make use of the Dasha Cloud to run conversational apps. In this case, you will obviously need to include the Dasha application code in a separate folder. &lt;/p&gt;

&lt;p&gt;Below is the JavaScript code you would use to launch a basic Dasha SDK connection and Dasha app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@dasha.ai/sdk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connectionProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phone&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createConsoleChat&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;dasha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Endpoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

  &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ttsDispatcher&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dasha&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createConversation&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phone&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;transcription&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;logFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;promises&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./log.txt&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;logFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;transcription&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;logFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;speaker&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\n`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;debugLog&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;msgId&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;RecognizedSpeechMessage&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;logEntry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]?.&lt;/span&gt;&lt;span class="nx"&gt;facts&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;logFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;logEntry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;logFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  main.dsl
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Main.dsl&lt;/strong&gt; is located in the &lt;strong&gt;/app/&lt;/strong&gt; directory. This is the DashaScript file which gets compiled and executed in the Dasha Cloud Platform. This file contains all the instructions that you provide to the Dasha AI Cloud on how to run your application. In essence, this is the conversational structure. &lt;/p&gt;

&lt;h3&gt;
  
  
  data.json
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Data.json&lt;/strong&gt; is the super-power file. It gives you the super power of training neural networks with simple JSON datasets. It is used for two things mainly - to define &lt;a href="https://dasha.ai/en-us/blog/intent-classification" rel="noopener noreferrer"&gt;&lt;strong&gt;intents&lt;/strong&gt;&lt;/a&gt; - ways of helping the AI to understand what real meaning the user places into their replies and &lt;a href="https://dasha.ai/en-us/blog/named-entity-recognition" rel="noopener noreferrer"&gt;named entities&lt;/a&gt; - data points located within the user’s replies. You can read more about both functions at the links above. &lt;/p&gt;

&lt;h3&gt;
  
  
  phrasemap.json
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Phrasemap.json&lt;/strong&gt; is another superpower file. Here you instruct what phrases your AI app should use in responding to the user. You can also instruct it to vary the phrases, to say different things if the same node gets called up a second or third time, etc. &lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the conversational AI app
&lt;/h2&gt;

&lt;p&gt;Now that we’ve got a high-level overview of the technology and the files you are working with, let’s look at &lt;strong&gt;main.dsl&lt;/strong&gt; more closely. &lt;/p&gt;

&lt;h3&gt;
  
  
  Run a test
&lt;/h3&gt;

&lt;p&gt;To start off, let’s launch a test conversation. To do so, you will need to have the &lt;a href="https://github.com/arrrgr/insurance-customer-service-demo" rel="noopener noreferrer"&gt;code&lt;/a&gt; open in your VSCode. Run &lt;strong&gt;&lt;code&gt;npm i&lt;/code&gt;&lt;/strong&gt;. Now, run &lt;strong&gt;&lt;code&gt;npm start chat&lt;/code&gt;&lt;/strong&gt;. A chat session will launch in your terminal. You can also run &lt;strong&gt;&lt;code&gt;npm start 12223334455&lt;/code&gt;&lt;/strong&gt; where &lt;em&gt;12223334455&lt;/em&gt; is your phone number in international format. You will get a call from the AI and can talk to it. &lt;/p&gt;

&lt;p&gt;Now, let’s look at the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Imports and declarations
&lt;/h3&gt;

&lt;p&gt;We start off by importing the library of commonly used digressions, intents, etc. By the way, digressions are nodes that can be called up at any point in the conversation. They do not have a node leading into them. Digressions are great for two things. One is preparing your AI appfor a variety of tangents which a human user might bring up in the course of a conversation. Two is letting you teach your AI app to say something along the lines of “how can I help you today” and then listen in for a response. You can read more about digressions &lt;a href="https://dasha.ai/en-us/blog/using-digressions" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Then we declare context variables - &lt;strong&gt;input&lt;/strong&gt; (ones that are pushed to the app on conversation start) and &lt;strong&gt;storage&lt;/strong&gt; ones. Following this, we declare external functions. &lt;/p&gt;

&lt;p&gt;External functions are a way to pass and receive arguments to and from the &lt;strong&gt;index.js&lt;/strong&gt; file, in which the Dasha app runs as a function. You can in turn write instructions on what to do with these arguments, for example, calculations or, more importantly, you can push data to or pull data from an external service from the Node.js file. Or both. In the app you are looking at now we make use of external functions and will go over it. &lt;/p&gt;

&lt;p&gt;I will paste examples of code. Unfortunately, due to the nature of Dasha apps, these code snippets do not pass the copy-paste test, as they need multiple files to run. As you have opened the &lt;a href="https://github.com/arrrgr/insurance-customer-service-demo" rel="noopener noreferrer"&gt;repo&lt;/a&gt;, you can run the entire code base.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "commonReactions/all.dsl";

context 
{
    // declare input variables here
    input phone: string;

    // declare storage variables here 
    name: string = ""; 
    policy_number: string = ""; 
    policy_read: string = "";
    policy_status: string = "";
    rating: string = "";
    feedback: string = "";
    claim: string = "";
}

// declare external functions here 
external function check_policy(policy_number: string): string;
external function convert_policy(policy_number: string): string;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conversation flow
&lt;/h3&gt;

&lt;p&gt;The conversation starts in earnest with line 22. &lt;/p&gt;

&lt;p&gt;We kick it off with a starting node named &lt;strong&gt;root&lt;/strong&gt;. Once the connection is established, the AI says the &lt;code&gt;__”greeting”__&lt;/code&gt; phrase, as indicated in the &lt;strong&gt;phrasemap.json&lt;/strong&gt;. In the greeting phrase it asks for a name. Upon finding the data &lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt;, as defined in &lt;strong&gt;data.json&lt;/strong&gt;, the conversation moves to the next node. In &lt;code&gt;node node_2&lt;/code&gt;, we store the collected name data in the previously defined storage variable &lt;code&gt;name&lt;/code&gt; and then use it to greet the user by their name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
   do //actions executed in this node
   {
       #connectSafe($phone); // connecting to the phone number which is specified in index.js that it can also be in-terminal text chat
       #waitForSpeech(1000); // give the person a second to start speaking
       #say("greeting"); // and greet them. Refer to phrasemap.json &amp;gt; "greeting"
       wait *; // wait for a response
   }
   transitions // specifies to which nodes the conversation goes from here
   {
       node_2: goto node_2 on #messageHasData("name"); // when Dasha identifies that the user's phrase contains "name" data, as specified in the named entities section of data.json, a transfer to node node_2 happens
   }
}

node node_2
{
   do
   {
       set $name =  #messageGetData("name")[0]?.value??""; //assign variable $name with the value extracted from the user's previous statement
       #log($name);
       #say("pleased_meet", {name: $name} );
       wait*;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, please refer to &lt;strong&gt;phrasemap.json&lt;/strong&gt; to see how the phrases are defined. You can see that we provide an alternate phrase under the label &lt;code&gt;”repeat”&lt;/code&gt;. This lets Dasha know that if it comes back to the same node a second time, a different phrase must be used. Note the use of dynamic variables in &lt;code&gt;node node_2&lt;/code&gt; and &lt;code&gt;”pleased_meet”&lt;/code&gt; phrase. Note that you can also define phrases directly and use dynamic variables in the body of main.dsl using the &lt;a href="https://docs.dasha.ai/en-us/default/dasha-script-language/built-in-functions?searchResult=p61-highlight-0#saytext-blocking-call" rel="noopener noreferrer"&gt;&lt;code&gt;#sayText()&lt;/code&gt; function&lt;/a&gt; and &lt;a href="https://stackoverflow.com/questions/68737877/how-added-dynamic-data-to-phrasemap/68742493#68742493" rel="noopener noreferrer"&gt;string concatenation&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nl"&gt;"greeting"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; 
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"first"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hello! Thank you for calling ACME Insurance claims help line. My name is Dasha. I will be your artificially intelligent agent today. Can you please introduce yourself?"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"repeat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"I was just saying, can you please introduce yourself? "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;

      &lt;/span&gt;&lt;span class="nl"&gt;"pleased_meet"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; 
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"first"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Pleased to meet you "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dynamic"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;". How can I help you today? "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"repeat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"I was just saying. How can I help you today "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dynamic"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"?"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s take a look at &lt;strong&gt;data.json&lt;/strong&gt; to get a grasp of the neural network training data. We are looking at the &lt;strong&gt;named entities&lt;/strong&gt; section of the file. Under &lt;code&gt;”values”&lt;/code&gt; we define the types of names that a person might have. Note that the &lt;code&gt;”open_set”&lt;/code&gt; parameter is set to &lt;code&gt;true&lt;/code&gt;. This means that the AI is free to substitute various other names for the ones we provide to it as an example. To help it recognize where the names can be located in the body of the user’s response, we provide &lt;code&gt;”includes”&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"entities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"open_set"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"values"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Jim Smith"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Jim Smith"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Tony Montana"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Tony Montana"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Jill Jones"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Jill Jones"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"My name is (Tony Montana)[name]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"My name is (Jill Jones)[name]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"This is (Jim Smith)[name]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Jim Smith)[name] calling"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Jill Jones)[name]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I'm (Tony Montana)[name]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(Tony Montana)[name]"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moving further down in &lt;strong&gt;main.dsl&lt;/strong&gt; we come upon &lt;code&gt;digression policy_1&lt;/code&gt;. This digression gets called up when the AI identifies intent which corresponds to &lt;code&gt;”policy_check”&lt;/code&gt;, as stated in &lt;strong&gt;data.json&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Here is where it gets interesting. Take a look at the following three nodes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digression policy_1
{
    conditions {on #messageHasIntent("policy_check");}
    do 
    {
        #say("what_policy");  //ask for policy number
        wait*;
    }
    transitions
    {
        policy_2: goto policy_2 on #messageHasData("policy");
    }
}

node policy_2
{
    do 
    {
        set $policy_number = #messageGetData("policy")[0]?.value??""; //set $policy_number wit the value acquired from the user 
        set $policy_read = external convert_policy($policy_number); //call up external function to add spaces between numbers to help the AI read out the numbers more legibly
        #log($policy_read);
        #say("confirm_policy" , {policy_read: $policy_read} ); //read policy number back out to user to confirm it was heard correctly
        wait*;
    }
    transitions
    {
        yes: goto policy_3 on #messageHasIntent("yes");
        no: goto policy_1_a on #messageHasIntent("no");
    }
}

node policy_3
{
    do
    {
        set $policy_status = external check_policy($policy_number); //call up an external function to check the policy 
        #say("verification_result", {policy_status: $policy_status} );
        wait*;
    }
    transitions
    {
        yes: goto can_help on #messageHasIntent("yes");
        no: goto bye_rate on #messageHasIntent("no");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can tell from the code and the comments, we ask the user to state their policy number in &lt;code&gt;digression policy_1&lt;/code&gt;, the number is identified as per instructions to the neural networks in &lt;strong&gt;data.json&lt;/strong&gt; under &lt;code&gt;”entities”&lt;/code&gt; &amp;gt; &lt;code&gt;”policy”&lt;/code&gt;. In &lt;code&gt;node policy_2&lt;/code&gt;, we store the policy number, call up an external function to send the number value to &lt;strong&gt;index.js&lt;/strong&gt;, where we put spaces between the numbers. The reason for this is - a string of numbers that have no spaces between them will be read by Dasha out as the integer value, for example, one thousand fifty, versus one zero five zero. We put the spaces between the numbers, pass the value back to our app and store it as $policy_read. This number is then read out to the user, to confirm that it was heard correctly. If the number is read incorrectly, the AI asks the user to repeat it. If it is confirmed by the user, we go to &lt;code&gt;node policy_3&lt;/code&gt;.  Here we call up an external function to check the policy number and verify that there is an active policy with this number. In the case of this demo, we simply pick one or two outcomes with random chance. In the case of a real application running in production, you will want to integrate with your database and get the data from there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="c1"&gt;// external function convert policy number.&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setExternal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;convert_policy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;policyRead&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;policy_number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;. &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;policyRead&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;policyRead&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

 &lt;span class="c1"&gt;// external function check policy number. Here we are providing a random evaluation, you will want to refer to your membership database&lt;/span&gt;
 &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setExternal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;check_policy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;policyNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;policyNumber&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;This is a valid policy number. And there is currently one active claim associated with this policy number.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;There is no active policy with this number. I'm sorry.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Going back to &lt;code&gt;node policy_3&lt;/code&gt; - if the user has no additional questions, the conversation progresses to &lt;code&gt;node bye_rate&lt;/code&gt;. Before letting the user go, Dasha asks to rate the interaction on the scale of 0 to 10. If the rating is six or below, Dasha will ask the user to clarify what they did not like about the experience. &lt;/p&gt;

&lt;p&gt;You can find this code in &lt;strong&gt;main.dsl&lt;/strong&gt; lines 104-177. Below I will only show the code for &lt;code&gt;node rating_evaluation&lt;/code&gt;, as it is the only node dealing with functions that we have not used previously in this tutorial. As you can tell here, we save data collected from the user (rating 0-10) to a variable &lt;code&gt;$rating&lt;/code&gt;, which we then convert to an integer. We have to do this because all user replies are saved as strings by Dasha. We then see whether the rating is greater than or equal to 7 or otherwise. Based on the outcome, the conversation develops.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node rating_evaluation
{
   do
   {
       set $rating =  #messageGetData("rating")[0]?.value??""; //assign variable $rating with the value extracted from the user's previous statement
       #log($rating);
       var rating_num = #parseInt($rating); // #messageGetData collects data as an array of strings; we convert the string to an integer in order to evaluate whether the rating is positive or negative
       if ( rating_num &amp;gt;=7 )
       {
           goto rate_positive; // note that this function refers to the transition's name, not the node name
       }
       else
       {
           goto rate_negative;
       }
   }
   transitions
   {
       rate_positive: goto rate_positive; // you need to declare transition name and the node it refers to here
       rate_negative: goto rate_negative;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Starting at line 193 and to the end of &lt;strong&gt;main.dsl&lt;/strong&gt;, the remaining digressions begin. These are concerned with the additional questions that a user might ask, once their policy number has been confirmed. These digressions deal with questions such as “what is the status of my insurance claim” and “I’d like to redeem my completed claim.” &lt;/p&gt;

&lt;h2&gt;
  
  
  In conclusion
&lt;/h2&gt;

&lt;p&gt;Now that you have gone through the conversational AI app, make some changes to it and run some tests, using the commands stated earlier. For your reference: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Run &lt;strong&gt;&lt;code&gt;npm i&lt;/code&gt;&lt;/strong&gt;. Now, run &lt;strong&gt;&lt;code&gt;npm start chat&lt;/code&gt;&lt;/strong&gt;. A chat session will launch in your terminal. You can also run &lt;strong&gt;&lt;code&gt;npm start 12223334455&lt;/code&gt;&lt;/strong&gt; where 12223334455 is your phone number in international format. You will get a call from the AI and can talk to it.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Let us know in the comments or in &lt;a href="https://community.dasha.ai" rel="noopener noreferrer"&gt;Dasha Developer Community&lt;/a&gt; what you build. &lt;/p&gt;

</description>
      <category>ai</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to design and build your first conversational voice AI app</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Thu, 05 Aug 2021 08:45:33 +0000</pubDate>
      <link>https://dev.to/arrrgr/how-to-design-and-build-your-first-conversational-voice-ai-app-1e7f</link>
      <guid>https://dev.to/arrrgr/how-to-design-and-build-your-first-conversational-voice-ai-app-1e7f</guid>
      <description>&lt;p&gt;In this tutorial I'll go over analyzing your proposed conversation, tailoring a conversational script, preparing and implementing it as a voice app using Dasha AI platform.&lt;/p&gt;

&lt;p&gt;/* We're in closed beta now. This is a repost of two posts form our blog. If you want to try a conversational AI for a pet project, head over to &lt;a href="https://community.dasha.ai"&gt;community.dasha.AI&lt;/a&gt; to join our developer community; you'll be welcomed and provided instructions on how to get your API key + you'll have the support of all our CS engineers. */ &lt;/p&gt;

&lt;h2&gt;
  
  
  AI as a service in the context of Dasha AI 
&lt;/h2&gt;

&lt;p&gt;A key value proposition of Dasha AI Platform suite of tools is letting you use the latest and greatest in conversational AI without knowing a single thing about machine learning, neural networks or AI for that matter. To this end, we provide AI as a service of the Dasha Cloud Platform. &lt;br&gt;
Here is the architecture at a glance, for more please refer to the Platform Overview section of the documentation. Everything you see in the Application Layer is the AI as a service component. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--24_OaEjZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673029605/KSrvIRobZ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--24_OaEjZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673029605/KSrvIRobZ.png" alt="Dasha architecture map"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Preparing your script and adapting it for the AI conversational interface
&lt;/h2&gt;

&lt;p&gt;For the purpose of this article we will take a simple conversation that I want to automate with an AI app. It’s an app that will replace an administrator at your favorite restaurant. You call the restaurant, the AI picks up, takes your order and tells you when to come by to pick it up. Of course, we may need to answer a few questions along the way. To figure out how the conversation usually goes, we sit down with the current receptionist. Here is the conversation, as he conveyed it to us. &lt;/p&gt;

&lt;p&gt;Administrator: Hi, this is John at Acme Burgers Main Street location. Would you like to place an order for pick-up? &lt;br&gt;
Customer: Yes, please. &lt;br&gt;
Administrator: What can I get for you? &lt;br&gt;
Customer: I’d like a burger, some fries and a milkshake. &lt;br&gt;
Administrator. Perfect. Let me just make sure I got that right. You want a burger, fries and a milkshake, correct? &lt;br&gt;
Customer: That’s right. &lt;br&gt;
Administrator: Great. Will you be paying at the store? &lt;br&gt;
Customer: Yes, please. &lt;br&gt;
Administrator: Perfect. Your order will be ready in 20 minutes at Acme Burgers Main Street location. Please go straight to the pick up counter. Can I help you with anything else? &lt;br&gt;
Customer: No, that’s it. Thanks. &lt;br&gt;
Administrator: And thank you for placing your order with us. Have a lovely day and enjoy!&lt;/p&gt;

&lt;p&gt;The Administrator also told us that sometimes customers ask about food availability, delivery, ability to eat in, among other things. Let’s structure this script for your use in your conversational AI app development. I like to use a table to do this, as it helps me to get a bird’s eye view of the app I’m building. You can copy &lt;a href="https://docs.google.com/spreadsheets/d/1LqBiQOyY77CsirHimHFz0wN7bCVjhGbns6ptiu4_zLA/edit#gid=0"&gt;this spreadsheet&lt;/a&gt; to your Google Drive here or download it as an Excel spreadsheet to use on your machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9IfSCfVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673130090/i4ZJiUVb2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9IfSCfVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673130090/i4ZJiUVb2.png" alt="A pre-filled out conversation map, as a first step to plan your conversational AI app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to build your conversational AI app, break your conversation into three main areas: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Perfect world workflow&lt;/strong&gt; - that’s the script the administrator shared with us earlier. Note that all nodes here are node which means that they can only be reached from another &lt;strong&gt;node&lt;/strong&gt; or &lt;strong&gt;digression&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Additional nodes (logical extensions)&lt;/strong&gt; - these are talking points that will have to come up based on some of the responses to the script above. In this case, if the user answers “No” to “Would you like to place an order for pick-up?”, a logical response will be “How can I help you then?” Since this is not described in our perfect world workflow, we place this &lt;strong&gt;node&lt;/strong&gt; in the logical extensions section.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Digressions (tangents)&lt;/strong&gt; - our hypothetical restaurant administrator told us that sometimes customers ask about things outside of the script. In order to sound human-like on the phone (pass the Turing test), the AI has to be prepared to respond to these &lt;strong&gt;digressions&lt;/strong&gt;. Here we prepare it for such. Note that, unlike a node, a digression can be brought up at any point in the conversation. Please note column C. It references an intent name. Intent classification categorizes phrases by meaning. This is how the AI app makes sense of what the user is saying to it. You can train your AI app to recognize the specific intent that you are looking for in the phrases of the user. To do so, you modify the data.json file and, you guessed it, you need to assign a specific name to each intent. In this spreadsheet we fill out intent names in Column C. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Pro tip: here's a post explaining the difference between **nodes&lt;/em&gt;* and &lt;strong&gt;digressions&lt;/strong&gt; in detail. You can find it &lt;a href="https://dasha.ai/en-us/blog/using-digressions"&gt;here&lt;/a&gt;. Also Iliya wrote a detailed explanation of how to use &lt;a href="https://dasha.ai/en-us/blog/intent-classification"&gt;intent classification&lt;/a&gt;.*&lt;/p&gt;

&lt;p&gt;Here is our spreadsheet with the intent names filled out:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jbr1Z4V6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673201274/7j3MdrR89k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jbr1Z4V6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673201274/7j3MdrR89k.png" alt="We filled out the intent name"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Planning and structuring your conversational AI app
&lt;/h2&gt;

&lt;p&gt;You should have noticed that a few of the columns in our spreadsheet are empty. Let’s see what they are and what their significance is to building your conversational AI app. &lt;/p&gt;

&lt;p&gt;Let’s start with &lt;strong&gt;column F&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Node name&lt;/strong&gt; - here you will name the &lt;strong&gt;node&lt;/strong&gt;; you will use the name in your DashaScript code &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Digression name&lt;/strong&gt; - by the same token, you will name your &lt;strong&gt;digression&lt;/strong&gt; here&lt;/p&gt;

&lt;p&gt;I have gone through and named all of our nodes and digressions. You can see the result here (here is the &lt;a href="https://docs.google.com/spreadsheets/d/1LqBiQOyY77CsirHimHFz0wN7bCVjhGbns6ptiu4_zLA/edit#gid=0"&gt;spreadsheet link&lt;/a&gt; again just in case )&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9ZO8rj69--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673928402/dcc7H8C_B.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9ZO8rj69--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673928402/dcc7H8C_B.png" alt="Conversation map with Node and Digression names filled out"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We’ve now got the node and digression names. By the way, you probably noticed that &lt;strong&gt;digression names&lt;/strong&gt; and &lt;strong&gt;intent names&lt;/strong&gt; are identical. They don’t have to be but for ease of mapping I like to keep them identical. &lt;/p&gt;

&lt;p&gt;Note that we have a &lt;strong&gt;node place_order&lt;/strong&gt; and a &lt;strong&gt;digression place_order&lt;/strong&gt;. We need to duplicate the functionality because you can only transition into a node, yet at any point in the conversation the user might request ordering food. You can have the same name for a digression and a node. &lt;/p&gt;

&lt;p&gt;Let’s map transitions (we’re getting to the fun part). The funnest (and most helpful) part about mapping transitions is realizing how many logical nodes are missing from our initial vision of the conversation map. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3YX4vqpX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673990933/fEOPDO5Mi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3YX4vqpX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623673990933/fEOPDO5Mi.png" alt="Our conversation map is complete"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now we have specified exactly what action the AI app should take upon any given user response. Bear in mind that we are not mentioning digressions here because the user can bring the digression up at any point in the conversation. That’s why they are digressions.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building your conversational AI app - intents and entities
&lt;/h2&gt;

&lt;p&gt;Now that we have our conversation mapped out, implementing it using DashaScript and JSON in Dasha Studio is a breeze. &lt;/p&gt;

&lt;p&gt;First, you’ll want to open an existing simple Dasha app. I will use &lt;a href="https://github.com/dasha-samples/dasha-first-app"&gt;this one&lt;/a&gt; as the example. If you need instructions on how to get your Dasha Studio set up, you can refer to the second section of &lt;a href="https://dasha.ai/en-us/blog/dasha-sdk-new-release-2021"&gt;this post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you’ve got the app opened in Visual Studio Code, make sure you have the following files open: &lt;em&gt;main.dsl, intents.json&lt;/em&gt;. You will also want to open the visual graph editor - you can refer to it, as you are building your app, for a bird's eye view of transitions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8Sydmn5m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623674176293/Vr_0PcKeR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Sydmn5m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1623674176293/Vr_0PcKeR.png" alt="Visual graph editor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Perfect. I usually like to start with my intents. It helps me to think through things properly. Oh! And I just realized that we forgot to map our Yes and No intents. There is a system function for sentiment negative/positive, however for an app where Yes and No may be expressed in less than usual ways, I suggest creating custom intents. &lt;/p&gt;

&lt;p&gt;Open Intents.json, select all and delete. Now paste in this code to get you started.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"v2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"intents"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"yes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"yes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"correct"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"sure"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"for sure"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"absolutely"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"right"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"righto"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"yep"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"you got it"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I would"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"excludes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"fuck off"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"no"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"no"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"hell no"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"definitely not"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"wrong"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"incorrect"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I do not"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I don't"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I would not"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"excludes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;

     &lt;/span&gt;&lt;span class="nl"&gt;"entities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;

     &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will now need to use the same format to fill out of all the intents that you had defined in the &lt;a href="https://docs.google.com/spreadsheets/d/1LqBiQOyY77CsirHimHFz0wN7bCVjhGbns6ptiu4_zLA/edit#gid=0"&gt;conversation map spreadsheet&lt;/a&gt;. You are stating the name of the intent and then listing examples of phrases that should be interpreted as signifying this intent and examples of phrases that should always be excluded as signifying this intent. Intents.json is the data you provide to train the intent classification neural networks in Dasha Cloud. For most intents 5-10 examples are enough, for some you may need more. &lt;/p&gt;

&lt;p&gt;When you’re done you should have something like &lt;a href="https://docs.google.com/document/d/1X9lfCp6K4tK79hgvMbh16_wj3h3vbCBdIQii81bofF8/edit"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You probably noticed the section “entities” which is something that we have not discussed. &lt;strong&gt;Named entities&lt;/strong&gt; are a way to extract specific data from speech. In this case, we are using &lt;strong&gt;named entities&lt;/strong&gt; to get the user’s order over the phone. To use &lt;strong&gt;entities&lt;/strong&gt;, we have to define them and state examples in the JSON file. To gain a better understanding of using Named Entity Recognition in Dasha, read Iliya’s write up &lt;a href="https://dasha.ai/en-us/blog/named-entity-recognition"&gt;here&lt;/a&gt;. &lt;br&gt;
Here is the code we will use for the entities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"entities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"food"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"open_set"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"values"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"burger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"burger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"hamburger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a burger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a hamburger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a tasty hamburger"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"fries"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"fries"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"some fries"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"french fries"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"delicious fries"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"milkshake"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"milkshake"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"shake"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a milkshake"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"strawberry milkshake"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a tasty milkshake"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"hot dog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"hot dog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"french dog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a hot dog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a french dog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"big dog"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"grilled cheese"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"grilled cheese"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cheese sandwich"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"grilled cheese sandwich"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a grilled cheese sandwich"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a cheese sandwich"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"coke"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"soda"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"coke"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a soda"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"a coke"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(burger)[food], (fries)[food] and a (milkshake)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(burger)[food], (fries)[food] and a (coke)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(grilled cheese)[food], (fries)[food] and a (milkshake)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(grilled cheese)[food], (fries)[food] and a (milkshake)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(hot dog)[food], (fries)[food] and a (milkshake)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(hot dog)[food], (fries)[food] and a (coke)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I'd like a (burger)[food], (fries)[food] and a (milkshake)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I'd like a (burger)[food], (fries)[food] and a (coke)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I'd like   (grilled cheese)[food], (fries)[food] and a (milkshake)[food]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I'd like a (grilled cheese)[food], (fries)[food] and a (milkshake)[food]"&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Synonyms are various ways in which the user might identify the entity value. Includes are ways in which the sentence, containing the entity value, might be phrased. &lt;/p&gt;

&lt;p&gt;Go ahead and paste the section above to replace the “entities” section already in the JSON file. You may want to add some variations in phrasing to further train the neural network powering your conversational AI’s classification engine. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the nodes and digressions 
&lt;/h2&gt;

&lt;p&gt;Now, switch over to the &lt;em&gt;&lt;strong&gt;main.dsl&lt;/strong&gt;&lt;/em&gt; file. First we need to declare a function that will receive the data collected from the conversation with the user. Later in the conversation we will use this function to read the data back to the user to confirm the order. Here is the function declaration statement and here is what the first 5 lines of your new app should look like:&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;context 
{
    input phone: string;
    food: {[x:string]:string;}[]?=null;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s move to the nodes. Your first task is to transfer over all the nodes and to map out their transitions. Start with node root. You will want to change the text to reflect what we had defined in the conversation map and you will want to map the transitions accordingly. As the outcome, you should have this statement:&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
   do
   {
       #connectSafe($phone);
       #waitForSpeech(1000);
       #sayText("Hi, this is John at Acme Burgers Main Street location. Would you like to place an order for pick-up?");
       wait *;
   }   
   transitions
   {
       place_order: goto place_order on #messageHasIntent("yes");
       can_help_then: goto can_help_then on #messageHasIntent("no");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your second node will be place_order. Here we need to use the NLU control function &lt;strong&gt;#messageHasData&lt;/strong&gt; to collect &lt;strong&gt;named entity&lt;/strong&gt; data that we have defined in our intents.json file. This is what it will look like. &lt;br&gt;
As you recall, we declared $food to be a data array variable in line 4 of the file. Now we are populating it with the data the user provides.&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node place_order
{
   do
   {
       #sayText("Great! What can I get for you today?");
       wait *;
   }
   transitions
   {
      confirm_food_order: goto confirm_food_order on #messageHasData("food");
   }
   onexit
   {
       confirm_food_order: do {
       set $food = #messageGetData("food");
      }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refer to your conversation map. The next step from here is to confirm the food order. In this node we will read the data collected and stored in variable &lt;code&gt;$food&lt;/code&gt; back to the user.&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node confirm_food_order
{
   do
   {
       #sayText("Perfect. Let me just make sure I got that right. You want ");
       var food = #messageGetData("food");
       for (var item in food)
           {
               #sayText(item.value ?? "");
           }
       #sayText(" , correct?");
       wait *;
   }
    transitions
   {
       order_confirmed: goto payment on #messageHasIntent("yes");
       repeat_order: goto repeat_order on #messageHasIntent("no");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With these three examples you will be able to create all the other nodes, as are required by your &lt;a href="https://docs.google.com/spreadsheets/d/1LqBiQOyY77CsirHimHFz0wN7bCVjhGbns6ptiu4_zLA/edit#gid=0"&gt;conversation map&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Now on to the digressions. As discussed previously, digressions are nodes that can be called up at any point of the conversation. They are used to make the conversation more human-like. (for more on digressions, read this &lt;a href="https://dasha.ai/en-us/blog/using-digressions"&gt;post&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Let’s start with the delivery digression.&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digression delivery
{
   conditions {on #messageHasIntent("delivery");}
   do
   {
       #sayText("Unfortunately we only offer pick up service through this channel at the moment. Would you like to place an order for pick up now?");
       wait *;
   }
   transitions
   {
       place_order: goto place_order on #messageHasIntent("yes");
       can_help_then: goto no_dice_bye  on #messageHasIntent("no");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the same framework to recreate all the other digressions, as you planned to in the conversation map. The only one to pay attention to will be the &lt;strong&gt;digression place_order&lt;/strong&gt;. Make sure you reuse the code from &lt;strong&gt;node place_order&lt;/strong&gt; to properly utilize named entities for data collection. &lt;/p&gt;

&lt;p&gt;When you are done, your main.dsl file should look something like &lt;a href="https://docs.google.com/document/d/1gpJSCEGsg22jxIGv1g-ZHzOQf_BJHKzNArhJHWYlKfE/edit?usp=sharing"&gt;this&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;You can get the code to the entire app in our &lt;a href="https://github.com/dasha-samples/food-pickup-demo-from-blog"&gt;GitHub repository here&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the conversational AI app you have just built 
&lt;/h2&gt;

&lt;p&gt;Type &lt;code&gt;npm start chat&lt;/code&gt; into your terminal. Give the cloud platform a minute to process the training data and train your intents and entities. A chat will launch within terminal.&lt;/p&gt;

&lt;p&gt;Depending on the route you take, it may go something like this: &lt;/p&gt;

&lt;p&gt;Type &lt;code&gt;npm start number&lt;/code&gt; into your terminal, where number = your phone number in the international format e.g.: 12813308004. You will get a call, when you pick it up give it a second and the AI will begin the conversation, just as you had instructed it to do. &lt;/p&gt;

&lt;p&gt;And that's about it. Have fun playing with our tech, also be sure to pop into &lt;a href="https://community.dasha.AI"&gt;our developer community&lt;/a&gt;. And let me know how I did in the comments. First post and all.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>voice</category>
      <category>conversational</category>
    </item>
    <item>
      <title>Citizen development </title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Thu, 05 Aug 2021 07:49:22 +0000</pubDate>
      <link>https://dev.to/arrrgr/citizen-development-dak</link>
      <guid>https://dev.to/arrrgr/citizen-development-dak</guid>
      <description>&lt;p&gt;Every company is a software company today. And if they are not today, they will be in the forthcoming future.  &lt;/p&gt;

&lt;p&gt;What is one thing every software company has in common? A shortage of IT specialists. In other words, more work than there are developers to do it. And that is where the citizen developer comes in. &lt;br&gt;
If you face problems that can be solved with IT and know how you would solve them but lack the technical skills, you just might be a citizen developer in the making.&lt;/p&gt;

&lt;h2&gt;
  
  
  Citizen developer: meaning, context, models of operation
&lt;/h2&gt;

&lt;p&gt;A citizen developer is any business professional who applies their generalist technical knowledge to solve their own business problems directly through technology, without a specialized developer’s assistance. These solutions can take on a variety of forms. &lt;/p&gt;

&lt;p&gt;To define a citizen developer: &lt;/p&gt;

&lt;p&gt;A sales professional in a small organization is tasked with setting up their sales tech stack. She maps out the workflow and reads the technical documentation to, with ample swearing, integrate Salesforce with Outreach and ZoomInfo. She is a citizen developer. &lt;/p&gt;

&lt;p&gt;A logistics manager at a large home electronics manufacturer is fed up with having to manually fill out spreadsheets. After some searching he tries out a suit of tools from the citizen developer RPA (robotic process automation) vendor Electroneek and builds a bot that replicates his actions in Excel. Soon, all of his peers are using the same automation, and innovations is looking into what other impactful activities can be automated across the company. He is a citizen developer. &lt;/p&gt;

&lt;p&gt;A director of call center operations is short-staffed. She manages a team of nearly 900, yet there are not enough agents to meet the ever increasing customer demand. After some digging around, she tries out Dasha’s suit of tools. With the help of our Customer Success engineers, she is able to put together a simple AI app that takes over for an agent and is able to save 1 minute on each 3-4 minute conversation. This change lets her safely scale total volume of call throughput by 20% without hiring a single new agent. She is a citizen developer. &lt;/p&gt;

&lt;p&gt;I can’t quite pinpoint where my own journey as a citizen developer began. It definitely started before I became aware of the term, with checking server status and server logs on applications that my development team was working on. It progressed to building and deploying WordPress websites and designing intricately integrated sales and marketing technology stacks. Then I learned to build apps with Dasha AI, as a way to quickly put together demos for my customers.&lt;/p&gt;

&lt;p&gt;My expectation is that citizen application development in the 2020’s will be like Excel in the 2000’s. You can’t imagine a job applicant coming to an interview who can’t use MS Word, Excel, Google Docs or email. That’s table stakes. By the same token, citizen application development will become table stakes by the end of the decade. Ranil Boteju, Global Head of Data Analytics WPB at HSBC, argues that the biggest shift will come with widespread use of accessible interfaces for data science analysis, enabling any professional to run big and small dataset analyses right at their computer. &lt;/p&gt;

&lt;p&gt;I’m making citizen development sound like the best thing since flat whites (thanks Australia). Let’s try and figure out what its real benefits and pitfalls are.&lt;/p&gt;

&lt;h2&gt;
  
  
  How citizen development is fundamental to digital transformation: the pros
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Speed of delivery&lt;/strong&gt; No need to get put on a wait list and kick rocks until IT resources get freed up 6 months down the line. With a culture of citizen development, your lines of business are able to solve their tech problems themselves and to do so quickly and efficiently. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No disconnect&lt;/strong&gt; No matter how close your IT and lines of business are, they are two separate functions. You can explain your problems to IT well enough but will they live these problems? No, they have their own. An operations manager who can quickly solve their own problem with tech will solve exactly the problem, until the solution does just what they are after. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quality assurance&lt;/strong&gt; By the same token - our citizen developer operations manager will test the solution they create within a real working environment, as soon as it's ready. Because it solves their problems. This will shorten the QA cycle and eliminate any risks of broken telephone. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Direct visibility into business difficulties&lt;/strong&gt; This one goes without saying. An employee becomes a citizen application developer because they see that something needs fixing and there is no one to step up to the challenge and fix it. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What citizen development is not
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Replacement for IT&lt;/strong&gt; Having a robust citizen development culture does not mean you can do without the help of IT professionals and software engineers. While citizen developers can solve some of their own problems with technologies you put at their disposal, they are still line of business employees first and foremost. This means you will still need tech pros to maintain all your systems and for more complex development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Set it and forget it&lt;/strong&gt; You can’t expect to just give your line of business managers and directors a citizen developer lecture and to have them running off and building tools on their own. This will lead to an influx of what is referred to as shadow IT - a situation in which your company is using technology that was not vetted by IT, nor approved by your infosec experts. What you should do instead is vet a set of tools and have your IT present these tools to your line of business experts, so that they can use them for their work. A best practice is to illustrate the usefulness of these tools with some real world use cases. I see you rolling your eyes - your IT teams are already overloaded. This is where some internal selling chops will come in handy. Your IT team needs to understand that this initial time investment will mean significant time savings for them down the line. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A garden of wild roses&lt;/strong&gt; A citizen developer culture will require nurturing. In our experience, the best way to help your citizen developers excel is to do two things - give them a platform to communicate and give them a way to quickly distribute successful applications to other team members who can use them with benefit. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A career path&lt;/strong&gt; I saw some discussions online claiming the idea of the citizen developer is a dead end because there are no job postings for “citizen developer” roles. And there shouldn’t be. Citizen development is only worthwhile as an additional layer of value that a professional in their respective field can offer to a company. There are no “citizen developer” jobs for the same reason there are no “Microsoft Word expert” jobs. It is an instrument, not a vocation. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to become a citizen developer or create a culture of citizen development
&lt;/h2&gt;

&lt;p&gt;Let’s start with a simple check list. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have you ever identified a problem or inefficiency in your work that can be solved with IT? &lt;/li&gt;
&lt;li&gt;Have you ever pitched IT to solve this problem for you, just to realize that they are much too busy now, and for the foreseeable future? &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You might want to consider becoming a citizen developer or introducing this concept into your company culture. &lt;/p&gt;

&lt;p&gt;How to go about it. As I mentioned earlier, my journey started of its own accord. It arose out of necessity. I clearly don’t have these numbers but I would imagine that the story is similar for a majority of citizen developers. And if you are reading these lines, chances are necessity already arose. &lt;/p&gt;

&lt;p&gt;Were I to be going on the citizen developer journey now, I would follow some sort of a roadmap to identify which tools I should be focusing on. &lt;/p&gt;

&lt;p&gt;Step 1: &lt;/p&gt;

&lt;p&gt;Identify your problems.&lt;/p&gt;

&lt;p&gt;Step 2: &lt;/p&gt;

&lt;p&gt;Identify which type of citizen developer tools might solve these problems. &lt;/p&gt;

&lt;p&gt;Some examples are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RPA (robotic process automation) (e.g.: Electroneek, UI Path) &lt;/li&gt;
&lt;li&gt;Applications development (e.g.: Mendix, Microsoft Power Apps, Salesforce Lightning)&lt;/li&gt;
&lt;li&gt;Common API and visual API tools (e.g.: Zapier, PieSync)&lt;/li&gt;
&lt;li&gt;Legal document automation (e.g.: Documate, Clio)&lt;/li&gt;
&lt;li&gt;Conversational automation - here I would be a fool not to suggest Dasha AI &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In closing
&lt;/h2&gt;

&lt;p&gt;I hope this was helpful. If you want to learn more about citizen development with Dasha AI - we’ve got a whole &lt;a href="https://dasha.ai/en-us/blog?category=developers"&gt;section of blog articles&lt;/a&gt; dedicated just to that. If you’ve got more questions than answers, feel free to schedule a time to speak with me here.  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Build a human-like conversational voice AI app and collect customer feedback
</title>
      <dc:creator>Arthur Grishkevich</dc:creator>
      <pubDate>Tue, 03 Aug 2021 03:53:40 +0000</pubDate>
      <link>https://dev.to/arrrgr/build-a-human-like-conversational-voice-ai-app-and-collect-customer-feedback-30lo</link>
      <guid>https://dev.to/arrrgr/build-a-human-like-conversational-voice-ai-app-and-collect-customer-feedback-30lo</guid>
      <description>&lt;p&gt;Some years back Gartner predicted that 89% of all companies will compete on customer experience. Today no one gets surprised by this. We love Apple, Amazon and Netflix because of the seamless experiences their respective platforms provide. Customer feedback surveys, collecting net promoter scores and customer satisfaction index are a big part of CX strategy for many companies and should be a big part for many more.&lt;/p&gt;

&lt;p&gt;Email and sms customer feedback surveys suck. Phone surveys are cool because they are so rare… and expensive. At least they were expensive. Now you can build a Dasha conversational AI app that will reach out to your customer after an interaction, ask some questions, collect the ratings &lt;em&gt;and&lt;/em&gt; collect some open, actionable feedback. It just works. Also, it’s a fun little project. &lt;/p&gt;

&lt;p&gt;You can watch the video below to see a live demo of what you will have built: &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/mJ_OZYTuJys"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/arrrgr/customer-feedback-survey"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this tutorial we will go over: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Designing the conversation map.&lt;/li&gt;
&lt;li&gt;Outsourcing your phrases to &lt;strong&gt;phrasemap.json&lt;/strong&gt; to clean up the body of your main.dsl application.&lt;/li&gt;
&lt;li&gt;Calling on external functions in your &lt;strong&gt;index.js&lt;/strong&gt; and passing variables from your DashaScript code.&lt;/li&gt;
&lt;li&gt;Running calculations within the body of your DashaScript application.
Using &lt;strong&gt;&lt;code&gt;#getMessageText();&lt;/code&gt;&lt;/strong&gt; to save entire user phrases as strings. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will also touch on some things we’ve covered previously, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating custom intents and named entities, setting up data to train the neural network.&lt;/li&gt;
&lt;li&gt;Creating digressions and ensuring their native flow within the conversational app. &lt;/li&gt;
&lt;li&gt;Structuring “perfect world” node flow. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If this is your first time building conversational apps with Dasha, I recommend you join our &lt;a href="https://community.dasha.ai"&gt;developer community&lt;/a&gt; and read &lt;a href="https://dasha.ai/en-us/blog/conversational-ai-app-creation-guide"&gt;this post&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to ask for feedback from customers: Customer feedback surveys, tools and net promoter scores
&lt;/h2&gt;

&lt;p&gt;Excuse the digression but here is some background information. Brands ask customers for feedback because they want to ensure that their product/service is as tailored to their customers’ needs as they can possibly get it. To a web or mobile developer, this may seem like a crazy notion, after all you are used to setting up A/B tests and figuring out the best ways to engage with the user in this manner. But even here, your product team probably monitors App Store reviews and asks for additional customer feedback/engagement from the users providing feature request or other feedback. Also, let’s not forget about test user focus groups. &lt;br&gt;
In an industry like insurance or banking, for example, you are going to have a much harder time doing the same for anything other than the mobile app. To that end, legacy industries run customer feedback surveys. The common ways to conduct these are - email, SMS/text messages and telephone calls. &lt;/p&gt;

&lt;p&gt;What are the costs/effectiveness of different customer feedback survey channels?  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email customer feedback surveys are free or very cheap but only get a meager 5-30% response rates&lt;/li&gt;
&lt;li&gt;SMS/text message surveys are slightly more expensive and get 10-40% response rates &lt;/li&gt;
&lt;li&gt;Telephone surveys are an order of magnitude more expensive than either of the above; however their results are significantly better - with over 90% response rates on picked up lines &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Needless to say that telephone surveys get very little love due to how expensive they are. Let’s fix that. &lt;/p&gt;
&lt;h2&gt;
  
  
  Preparing the script for your customer feedback survey conversational AI app
&lt;/h2&gt;

&lt;p&gt;A conversational AI application is literally a way of applying conversational AI technology to solve a specific real world problem, for example - how to get feedback from customers. The conversational app interacts with the user (customer) through speech - understanding, interpreting and generating natural language. For more on how Dasha Cloud Platform uses its conversational AI as a Service to make your apps human-like, you can read &lt;a href="https://dasha.ai/en-us/blog/dasha-conversational-ai-as-a-service"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In order to create an app, you need to have a basic understanding of the type of interactions you expect the AI to have with the user. This includes user replies, requests, the AI’s phrases and the direction in which you want it to take the conversation. In a way, this first step is similar to how you may document the UX of a mobile or web app. &lt;/p&gt;

&lt;p&gt;For the sake of the present conversation, let’s envision a conversation in which Dasha calls ACME Bank’s customer a few hours after they had visited the bank’s office. She then proceeds to ask if they have got two minutes to fill out a survey. If they do, she asks three customer feedback questions with a rating of 1-5. If the rating is identified as negative, we will have Dasha ask the customer to specify what could have been done better. For the last question “what was your overall experience like,” we will ask to elaborate on the details of the experience even if it was positive, as well as negative.&lt;/p&gt;

&lt;p&gt;I like to throw together a simple conversation map to outline my conversation. For detailed instructions on how to create your conversational map, you can refer to &lt;a href="https://dasha.ai/en-us/blog/build-conversational-AI-app-1"&gt;this post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For the project we are building, this is the conversational AI app map I ended up with: &lt;/p&gt;

&lt;p&gt;You can find the spreadsheet &lt;a href="https://docs.google.com/spreadsheets/d/1BxyTsJ3sddEnM4Z6ZbMtSUjIojNEGtbEUE-tythKaVg/edit#gid=0"&gt;here&lt;/a&gt;. Feel free to copy to your Google Drive and edit it as you may see fit to change your conversational app.&lt;/p&gt;

&lt;p&gt;Here is what we’ll cover next: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating the “perfect world” conversation flow&lt;/li&gt;
&lt;li&gt;Adding digressions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the course of this we will cover everything promised above - using the phrasemap, creating neural training data, running calculations using DashaScript. &lt;/p&gt;
&lt;h2&gt;
  
  
  Building the “perfect world flow” version of your customer feedback survey conversational AI app
&lt;/h2&gt;

&lt;p&gt;First, make sure you’ve got the latest version of Node.js and Visual Studio Code. Now, head over to our &lt;a href="https://community.dasha.ai"&gt;developer community&lt;/a&gt; where you will get instructions to your Dasha API key. You will also want to install the Dasha Studio extension in VS Code, a well as the Dasha &lt;a href="https://dasha.ai/en-us/blog/dasha-cli"&gt;command line interface&lt;/a&gt; &lt;strong&gt;&lt;code&gt;npm i -g "@dasha.ai/cli"&lt;/code&gt;&lt;/strong&gt;. AIf you need a quick start guide, please refer to &lt;a href="https://dasha.ai/en-us/blog/virtual-receptionist-software"&gt;this post&lt;/a&gt;. If you have any difficulties, just ask in our developer community. &lt;/p&gt;

&lt;p&gt;Now open a Dasha app in VS Code. I propose you start with the &lt;a href="https://github.com/dasha-samples/dasha-first-app"&gt;first app&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Now, open up the following files:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;main.dsl&lt;/strong&gt;  - you use your main DashaScript file to define the conversational workflow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;phrasemap.json&lt;/strong&gt; - you use the phrase map to store phrases for Dasha to pronounce in the course of the conversation. You map to the phrases from &lt;strong&gt;main.dsl&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;intents.json&lt;/strong&gt; -  here is where you store the data with which to train the neural network to recognize custom intents and named entities. Pro tip: rename to data.json, because the file includes named entities, not only intents. &lt;/li&gt;
&lt;li&gt; &lt;strong&gt;index.js&lt;/strong&gt; - the NodeJS file which launches the Dasha SDK. This is where you can use external JS functions to augment your conversational workflow or build out integrations to external services.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Go to &lt;strong&gt;main.dsl&lt;/strong&gt;. You can refer to the application source code &lt;a href="https://github.com/arrrgr/customer-feedback-survey"&gt;here&lt;/a&gt; if you wish but I strongly encourage you to build from scratch using a blank canvas. &lt;/p&gt;

&lt;p&gt;Select all code and delete it. &lt;/p&gt;

&lt;p&gt;Let’s start by importing common libraries&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "commonReactions/all.dsl";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let’s declare some variables. We are going to use these to store variables. Here and onwards, refer to the in-code comments for additional specifications:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;context
{
   // declare input variables phone and name - these variables are passed at the outset of the conversation. In this case, the phone number and customer’s name
   input phone: string;
   input name: string = "";

   // declare storage variables
   q1_rate: string = "";
   q2_rate: string = "";
   q3_rate: string = "";
   q1_feedback: string = "";
   q2_feedback: string = "";
   q3_feedback: string = "";
   final_feedback: string = "";
   call_back: string = "";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let’s declare an external function. External function is how you call out to &lt;strong&gt;index.js&lt;/strong&gt; from DashaScript (&lt;strong&gt;main.dsl&lt;/strong&gt;) to make use of JavaScript functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// declaring external function for console logging, so that we can check the values of the variables, as the conversation progresses 
external function console_log(log: string): string;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ll look at this external function a bit later. Now, let’s move to the actual conversation flow. The first node in the conversation is called the &lt;strong&gt;&lt;code&gt;node root&lt;/code&gt;&lt;/strong&gt;. As above, please refer to the comments below. They will help to paint the full picture.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;start node root
{
   do //actions executed in this node
   {
       #connectSafe($phone); // connecting to the phone number which is specified in index.js that it can also be in-terminal text chat
       #waitForSpeech(1000); // give the person a second to start speaking
       #say("greeting", {name: $name} ); // and greet them. Refer to phrasemap.json &amp;gt; "greeting" (line 12); note the variable $name for phrasemap use
       wait *;
   }
   transitions // specifies to which nodes the conversation goes from here and based on which conditions. E.g. if intent “yes” is identified, the conversation transitions to node question_1
   {
       question_1: goto question_1 on #messageHasIntent("yes"); // feel free to modify your own intents for "yes" and "no" in data.json
       all_back: goto when_call_back on #messageHasIntent("no");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that in the function &lt;strong&gt;&lt;code&gt;#say("greeting", {name: $name} );&lt;/code&gt;&lt;/strong&gt; we refer to &lt;strong&gt;&lt;code&gt;greeting&lt;/code&gt;&lt;/strong&gt;. The &lt;strong&gt;&lt;code&gt;#say()&lt;/code&gt;&lt;/strong&gt; function maps to the reference phrase in &lt;strong&gt;phrasemap.json&lt;/strong&gt;.   This means we need to add the values to your phrasemap. Open it up. You will see up top the following 9 lines of code. Keep it. This code controls the speech synthesis. Feel free to play around with it but these are the preferred values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; 
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"voiceInfo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; 
     &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"lang"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"en-US"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"speaker"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"V2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"speed"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"variation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will add some phrases to this file as we go along. If there are leftover phrases which are unused by our present app, it will not hurt the performance of the app. However, I encourage you to look through your JSON code and clean out all unused pieces of code. &lt;/p&gt;

&lt;p&gt;Let’s add the phrase “greeting”, so that it can map to the relevant code in &lt;strong&gt;main.dsl&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="nl"&gt;"greeting"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hi "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dynamic"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;" this is Dasha with Acme Credit Union. You visited one of our offices earlier today. I'd like to ask you a few questions about the experience. Do you have two minutes now? "&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now scroll down, until you see __&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
:__ and add this line:



```json
      "greeting": {},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember that for every phrase you add to the phrase map, you need to have a corresponding macro. If you forget, your IDE will let you know you made the mistake. Now your app knows how to greet the user. Note that we are substituting a dynamic variable “name” to refer to the user by their name. &lt;br&gt;
The input variable &lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt; is also used in the function we were just looking at &lt;strong&gt;&lt;code&gt;#say("greeting", {name: $name} );&lt;/code&gt;&lt;/strong&gt;. As you run your conversational app, you would input the value for “name” following for the phone number. The terminal command to launch a call would look something like this: &lt;strong&gt;&lt;code&gt;npm start 12223334455 John&lt;/code&gt;&lt;/strong&gt;. Now, in order for the application to recognize “John” as mapping to variable &lt;strong&gt;&lt;code&gt;name&lt;/code&gt;&lt;/strong&gt;, we need to provide instructions in the SDK. Open &lt;strong&gt;index.js&lt;/strong&gt; and search for &lt;strong&gt;&lt;code&gt;const conv = app.createConversation&lt;/code&gt;&lt;/strong&gt; modify this line to read.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="c1"&gt;// in the line below, to account for name input context variable, you declare below: name: process.argv[3] ?? ""&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createConversation&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code is found in lines 57-58 of &lt;strong&gt;index.js&lt;/strong&gt;, as found in the GitHub repository.&lt;br&gt;
Great work. Now let’s assume that our user replied in the positive to Dasha’s request for two minutes and move on to the perfect world flow below. We finally get to ask the first question of our automated customer feedback survey.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node question_1
{
   do
   {
       #say("question_1"); //call on phrase "question_1" from the phrasemap
       wait *;
   }
   transitions
   {
       q1Evaluate: goto q1Evaluate on #messageHasData("rating");// when Dasha identifies that the user's phrase contains "rating" data, as specified in the named entities section of data.json, a transfer to node q1Evaluate happens
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty straightforward stuff. Dasha pronounces the phrase for &lt;strong&gt;&lt;code&gt;question_1&lt;/code&gt;&lt;/strong&gt; from the &lt;strong&gt;phrasemap&lt;/strong&gt;, waits for a response and, on recognizing rating data, transfers to &lt;strong&gt;&lt;code&gt;node q1Evaluate&lt;/code&gt;&lt;/strong&gt;. You will need to add  &lt;strong&gt;&lt;code&gt;question_1&lt;/code&gt;&lt;/strong&gt; to the phrasemap file. I will show you this one last example, the rest of the phrasemap modifications you will do on your own, using previous ones as examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="nl"&gt;"question_1"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"first"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Perfect, thank you. First question - how would you rate the bank employees with whom you interacted on the scale of 1 to 5."&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}],&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"repeat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
             &lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"I was saying. how would you rate the bank employees with whom you interacted on the scale of 1 to 5."&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the &lt;strong&gt;”repeat”&lt;/strong&gt; value. This lets us provide an alternative phrase for the AI to substitute for the original in case this node gets called on a second time. Such a thing would usually happen when coming back from a &lt;strong&gt;digression&lt;/strong&gt;. To learn more about digressions, you can take a look at &lt;a href="https://dasha.ai/en-us/blog/using-digressions"&gt;this article&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The second part I want to draw your attention to in the node above is the transition to &lt;strong&gt;&lt;code&gt;node q1Evaluate&lt;/code&gt;&lt;/strong&gt;. The function &lt;strong&gt;&lt;code&gt;#messageHasData()&lt;/code&gt;&lt;/strong&gt; tells Dasha to check for a specific set of data, as defined in the &lt;strong&gt;“entities”&lt;/strong&gt; section of &lt;strong&gt;data.json&lt;/strong&gt;.  Go to the file. You will need to append the code below after the closing curly bracket for &lt;strong&gt;”intents”&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"entities"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"rating"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"open_set"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
     &lt;/span&gt;&lt;span class="nl"&gt;"values"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"one"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"zero"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"horrible"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"worst ever"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"the worst"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"awful"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"horrid"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"despicable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"detestable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"very bad"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"two"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bad"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"quite bad"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pretty bad"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"not good"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"crappy"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"three"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"alright"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"okay"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"just okay"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"four"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"good"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pretty good"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"quite good"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"good enough"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
         &lt;/span&gt;&lt;span class="nl"&gt;"synonyms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"five"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"amazing"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"incrdible"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"just grand"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"perfct"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wondrful"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"very good"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;“ten”&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I would say it was (1)[rating]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"(4)[rating]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"I had an (3)[rating] experience"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="s2"&gt;"It was (4)[rating]”,
    “Totally (2)[rating]”
     ]
   }
 }
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the &lt;strong&gt;&lt;code&gt;"open_set": false,&lt;/code&gt;&lt;/strong&gt;. This tells the AI that it cannot substitute just any values for the ones defined in the file. The match has to be exact. Now, this only applies to the &lt;strong&gt;”value”&lt;/strong&gt;, not to the &lt;strong&gt;“synonym”&lt;/strong&gt;. For example, with time the neural network will recognize “brilliant”, as signifying “5”, even though it is not mentioned in the training data. But it will never recognize “6” as a reasonable value to save in place of “1” or “5”. If you were to set the parameter to “true”, it would. &lt;/p&gt;

&lt;p&gt;Also, pay attention to the &lt;strong&gt;”includes”&lt;/strong&gt; section. It provides a few variations of the types of constructions the AI may expect to hear from the user, so that it knows in which place to look for the value, in case it is not an exact match to one of the “synonyms”. &lt;br&gt;
We got through &lt;strong&gt;&lt;code&gt;node question_1&lt;/code&gt;&lt;/strong&gt;. Let’s assume the user gave us an acceptable value which was rightly interpreted by the neural network and we are on to the next node. In this one, we evaluate the received value to estimate if the response is positive or negative.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node q1Evaluate
{
   do
   {
       set $q1_rate =  #messageGetData("rating")[0]?.value??""; //assign variable $q1_rate with the value extracted from the user's previous statement
       var q1_num = #parseInt($q1_rate); // #messageGetData collects data as an array of strings; we convert the string into a number in order to evaluate whether the rating is positive or negative
       if ( q1_num &amp;gt;=4 &amp;amp;&amp;amp; q1_num &amp;lt;=5 )
       {
           goto question_2; // note that this function refers to the transition's name, not the node name
       }
       else
       {
           goto question_1_n;
       }
   }
   transitions
   {
       question_2: goto question_2; // you need to declare transition name and the node it refers to here
       question_1_n: goto question_1_n;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Named entity variables are stored as an array of strings. In order for us to interpret the extracted value, we need to convert it to an integer. Once it is converted to integer, we can compare the value. If it is greater than or equal to 4, we go on to &lt;strong&gt;&lt;code&gt;node question_2&lt;/code&gt;&lt;/strong&gt;. If it is less than 4, we want Dasha to ask the user how their experience could have been made better. Let’s do just that now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node question_1_n
{
   do
   {
       #say("question_1_n");
       wait*;
   }
   transitions // specifies an action that Dasha AI should take, as it exits the node. The action must be mapped to a transition
   {
       q1_n_to_q2: goto q1_n_to_q2 on true; // "on true" is a condition which lets Dasha know to take the action if the user utters any phrase
   }
   onexit 
   {
       q1_n_to_q2: do
       {
           set $q1_feedback = #getMessageText();
           external console_log($q1_feedback); // call on external function console_log (we want to see that the data was collected properly), you can then use the variable to push to wherever you want to use it from index.js
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take a look at the &lt;strong&gt;&lt;code&gt;onexit&lt;/code&gt;&lt;/strong&gt; section. This is where we use our external function which we initialized in the beginning of &lt;strong&gt;main.dsl&lt;/strong&gt;. We want to be able to check that the values were collected properly in this part of the conversation. To do so, we need to store the value collected from the user’s reply in the previous node as variable (&lt;strong&gt;&lt;code&gt;$q1_feedback&lt;/code&gt;&lt;/strong&gt;) and send the value to our JS file and execute the &lt;strong&gt;&lt;code&gt;console.log()&lt;/code&gt;&lt;/strong&gt; function.&lt;/p&gt;

&lt;p&gt;Of course, in order to use the function, we need it to exist in our &lt;strong&gt;index.js file&lt;/strong&gt;, so let’s head over there and add the code below within the &lt;strong&gt;&lt;code&gt;async function main()&lt;/code&gt;&lt;/strong&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in the next 4 lines you set up a function for checking your acquired variables with external function console_log&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setExternal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;console_log&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;conv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is line 50 if you are looking at the file found in the GitHub repo. &lt;br&gt;
Now that we collected the open feedback we can head over to the next question. However, logic and good upbringing call for us to say something encouraging to the customer who poured their heart out to us. Unfortunately, there is no way to say a phrase after the &lt;strong&gt;&lt;code&gt;onexit&lt;/code&gt;&lt;/strong&gt; section, so we head to a transition node.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node q1_n_to_q2
{
   do
   {
       #say("transition");
       goto question_2;
   }
   transitions
   {
       question_2: goto question_2;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quite self-explanatory. From here we head over to &lt;strong&gt;&lt;code&gt;node question_2&lt;/code&gt;&lt;/strong&gt;. I will leave it up to you to recreate questions 2 and 3, along with all the phrase maps based on the example nodes above. Do bear in mind that question 3 has branches - positive and negative, not negative and next question. When in doubt refer to the conversation map. There is also the final question that we ask before disconnecting - does the customer have anything else to add. That leads into the final node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node final_bye
{
   do
   {
       #say("final_bye");
       exit;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should also add two nodes for the call back flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Digressions - what to do when your user strays from the customer feedback survey script
&lt;/h2&gt;

&lt;p&gt;A digression is activated when Dasha identifies that the user has mentioned a specific intent. A digression can be activated in any point in the conversation. You can read up more on digressions &lt;a href="https://dasha.ai/en-us/blog/using-digressions"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As you can see in our &lt;a href="https://docs.google.com/spreadsheets/d/1BxyTsJ3sddEnM4Z6ZbMtSUjIojNEGtbEUE-tythKaVg/edit#gid=0"&gt;conversation map&lt;/a&gt;, we have defined quite a few digressions. Let’s create the digression for “how_are_you”. First, you will want to define the intent, so that Dasha knows when the digression is called. Add this code to the &lt;strong&gt;”intents”&lt;/strong&gt; part of the &lt;strong&gt;data.json&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nl"&gt;"how_are_you"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"includes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"how are you?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"how is everything?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
        &lt;/span&gt;&lt;span class="s2"&gt;"you okay?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"how are you"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"what it do"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, head over to &lt;strong&gt;main.dsl&lt;/strong&gt;. Scroll down to the bottom and add this code for the digression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digression how_are_you
{
   conditions {on #messageHasIntent("how_are_you");}
   do
   {
       #sayText("I'm well, thank you!", repeatMode: "ignore");
       #repeat(); // let the app know to repeat the phrase in the node from which the digression was called, when go back to the node
       return; // go back to the node from which we got distracted into the digression
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, quite self explanatory thanks to the comments. When intent &lt;strong&gt;”how_are_you”&lt;/strong&gt; is recognized, the platform says “I’m well, thank you!” (note that I’m using &lt;strong&gt;&lt;code&gt;#sayText&lt;/code&gt;&lt;/strong&gt;, not &lt;strong&gt;&lt;code&gt;#say&lt;/code&gt;&lt;/strong&gt; here. This means I can type up the text right in the node and don’t have to refer to the phrase map). Then it goes back to the node from which it was so rudely interrupted and repeats the phrase that Dasha pronounced after which the user initiated the digression. If you provide alternative phrasing in your phrase map, Dasha will use it. &lt;/p&gt;

&lt;p&gt;And there you go. If you follow these instructions you will have built a basic customer feedback survey conversational AI app. Just in case you haven’t visited yet, here is the link to the source code in the &lt;a href="https://github.com/arrrgr/customer-feedback-survey"&gt;GitHub repository&lt;/a&gt; again. &lt;/p&gt;

&lt;p&gt;If this tutorial was helpful, do let me know in &lt;a href="https://community.dasha.ai"&gt;Dasha developer community&lt;/a&gt; or at &lt;a href="mailto:arthur@dasha.ai"&gt;arthur@dasha.ai&lt;/a&gt;. If it was hard to understand, please do the same. Good luck and godspeed! &lt;/p&gt;

</description>
      <category>ai</category>
      <category>voice</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
