<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Snehasish Mishra on Medium]]></title>
        <description><![CDATA[Stories by Snehasish Mishra on Medium]]></description>
        <link>https://medium.com/@snehasish069?source=rss-b53639644721------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mjgpqzsh4UmOooeDDUZltQ.jpeg</url>
            <title>Stories by Snehasish Mishra on Medium</title>
            <link>https://medium.com/@snehasish069?source=rss-b53639644721------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 05:46:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@snehasish069/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Guide to Customer Experience Excellence in Enterprise Bots]]></title>
            <link>https://medium.com/saarthi-ai/building-enterprise-level-bots-a-guide-to-customer-satisfaction-38a9f0f4cf6f?source=rss-b53639644721------2</link>
            <guid isPermaLink="false">https://medium.com/p/38a9f0f4cf6f</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[enterprise-technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <dc:creator><![CDATA[Snehasish Mishra]]></dc:creator>
            <pubDate>Wed, 20 Nov 2019 08:30:51 GMT</pubDate>
            <atom:updated>2019-11-29T11:16:33.706Z</atom:updated>
            <content:encoded><![CDATA[<h3>Developer-Guide to Customer Experience Excellence in Enterprise Bots</h3><p>If you are just entering into the world of chatbot development, and have successfully built your first bots, this would be a perfect time to sharpen your chatbot development skills from the viewpoints of customer experience and conversational design.</p><p><em>In this blog, we are going to explore the know-hows of fine tuning our creativity of designing and building robust conversational interfaces.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjqPbycy3dj7afeaeD-JnA.jpeg" /><figcaption>How to build a chatbot with a robust conversational design?</figcaption></figure><p>Conversational AI is on the brink of augmenting customer service, sales and marketing functions with enterprise bots.</p><p>Studies show that by 2020, around 80% of enterprises will have been using customer service automation by deploying intelligent chatbots to provide their customers base a seamless experience with a smaller workforce.</p><p>By now, you must have come across a lot of chatbots on various platforms. Most of the chatbots today are click-based, implying most of the functionalities depend on <em>whether or not user taps the buttons</em> in place.</p><p>Some business bots even disable keypad to become intolerant towards “unhappy paths”. This makes the conversational design rigid and give customers a synthetic experience. It also exhibits the limited intelligence of the bots. Befittingly, 9 out 10 CXOs around the world think “Artificial Intelligence” driven bots needs to be smarter before they can be adopted.</p><p>The focus today is shifting towards Natural Language Understanding bots. It is appropriately termed as <strong>Conversational Agents</strong>. These agents provide us with a better platform by bringing chatbots closer to human interactions. This is what businesses all around the globe are looking for.</p><p><em>So, fasten your seatbelts… Let’s dive in!</em></p><p>In this blog, we shall be exploring the following topics —</p><p><strong><em>1. Conversational Design Guide</em></strong></p><p><strong><em>2. Real-time Typing Suggestions</em></strong></p><p><strong><em>3. Action Confirmation and Intent Suggestions</em></strong></p><p><strong><em>4. Human-in-the-Loop Conversational Design</em></strong></p><p><strong><em>5. Handling “Out of Domain” Utterances</em></strong></p><p><strong><em>6. Pre and Post Deployment Feedback</em></strong></p><h3>1. Conversational Design Guide</h3><p>As discussed above, we now understand that click-based chatbots have limited functionalities but are tolerant to misleading or out of scope conversations. Hence,</p><blockquote>Our primary focus must be to guide the user towards business paths.</blockquote><p>As a user gets introduced to a conversational agent, most of the information he/she has about the bot is its name and/or the website it is deployed on.</p><p>User is unaware of the tasks that are within the capability-scope of the bot. <em>This leads to overestimation or underestimation of the bot. </em>This is followed by misleading paths right from the start. As a result, bots often breakdown, much to chagrin of its developer, and starts uttering gibberish.</p><p>To avoid this mishap, the scope or the capability of the bot must be introduced to the user in its very first response.</p><p>Since capabilities are individual tasks, each may be shown as buttons as options for the user to enter each business path directly.</p><p><em>However, if the user does not choose to tap on any button and queries directly, the bot’s NLU must be robust enough to handle them explicitly. This is the first mark of conversational intelligence.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*XuB3MC-5auRajEpisK-Gmg.png" /><figcaption>The NLU engine has to be robust enough to handle queries that bypass the buttons</figcaption></figure><p>Apart from the conversation starter, we must choose to show buttons wherever the necessity is felt to provide the user with some options to choose from.</p><p>For example, if we are expecting approval of user as next input <em>Yes/No</em> buttons can be used. Same holds for cases where we would want the user to shift to a different business path to get his or her task done immediately.</p><p>We can advise the users to shift the path and show business path buttons for a convenient and seamless experience.</p><h3>2. Real-time Typing Suggestions</h3><p>This method is a technically advanced version of error handling as compared to others.</p><p><em>Whenever a user starts typing, text completion or automatic intent suggestions can be done.</em></p><p>This strategy would reduce the failure rate of your enterprise bot by a significant level. Most of the users do not prefer typing complete sentences for their issues/queries.</p><p>Hence, suggestions should be done to the users real-time whenever the sentence, being typed, has a relevancy rate above the threshold set (based on the scope for which enterprise bot is built).</p><p>This can be accomplished based on the following approaches:</p><p><strong>· Text Completion based</strong></p><p><strong>· Quick Reply based</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*12SQC4WPezgiajGm7923mA.jpeg" /><figcaption>Quick replies help not just guide an end-user, it also helps make the conversation more intuitive and improve CX</figcaption></figure><p>This reduces the users from unwillingly deviating from happy paths.</p><p>However, our chatbot must be foolproof when it comes to handling user’s intentions. The whole design and development would be futile if our chatbot is unable to comprehend the user’s intent.</p><h3>3. Action Confirmation and Intent Suggestions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*qvard3gKPdNfjDo8MBKAWw.png" /></figure><p>Each conversational agent has 3 major components: <em>Natural Language Understanding Engine (NLU)</em>, <em>Dialogue Manager</em> and <em>Action Scripts.</em></p><p>Dialogue manager is the core of our chatbot. As soon as a user utterance is received by our Dialogue Manager, it hits the <strong>NLU server</strong> to receive the predicted <em>intent</em> and <em>entities.</em></p><p>After successfully receiving NLU information of the predicted intent with confidence above the NLU threshold, the Dialogue Manager predicts the<strong> next action</strong> to be taken based on conversation stories or scenarios on which it is trained.</p><p>As per the above chatbot architecture, there are 2 primary breakpoints of our chatbot. Although we can efficiently reduce <em>failure cases due to conversation stories,</em> by rigorously testing each and every corner case, the <em>dependency on NLU accuracy</em> can never be ignored.</p><p>Any Enterprise would never accept a chatbot if it enters into a business action without the action being the actual motive of the user. One ought to be bumfuzzled if he asks a bot for its name, only to get an erroneous response with his account balance in a beautifully designed response.</p><p>To avoid such scenarios, it is good practice (as long as you have sufficient live data) to get confirmation from user before executing “critical” business actions. If the user denies the predicted action, then there should be suggestions displaying next predicted intents (Texts mapped to each intent) as <em>buttons</em> or <em>quick replies</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*JID5T4L2jKhyKwZ6mVto_A.jpeg" /><figcaption>Built in BotPreview</figcaption></figure><p>This approach can be best implemented by defining a “confirmation threshold” for the NLU response.</p><p>My balance please.</p><p>intent: &quot;ask_fundTransfer&quot; confidence: 0.67</p><p>If the predicted intent’s confidence lies within the range of <em>fallback threshold</em> (let’s assume 0.25) and <em>confirmation threshold</em> (let 0.8), we can then wish to go for action confirmation based on further logic.</p><p>However, this approach must be employed with great scrutiny, meaning, it is only to be used where its necessity is felt.</p><h3>4. Human-in-the-loop Conversational Design</h3><p>We know that Conversational AI is the key to winning customer loyalty in today’s market. But the question to be asked is, whether an Enterprise is willing to risk their customer interactions completely on conversational agents.</p><p>Of course NOT!</p><p>This is where Human Handoff comes into picture. This means handing over the control of our bot’s responses from Dialogue Manager to a custom Widget for the user to interact with a human agent to resolve its issue.</p><p>Once the chat is transferred to a live agent, all the previous conversations and the context of conversation in the current session must be displayed in the widget.</p><p>After the user’s issue is resolved by a human agent, the chat should be “<em>marked as done</em>” for our bot to take over the control of conversation again or terminate the session for the user or continue as the scenario demands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1aaGPyvbvXRWB6zRRFAaw.jpeg" /></figure><p>Following are the scenarios where you can expect to handover the chat to a live agent.</p><ol><li>User explicitly wants to chat with a human agent.</li><li>The confidence for NLU prediction is below threshold twice consecutively.</li><li>User agrees to chat with Human when we suggest to do so for some business actions.</li></ol><p>This creates a seamless experience for the users of our chatbot. Also, the enterprises would be satisfied that no user would return simply because of the incapabilities or mistakes due to complete dependency on Conversational AI.</p><p>This conversational flow also ascertains, to the satisfaction of a business, that no user would return simply because of a mistake that is due to the dependence of the bot on the NLU.</p><blockquote>I shall be writing about Human Handoff on a more detailed blog.</blockquote><h3>5. Bot Handling Out of Domain Utterances</h3><blockquote>A “complete” chatbot handles all possible paths, in and out of scope of the desired domain.</blockquote><p>Even if we guide the users towards business paths using the aforementioned ideas, our chatbot must have the capability to confidently classify when a user utterance is within its handling domains.</p><p>Further, if a query is within the domain of the bot’s understanding, the bot must be programmed to understand whether it is provisioned to resolve such queries. This is often subject to business requirements or limitations. Based on this, we can handle every corner case scenario of conversations.</p><p>Let’s have a look at few scenarios to understand better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*gXhyT41et9v5PzUdRSnF1w.png" /><figcaption>How to build a chatbot: In Domain but Out of Scope.</figcaption></figure><p>In this case, the user is asking for a refund. Let’s assume, we have built a bot for just booking flights. In this case, the query is within our domain, but out of our scope of handling.</p><blockquote><em>So, we just inform the user that we understood the concern but currently are not handling such cases, and therefore suggest to transfer to live chat.</em></blockquote><p>Similarly, the handling of utterances which are classified as completely out of domain, can be handled in the following approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*KSMUXLZocybV0fK7eo6YCw.png" /><figcaption>How to handle completely Out of Domain queries?</figcaption></figure><p>We simply show the bot’s capabilities whenever the user queries about something not in our domain to be handled. Of course, the bot must remember to be polite :)</p><p>This approach shall greatly handle the “bot-bullies” interacting with our enterprise bot, and I assure you, there are plenty.</p><h3>6. Pre and Post Deployment Feedback</h3><p>We perfectly know that feedback and suggestions exponentially improve any software being developed. Feedback incorporate a wider lens of the audience that actually puts the software to use.</p><p>Hence, there absolutely must be a mechanism to receive these feedback in our conversational agents too.</p><h4>* Pre Deployment Feedback Mechanism</h4><p>Once our bot is built, we add users to test it internally. During this phase, we can use a feedback system to store the last few conversations and the logged data in a database whenever a tester reports a bug.</p><p>This can be implemented by using an intent named <em>feedback</em> which would trigger an action that can perform the aforementioned task.</p><p>However, instead training any NLU for this intent, it must directly bypass the NLU engine, using “/feedback” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*ZmIxlZVJTMoI7BlMEsIO8Q.png" /><figcaption>Feedback from Internal Testers.</figcaption></figure><h4>* Post Deployment Feedback</h4><p>However, after deployment, we must remove the /feedback command and make our bot ready to accept feedback from users based on the conversational experience.</p><p>Again, there are various approaches to this, depending on the business for which bot developed.</p><p>One such approach would be to ask the user how satisfied he was with the query-resolution, after a business path comes to an end.</p><p>If the user is satisfied, then we proceed with normal flow. If unsatisfied, we may suggest for the correction to be made and store the data for releasing a more appeasing bot in the next iteration.</p><h3>Conclusion</h3><p>This article laid down certain criteria on which the CX and conversational robustness of any enterprise bot is based on. Essentially, any chatbot developer must understand the plausible loopholes in his conversational design, and address every corner case to bring robustness into the conversational flows.</p><p>Of course, there are various other ideas to implement before making our bot enterprise ready. Conversational AI is the emerging technology where all these magic happens. As the saying goes…</p><blockquote>The more a bot is capable of imitating a human, the more ‘intelligent’ it is considered.</blockquote><p>Keeping this statement in mind, we must design and develop our conversational agents (be it speech or text).</p><p>Hope you enjoyed the article.</p><p>Subscribe for my article. Follow our page on <a href="http://facebook.com/thesaarthi">Facebook</a> and <a href="http://linkedin.com/company/saarthi-ai">LinkedIn</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*UcrcRXbJ0Oday4QyX9AzYQ.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38a9f0f4cf6f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saarthi-ai/building-enterprise-level-bots-a-guide-to-customer-satisfaction-38a9f0f4cf6f">Guide to Customer Experience Excellence in Enterprise Bots</a> was originally published in <a href="https://medium.com/saarthi-ai">Saarthi.ai</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chatbot Development : Make conversations flawless with a Dialog Manager]]></title>
            <link>https://medium.com/saarthi-ai/how-do-automated-conversational-agents-learn-80d2c62e5594?source=rss-b53639644721------2</link>
            <guid isPermaLink="false">https://medium.com/p/80d2c62e5594</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[dialogue-manager]]></category>
            <dc:creator><![CDATA[Snehasish Mishra]]></dc:creator>
            <pubDate>Tue, 11 Jun 2019 13:26:53 GMT</pubDate>
            <atom:updated>2019-06-12T06:18:28.130Z</atom:updated>
            <content:encoded><![CDATA[<h3>Chatbot Development : Make conversations flawless with a Dialog Manager</h3><p>In your journey of chatbot development, you must have always wondered how chatbots converse so effectively. The conversations become so flawless that we almost forget that we are actually talking to an automated agent.</p><p>In this article, we are going to dive into conversational design, and how to make the agent learn example conversations for training the Dialogue Manager. So, let’s start our exciting journey of …</p><blockquote>How to Train your d̶r̶a̶g̶o̶n̶ 🅑🅞🅣 ? 🤖</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqDpfYx1DPxnrpK56mkqsA.jpeg" /></figure><p>Whenever we start building a conversational agent, we just have one thing in mind… “<strong><em>How to make our Bot most Human like?”</em></strong></p><p>Every conversational agent is built on two important components — Language Understanding and Dialogue Management System.</p><p>Language Understanding, also known as Natural Language Understanding (NLU) is the very first step of any agent. To know better about NLU, you can follow <a href="https://medium.com/saarthi-ai/road-map-to-chatbot-development-part-1-setting-up-nlu-severs-773087373458">this article</a>. Obviously, same as a human, the agent first needs to understand the user properly. Based on this understanding, the agent shall take further actions and provide suitable response back to the user. Here comes the role of a Dialogue Manager.</p><p>A Dialogue Manager keeps track of the current state of conversation. The NLU prediction results, latest utterance by user, slot information of the agent, etc. To know more about slots, <a href="https://medium.com/saarthi-ai/chatbot-development-context-variables-for-dialog-management-969390baac70">here’s</a> an article for reference.</p><p>We train the Dialogue Manager on example conversations in the form of stories. Every such story is some conversation translated into such a format that is understandable by the Dialogue Manager.</p><p>In this article, we are going to cover these topics —</p><h3><strong>1. Introduction to Policies<br>2. Types of Policies<br>3. Configuring Policies<br>4. Role of Policies in Dialogue Training</strong></h3><h3>1. Introduction to Policies</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*vFeQ3ir1Tkk7nsBdIqJrMA.jpeg" /><figcaption>Am I talking to a bot or another human? 🤔</figcaption></figure><p>In simple terms, Policy is nothing but Rules based on which we train our Dialogue Framework to learn the input data provided in the form of example conversations. These conversations are termed as stories, which consists of information about intent from the user, actions to be taken and the events before and after each action.</p><p>Now, to make the agent learn from such conversations, there must be a set of rules following which the agent can be trained. Focusing on various parts of the conversations, different policies are used in any Dialogue Manager.</p><p><em>For understanding better, we are going to have a look at </em><a href="http://rasa.com/docs/"><em>Rasa</em></a><em>. Rasa has just released the latest version — Rasa 1.0. An open-source framework for NLU and Dialogue Management System.</em></p><p>Rasa uses a configuration file which is written in <em>yml</em> format, and the configuration pipeline of NLU and Core (Dialogue Framework) are specified appropriately under separate keys.</p><p>Let’s now understand various types of Policies.</p><h3>2. Types of Policies</h3><p>There are various types of policies that have been implemented in the Dialogue Framework, to train on stories for making predictions about what actions to take next.</p><blockquote>a) Keras Policy<br>b) Memoization Policy<br>c) Fallback Policy<br>d) Form Policy<br>e) Mapping Policy<br>f) Two-Stage Fallback Policy</blockquote><h4>a) <em>Keras Policy</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*FA3HTqRGvuYgqzEf6S8NBQ.jpeg" /><figcaption>Context Matters!</figcaption></figure><p>This policy uses Neural Networks implemented in Keras for predicting the next best action by the agent. It uses <a href="https://colah.github.io/posts/2015-08-Understanding-LSTMs/">Long Short Term Memory (LSTM)</a> architecture by default. LSTM is used so that, the agent learns from the conversational history, without losing context.</p><p>We can also make changes to the featurizer of this policy by setting different parameters in the configuration file itself. The featurizer being used is self-explanatory — <em>MaxHistoryTrackerFeaturizer. </em>We can change the max_history parameter to an integer, as shown below. History in this case is nothing but number of steps in the conversation that we want our agent to consider before predicting any action going further. Each “step” here means either a previously predicted action, intent classified from NLU, or any other event such as a <em>slot set</em> event.</p><pre>policies:<br>  - name: &quot;KerasPolicy&quot;<br>    featurizer:<br>    - name: MaxHistoryTrackerFeaturizer<br>      max_history: 5</pre><p>This feature can be used to give a personality to our agent. The following story example might help you understand better.</p><pre>* ask_bot_name<br>   - utter_name<br>* ask_bot_name<br>   - utter_its_still_the_same</pre><p>Suppose, the user is continuously asking the bot’s name a lot of times, we can make our agent learn that whenever the user asks for its name thrice consecutively, the bot can give a different response other than simply answering its name.</p><pre><strong>User</strong>: may i know your name?<br><strong>Bot</strong>: I am Xia.<br><strong>User</strong>: what’s your name?<br><strong>Bot</strong>: I just said it. It’s still Xia. Hasn’t changed yet! 😀</pre><p>You must now be thinking how cool a feature this is, and surely, increasing <em>max history</em> parameter to a high number should be a great idea<em>. </em>However, the problem is that it would make the model unnecessarily huge and our bot will be highly dependent on the history. Hence, we avoid that and instead use <a href="https://medium.com/saarthi-ai/chatbot-development-context-variables-for-dialog-management-969390baac70">slots</a> to retain necessary pieces of information for processing later on.</p><h4>b) Memoization Policy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*dpf1i7kBOc6ZShpO1CNEXQ.png" /><figcaption>Let me memorise these scenarios!</figcaption></figure><p>It is the simplest of policies. As the name suggests, this policy predicts the next action by memorizing the conversation present in the training data.</p><p>It also has the parameter of <em>max_history </em>that can be set by us.</p><pre>policies:<br>  - name: &quot;MemoizationPolicy&quot;<br>    max_history: 5</pre><p>Keep in mind, that the <em>max_history</em> parameter is in the Keras Policy as well. There must be no confusion that both the policies work differently even though there is a common parameter between them.</p><p>Keras Policy is like teaching our bot from past incidents and predict properly in future whereas, Memorization Policy is nothing but providing the bot with a book about example conversation and instructing it to predict by finding answers only from the book.</p><h4>c) Fallback Policy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*4Y7CaFn9pzI0cRJNk09iyg.png" /><figcaption>Oh crap! What to do now?</figcaption></figure><p>Whenever the agent fails, it is termed as fallback. There are mainly two cases when the agent fails — NLU prediction is of low confidence or the action prediction is of low confidence.</p><p>In this policy, we configure both the thresholds (for both cases of failure above). These are termed as NLU threshold and Core threshold.</p><p>Now, whenever fallback takes place, there must be some action that needs to be executed. This action has to be mentioned in the configuration file as well.</p><pre>policies:<br>  - name: &quot;FallbackPolicy&quot;<br>    nlu_threshold: 0.3<br>    core_threshold: 0.3<br>    fallback_action_name: &#39;action_default_fallback&#39;</pre><p>Here, <em>action_default_fallback</em> is an already implemented action. If we want to use our own action, we can provide the action’s name in the appropriate place.</p><pre><strong>User</strong>: sdfs ifgk thsr<br><strong>Bot</strong>: Sorry I could not get what you are trying to say. Please be more specific.</pre><h4>d) Form Policy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*N-5h5xd7IVED4QZHJbZTtw.jpeg" /><figcaption>Hey hooman! I need some details from you.</figcaption></figure><p>Form Policy is another twist to the Memorization Policy. In a conversation, there are scenarios where a bot needs the user to input information. To get these pieces of information, the bot needs to ask various questions, and get the information from the user.</p><p>There is also a need to validate the information the user provides. Further, the bot must not repeat questions regarding already extracted information. To facilitate this, a separate action called <em>FormAction</em> comes into the picture.</p><pre>policies:<br>  - name: &quot;FormPolicy&quot;</pre><p>Hence, whenever a Form is initiated, the Form Policy is used. This policy takes care of understanding regarding what part of a conversation needs a separate flow. This policy will continuously keep on asking the user until all the information is successfully extracted by the bot.</p><pre><strong>User</strong>: I would like to book a hotel in Mumbai.<br><strong>Bot: </strong>And for how many days are you planning to stay?<br><strong>User: </strong>umm. 3 days.<br><strong>Bot: </strong>Sure. For what date should I look to check-in?<br><strong>User: </strong>this Friday.</pre><h4>e) Mapping Policy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*Hugb2qtnpid2iIRTORWNhA.png" /><figcaption>Let me greet back since you are greeting me.</figcaption></figure><p>This is a very interesting policy. Using this policy, we can set some intents to trigger a fixed action without taking into consideration the dialogue context.</p><p>Suppose, we want to respond to the user whenever the <em>out_of_scope </em>intent is classified by NLU. This <em>out_of_scope</em> utterance might pop up anytime in the middle of conversation and it is not viable to write all possible stories for such scenarios.</p><p>The simpler way to deal with this is by mapping the <em>out_of_scope </em>intent to a particular action called <em>action_apologize</em>.</p><p>This can be done by mapping the intent defined in our domain file of the Dialogue Manager.</p><pre>intents:<br> - out_of_scope:<br>     triggers: action_apologize</pre><p>An intent can be mapped to at most only a single action. Once, the intent is predicted by the NLU, the action, if any, mapped to that intent will be triggered automatically.</p><pre><strong>User</strong>: I would like to book a hotel in Mumbai.<br><strong>Bot: </strong>And for how many days are you planning to stay?<br><strong>User: </strong>umm. 3 days.<br><strong>Bot: </strong>Sure. For what date should I look to check-in?<br><strong>User: </strong>You are beautiful Xia.<br><strong>Bot: </strong>Thanks! Beauty is in the eye of beholder.😉 <br>     When are we checking in?<br><strong>User: </strong>this Friday.</pre><p>If it is necessary that the off-topic conversation doesn’t affect the dialogue history, it can be done by returning a <em>UserUtteranceReverted() </em>event in the action code. This will revert the bot to previous state after executing the desired mapped action.</p><pre><strong>class</strong> <strong>ActionApologize</strong>(Action):<br><br><strong>def</strong> name(self):<br>    <strong>return</strong> &quot;action_apologize&quot;<br><br><strong>def</strong> run(self, dispatcher, tracker, domain):<br>    dispatcher.utter_template(&quot;utter_apologize&quot;, tracker)<br>    <strong>return</strong> [UserUtteranceReverted()]</pre><h4>f) Two-Stage Fallback Policy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*MzI76jsBFfCw5pCgdO8nbg.gif" /><figcaption>Calm down.. I got this!</figcaption></figure><p>This is the sophisticated version of Fallback Policy. In our configuration, we can either include FallbackPolicy or TwoStageFallbackPolicy, but not both.</p><p>This policy deals with fallback in two stages —</p><p>In the first stage, if fallback occurs with low confidence of some intent, the user is asked for confirmation if that intent was meant. If the user affirms, then normal conversation resumes. If denied by user, then the bot asks its user to rephrase for a better understanding.</p><p>After the user rephrases the utterance, if some intent is classified with high confidence, then no fallback occurs and dialogue continues normally.</p><p>But, if the rephrased utterance is not classified with high confidence, then second stage fallback starts. The bot again asks the user to confirm the intent. If affirmed by user, then the story continues as if this had been the intent since beginning of fallback. If denied by the user again in this stage too, then there is some intent which is assigned forcefully (<em>deny_suggestion_intent_name</em>). Human-hand-off generally occurs in such scenarios, where the bot transfers the chat to a live agent who can further assist the user.</p><pre>policies:<br>  - name: TwoStageFallbackPolicy<br>    nlu_threshold: 0.3<br>    core_threshold: 0.3<br>    fallback_core_action_name: &quot;action_default_fallback&quot;<br>    fallback_nlu_action_name: &quot;action_default_fallback&quot;<br>    deny_suggestion_intent_name: &quot;out_of_scope&quot;</pre><p>While configuring this policy, there is an extra provision of explicitly specifying core and NLU fallback actions —</p><p><em>fallback_core </em>is when action could not be predicted with a confidence higher than <em>core_threshold</em>.</p><p><em>fallback_nlu </em>is when intent prediction could not be done with confidence higher than <em>nlu_threshold.</em></p><p>After fallback for two times consecutively, the intent prediction will be <em>out_of_scope </em>intent. We can then write in our story that whenever the intent is <em>out_of_scope, </em>action to be taken is <em>action_human_handoff.</em></p><pre>* out_of_scope<br>   - action_human_handoff</pre><p>Here is a conversation to understand it better —</p><pre><strong>User</strong>: what is my uncle&#39;s name?<br><strong>Bot: </strong>Sorry. Did you mean your name?<br><strong>User: </strong>No<br><strong>Bot: </strong>Could you be more specific?<br><strong>User: </strong>what&#39;s my own uncle&#39;s name?<br><strong>Bot: </strong>Sorry. Did you mean your name? <br><strong>User: </strong>Nope.<br><strong>Bot: </strong>I am sorry. I am unable to help with this.<br>     Would you like me to connect you to a live agent?</pre><h3>3. Configuring Policies</h3><p>Even though all the policy configuration is separate under each topic, it is now required to combinedly specify index <em>policy</em> key in config.yml file.</p><pre>policies:<br>  - name: &quot;KerasPolicy&quot;<br>    featurizer:<br>    - name: MaxHistoryTrackerFeaturizer<br>      max_history: 5<br>  - name: &quot;MemoizationPolicy&quot;<br>    max_history: 5<br>  - name: &quot;FormPolicy&quot;<br>  - name: TwoStageFallbackPolicy<br>    nlu_threshold: 0.3<br>    core_threshold: 0.3<br>    fallback_core_action_name: &quot;action_default_fallback&quot;<br>    fallback_nlu_action_name: &quot;action_default_fallback&quot;<br>    deny_suggestion_intent_name: &quot;out_of_scope&quot;</pre><p>This file is then saved and used for our Dialogue Manager training.</p><h3>4. Role of Policies in Dialogue Training</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*wWvsneOyfkklqFDbB1jL-A.png" /><figcaption>Yipee! I am done with my studies. Ready for the exam.</figcaption></figure><p>All the policies mentioned in the configuration file predict the next action separately and then the result of all the predictions are ensembled to get the final next action to be taken. The importance of each policy is explained in a detailed manner under each policy type.</p><p>All the policies are nothing but some rules and regulations following which we want our conversational agent to learn the dialogues appropriately. If a particular part of dialogue is not predicted appropriately, then we can further tune the policy configurations based on the quantity and quality of stories that we have for our agent.</p><h3>Conclusion</h3><p>In this article, we learnt how various policies help the Dialog Manager keep the state of the conversation, and predict the next step of action to keep the pertinence of the conversation in a useful manner.</p><p>We also learn how, in cases where the intent of the user-utterance isn’t predicted correctly, the robust conversational design allows the bot to fallback and prompts the user to rephrase, to help it understand the user’s utterance better.</p><p>An important point to be noted is, for further betterment and enhancement of action prediction, the stories on which our dialogue manager is trained need to be appropriate. Again, to remind you, stories are nothing but the dialogues written in a format understandable by the conversational agent.</p><p><strong><em>For more articles on conversational agents, NLP and deep learning, follow our blog from the link below.</em></strong></p><p><a href="https://medium.com/saarthi-ai">Saarthi.ai</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80d2c62e5594" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saarthi-ai/how-do-automated-conversational-agents-learn-80d2c62e5594">Chatbot Development : Make conversations flawless with a Dialog Manager</a> was originally published in <a href="https://medium.com/saarthi-ai">Saarthi.ai</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Road Map to Chatbot Development Part 1 ( Getting Started with Language Understanding )]]></title>
            <link>https://medium.com/saarthi-ai/road-map-to-chatbot-development-part-1-setting-up-nlu-severs-773087373458?source=rss-b53639644721------2</link>
            <guid isPermaLink="false">https://medium.com/p/773087373458</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Snehasish Mishra]]></dc:creator>
            <pubDate>Thu, 11 Apr 2019 05:52:17 GMT</pubDate>
            <atom:updated>2019-04-11T13:27:43.930Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Ultimate Road Map to Chatbot Development — <strong>Part 1 (Getting Started with Language Understanding)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Y0m1zcq4cdCWLuFFLB-7oQ.jpeg" /><figcaption>Developing a Truly Conversational AI agent… Hmm 🤔</figcaption></figure><p>Conversational AI has been a field of intense research for past few years, and the vast amount of convenience it promises, definitely labels it as the <strong>NEXT BIG THING! </strong>🔥</p><p>Much of the progress in the Natural Language Understanding can be attributed to advancements in deep learning and NLP, and convenient access to high-end computational resources.</p><p>Being a Language Understanding company, <a href="https://saarthi.ai/"><em>Saarthi.ai</em></a> is building multilingual conversational agents to serve a simple motto —</p><blockquote>Diminishing the intelligence-gap between humans and conversational agents.</blockquote><p>This series of articles aims at helping you understand the underlying elements involved in chatbot design, and the process of chatbot development, by implementing a bot in python.</p><h3>Outline</h3><blockquote>How does a Bot think?</blockquote><blockquote>Domain Identification</blockquote><blockquote>Training Data for NLU</blockquote><blockquote>Training and Evaluation</blockquote><blockquote>Setting up NLU server</blockquote><blockquote>How to make NLU better?</blockquote><h3>1. How does a Bot think?</h3><p>For building any conversational agent, the most crucial part is understanding what the user is conveying. <em>Natural Language Understanding</em> (<strong>NLU</strong>) plays an important role in this aspect. After this, to actually build a bot, a <em>Dialogue Framework</em> needs to be chosen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*_7TfOMHqn87efUCWzjuyTQ.jpeg" /><figcaption>The flow of information through a Natural Language Understanding Engine and Dialog Framework</figcaption></figure><p>Whenever a user utters queries to our conversational agent, the first task is to classify the intention of the user utterance (<em>intent</em>) and alongside extract out important information present in the utterance (<em>entity</em>). A lot of additional tasks can be carried out in parallel, such as <strong>emotion classification</strong> (<em>to check the mood of the user</em>), <strong>order request classification</strong> and many more.</p><p>Once the conversational agent understands complete detail about the user utterance, it uses a Dialogue Framework to <strong>predict the actions</strong> to be carried out next. And then, that particular action is executed (may involve database fetch or API calls) to provide the desired response back to the user.</p><h3>2. Domain Identification</h3><p>Let us dive right into what we are eagerly waiting for…</p><p><em>Let’s build a bot </em>😃</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xt9HbEP_aX0Xyd3F2K_PYA.gif" /><figcaption>Highly caffeinated fingers ready to roll</figcaption></figure><p>We will start with a basic version of <strong>Payment Bot</strong> in <strong>Hindi</strong>.</p><p>The first step is to identify the domain of the bot. As discussed, two important aspects of NLU are <em>Intents </em>and <em>Entities.</em></p><p><strong>Intents </strong>are the different categories of utterances to classify what the user could mean while conversing with the bot. Whereas, <strong>Entities </strong>are important information present in an utterance from user.</p><p>For example, let the user utterance be —</p><blockquote>“मुझे <strong>दिल्ली</strong> के लिए एक फ्लाइट बुक करनी है।”</blockquote><p>Clearly, the user intends to <em>book a flight</em> and also has provided the <em>destination</em> which is <em>Delhi. </em>Therefore, the following can be concluded.</p><blockquote><strong>“intent”</strong>: “book_flight”<br><strong>“entities”</strong>: {<strong>“destination”</strong> : “दिल्ली”}</blockquote><p>Let us narrow down our domain primarily focusing on a bot that can validate user’s mobile number, and show the current wallet balance. There are obviously some <em>general intents</em> needed for every domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*cKsnDOgQSBM8SZ1U5UPssQ.png" /><figcaption>Building domain level understanding for Chatbot Development</figcaption></figure><blockquote>At <a href="https://saarthi.ai/">Saarthi.ai</a>, we use our chatbot development platform to train the NLU models as per the required configurations. There is also a data tagging tool which facilitates multiple members in the Data Team to write intent utterances conveniently tagging the entities. But, since the work is at pre-release stage, let me explain using another commonly used open-source chatbot framework ‘RasaNLU’ , to walk you through the process of building a bot. We shall learn how to tweak some configurations in RasaNLU to make it perform better for our use case.</blockquote><h4>Installation</h4><p>We will be installing RasaNLU open-source framework for NLU training.</p><p>First make sure, your system has <a href="https://www.digitalocean.com/community/tutorials/how-to-install-anaconda-on-ubuntu-18-04-quickstart">Anaconda</a> setup with the latest stable version.</p><pre>## create a new conda environment<br><strong>$ </strong>conda create -n rasanlu python==3.6.1<br><strong>$ </strong>conda activate rasanlu</pre><pre><strong>$ </strong>git clone <a href="https://github.com/RasaHQ/rasa_nlu.git">https://github.com/RasaHQ/rasa_nlu.git</a><br><strong>$ </strong>cd rasa_nlu<br><strong>$ </strong>pip install -r requirements.txt<br><strong>$ </strong>pip install -e .</pre><pre><strong>$ </strong>pip install rasa_nlu[spacy]<br><strong>$ </strong>python -m spacy download en_core_web_md<br><strong>$ </strong>python -m spacy link en_core_web_md en<br><strong>$ </strong>pip install rasa_nlu[tensorflow]</pre><blockquote>Always prefer cloning the projects and installing from your local file system to make sure you can edit the source code according to your requirements.</blockquote><h3>3. Training Data for NLU</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*tvw0kR2riWBXLBWSVeaL1Q.gif" /><figcaption>Preparing training data for your chatbot usecase</figcaption></figure><p>After the NLU domain is finalized, enters the cumbersome (as any developer might think 😏) task of preparing data for training the NLU. But, once the NLU server is up and running with acceptable accuracy for classification task, a huge hindrance is avoided 😃, which is usually coding the actions for the bot using any Dialogue Framework.</p><p>The training data needs to be prepared in Rasa format since we are using RasaNLU here. Markdown (md) format is shown as an example.</p><p>Please do have a look at <a href="https://rasa.com/docs/nlu/dataformat/">training data format</a> used in Rasa.</p><pre><strong>##</strong> intent:inform<br>- मेरा मोबाइल नंबर [9412312345](mobile) है<br>- [70014512345](mobile)<br>- ओ. टी. पी. [2343](otp) <br>...</pre><pre><strong>##</strong> intent:show_wallet_balance<br>- मेरा बैलेंस कितना है    <br>- मेरे पैटीएम् वॉलेट में कितनी धनराशि है<br>...</pre><blockquote>While writing the utterances, it is a good practice to write them as an end-user of the bot.</blockquote><p>Similarly, write the utterances for each intent present in the domain. Since we are going to use “<em>tensorflow embedding</em>” pipeline of Rasa, it is important to have <strong>distinct utterances</strong> of each intent in the final training data. Also, there must be at least <strong>40 utterance examples</strong> to make sure we have enough test data to evaluate our model.</p><p>With these points in mind, once the dataset is finalized, CONGRATS! 👏👏You have overcome the initial hurdle. Although there will be iterations on the NLU training data, for now you are all set to move towards training and evaluating the NLU.</p><h3>4. Training and Evaluation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*M7W_h805deiOiyO2BMXdxg.gif" /><figcaption>Time to check how conversant you are!</figcaption></figure><p>Before starting the training phase, there are few hacks that needs to be done in order to train on Hindi data.</p><p>Let us download a <a href="https://spacy.io/models/xx">multi-language model</a> from <strong>Spacy</strong>. Then link the short-form ‘hi’ (for Hindi) to this model. Make sure the NLU environment is activated and then use the following commands shown below.</p><pre><strong>$</strong> python -m spacy download xx_ent_wiki_sm<br><strong>$</strong> python -m spacy link xx_ent_wiki_sm hi</pre><p>We need to add a config file for training our Hindi dataset on RasaNLU. The configuration we are going to use is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c30dc710e204dcf9cba72e1ad6ffc190/href">https://medium.com/media/c30dc710e204dcf9cba72e1ad6ffc190/href</a></iframe><p>Save the above lines as ‘config_tensorflow.yml’. Move the file into <em>rasa_nlu → sample_configs </em>directory where all the other predefined config files are saved.</p><p>Before we proceed towards training, have a look at the <strong>token pattern</strong> and <strong>max_ngram</strong>. <em>Token pattern</em> is regex defining tokens that are considered. The default regex by Rasa ignores words with single character, which might be a problem for languages apart from English. Hence, the token pattern is changed as shown above.</p><p><em>max_ngram</em> defines the maximum number of consecutive words that can be considered together during featurization. Generally <em>max_ngram </em>performs well when set to 3. But there is an option to evaluate each and every model and finding out the best model.</p><p>Now, it’s time to <strong>train</strong> the NLU using this config file. But before that just one last step, separate out 10% of the utterances for each intent and create another test dataset for evaluation task.</p><pre><strong>$</strong> python -m rasa_nlu.train \<br>         --config sample_configs/config_tensorflow.yml \<br>         --data &lt;path to your training data file&gt; \<br>         --path models \<br>         --fixed_model_name nlu \<br>         --project paytmbot --verbose</pre><p>Once the model is successfully trained, let’s <a href="https://rasa.com/docs/nlu/evaluation/"><strong>evaluate</strong></a> our trained model.</p><pre><strong>$</strong> python -m rasa_nlu.evaluate \<br>         --data &lt;path to test data set&gt; <strong>\</strong><br>         --model models/paytmbot/nlu</pre><blockquote>You might run into <strong>TclError </strong>because of the command line. Fix it using <a href="https://stackoverflow.com/questions/37604289/tkinter-tclerror-no-display-name-and-no-display-environment-variable">this link</a>.</blockquote><h3>5. Setting up NLU server</h3><p>Great! 😁</p><p>So, now we are almost done with our NLU. All we need is to run a <a href="https://rasa.com/docs/nlu/config/"><strong>server</strong></a> locally and test some of our own utterances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*oiQ07aGVu4ZwzHvgDTIBIQ.gif" /><figcaption>Almost done now! Let’s get the server running.</figcaption></figure><pre><strong>$</strong> python -m rasa_nlu.server -c sample_configs/config_tensorflow.yml --path models --port &lt;port number&gt;</pre><p>Open up the browser to check the NLU server.</p><pre>localhost:&lt;port number&gt;/parse?q=”&lt;example_utterance&gt;”&amp;project=paytmbot&amp;model=nlu</pre><p>You can also use curl from terminal:</p><pre><strong>$</strong> curl -XPOST localhost:&lt;port no&gt;/parse -d &#39;{&quot;q&quot;:&quot;&lt;example_utterance&gt;&quot;, &quot;project&quot;:&quot;paytmbot&quot;, &quot;model&quot;:&quot;nlu&quot;}&#39;</pre><h3>6. How to make NLU better? 💪</h3><p>Now you might have noticed that the entity <em>number</em> is not that appropriate for our use case. Because number could mean <em>OTP, mobile number, </em>or any other random number.</p><p>One way to classify this is by creating an <strong>external NLU layer </strong>through an API which makes <a href="https://github.com/facebook/duckling">duckling calls</a> to perfectly extract phone number separately. There are a lot of other types of entities that duckling can extract such as <em>emails, names, distance, time </em>and many more in multiple languages.</p><p>Even if there is no external NLU layer, there is nothing to worry about. To complete the payment bot, we shall be using slots and validate the <em>number</em> entity that has been extracted to differentiate among <em>OTP, mobile, </em>etc. (<em>more on this in the next part</em>).</p><p>Apart from using an API, there are various other tips that will help you to improve the performance of NLU. Needless to say, the most important component is <strong>data</strong>. If the training data for NLU is clean and contextual then the classification performs much better.</p><p>One more thing you can do is to host the NLU server on <strong>Apache</strong>. It helps in reducing the lag after deployment.</p><p>If you are reading this part, by now you must be having a NLU server up and running in your desired port. Congratulations! 🎉</p><p>In the next article, we shall dive into further development of this bot using a dialog framework to design stories and train our model to predict the next action.</p><blockquote>Hopefully, this article has allowed you to get hands-on with setting up your own NLU server and testing the accuracy of language understanding.</blockquote><h4>If you liked this article, don’t forget to give us a clap.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*ckcO1jugSFFKI3DZvDYg2Q.gif" /><figcaption>Two Claps! Three Claps! Four Claps! Forty 👏👏</figcaption></figure><p><a href="https://twitter.com/saarthi_ai/status/1116044577373335557"><strong><em>This article is subject to an update after the community release of our platform.</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=773087373458" width="1" height="1" alt=""><hr><p><a href="https://medium.com/saarthi-ai/road-map-to-chatbot-development-part-1-setting-up-nlu-severs-773087373458">Road Map to Chatbot Development Part 1 ( Getting Started with Language Understanding )</a> was originally published in <a href="https://medium.com/saarthi-ai">Saarthi.ai</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>