Building a chatbot, pt. 2: Conversations

Tags: chatbot, ai, neuralnetwork
Published: 2021-06-09 10:07:18

<p>Everybody has met or talked to a person that had a script to follow. Insurance salesmen, dealers, receptionists… All
    these people were given a script to follow, a checklist to go through, or just a simple answer to give when asked.
    Not unlike a chatbot.</p>
<p>In the previous article, I described a chatbot that we built for making reservations. Not much was said about the
    inner works or about its potential. There are indeed multiple topics to cover. In this article, I would like to talk
    a bit about conversations and conversation flow.</p>
​
<h2>AI?</h2>
<p>Our application is designed to fulfill users’ requests. A user usually has a general idea about what he or she wants
    to achieve. But even the most knowledgeable user can’t possibly know every item and variations that the application
    needs to achieve a goal. Even if the user is not sure what the right way to ask is, the chatbot should be able to
    guide the user and in the end, find exactly what the user desires, and then fulfill his request. For each request,
    the bot should have a list of instructions to follow - information that the user has to provide so that the
    application is able to execute the user's command.</p>
<h2>Illusion of choice</h2>
<p>To provide a good user experience, we decided to leave the first step to the user. The user’s first sentence gives us
    a direction to follow and an idea of the user’s intent, but actually, this is the last time a user is in command of
    the conversation flow. From this point on, every step of the conversation is directed by the application. The bot
    knows what checklist it has to follow to fulfill the request. Even if the user is not specific or not sure what to
    say, the bot should be able to get this information from the user with properly constructed questions.</p>
<p>Every conversation in our application is directed by a set of checklists. These checklists can be simple, even just
    one item, or they can spawn other checklists, and even create cyclic conversations. What exactly we are able to
    create with these types of checklists will be described in a separate blog. For now, let’s focus on the following
    example.</p>
​
<h2>From a conversation to a checklist</h2>
<p>Let’s meet our example user: Joe. Joe is working an office job and has multiple meetings per day. For those, he needs
    to schedule reservations in a call booth or a meeting room with his colleagues. At the start of the week, he knows
    about two meetings that will take place. One today (for the sake of this example let’s assume it is Monday) and one
    tomorrow. Interaction with the bot will then look like this:</p>
​
<p>
    <strong style="color:#381457">User</strong> : <em>Book me a room for today from 11:30 to 12:30</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Alright! Do you want to book a specific meeting room or should I
    just book you one that is free?</em><br>
    <strong style="color:#ffed00">Options</strong> : <em>Any meeting room, Specific meeting room</em><br>
</p>
​
<p>For today's meeting Joe has a remote call with colleagues from out of town, therefore any available room will do the
    trick. He will select “any meeting room” from the options given. If there is an available room in the system, Joe
    will get one. Like this:</p>
​
<p>
    <strong style="color:#381457">User</strong> : <em>Book me a room for today from 11:30 to 12:30</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Alright! Do you want to book a specific meeting room or should I
    just book you one that is free?</em><br>
    <strong style="color:#381457">User</strong> : <em>Any meeting room</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>I have booked room R.332 for today from 11:30 to 12:30 for you</em><br>
</p>
​
<p>And that's it. Joe has booked a room for a given time. From a user's point of view this is quite easy. Using our
    mobile applications, Joe can even use voice input!. This is all great, but how does it work?</p>
​
<p>To make a reservation, the chatbot needs to pass a checklist. For the example above, where the user is making a room
    reservation, the checklist looks like this:</p>
<ul>
    <li>Intent - make a booking</li>
    <li>What (seat, room, call booth)</li>
    <li>Where (any available room, or does the user want a specific room?)</li>
    <li>When (date and time, or duration of the meeting)</li>
</ul>
​
<p>Joe knew most of these and intuitively created a sentence that matched his wishes best. What was not explicit in the
    first sentence, the bot asked for in the follow-up question. When asking follow-up questions, chatbot usually gives
    users multiple options to select from. These suggestions give the user an idea of how to respond and also what kind
    of information the bot is expecting. In the same answer, the user can also write additional information.</p>
​
<p>Now let's say that Joe needs a specific room for a meeting that takes place on Wednesday. He needs a big interactive
    board, a projector and a room for 10 people where he will introduce new products to customers. This room is quite
    busy so he needs to find a spot for his meeting. The conversation could look like this one:</p>
​
<p>
    <strong style="color:#381457">User</strong> : <em>When is room R.121 available?</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>For which date(s) do you want to see the room's
    availability?</em><br>
    <strong style="color:#381457">User</strong> : <em>Wednesday</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>How long will you need the room for?</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>I will find you times, where there is enough space for your
    meeting. For example: 1 hour 30 minutes or just like 15 minutes</em><br>
    <strong style="color:#381457">User</strong> : <em>2 hours</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Alright.</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>The room R.121 is available on wednesday from 9:00 to
    13:59.</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Do you want to book it?</em><br>
    <strong style="color:#381457">User</strong> : <em>Yes</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Ok, can you specify the time for me please?</em><br>
    <strong style="color:#381457">User</strong> : <em>10:00</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>I have booked room R.121 on wednesday from 10:00 to 12:00 for
    you.</em><br>
</p>
​
<p>That's a slightly different conversation, right? But in the end, Joe will have his reservation ready. So what does
    the checklist on the bot’s side look like for this example?</p>
​
<ul>
    <li>Intent - check availability</li>
    <li>What - specific place to check</li>
    <li>When - time-frame to check</li>
    <li>How long - meeting duration</li>
    <li>To book it or not</li>
</ul>
​
<p>Up to this point Joe has only checked for available time slots. If he wants to make a booking now, he can. For
    booking, the chatbot has a different checklist. That one was previously listed, but here it is again for
    completion:</p>
​
<ul>
    <li>Intent - make a booking</li>
    <li>What (seat, room, call booth)</li>
    <li>Where (any available room, or does the user want a specific room?)</li>
    <li>When (date and time, or duration of the meeting)</li>
</ul>
​
<p>Most of these parameters are already checked for the booking. Joe has already told the bot to look for a specific
    room. He’s even given it a date so the only thing missing is the time. Joe gave the bot a meeting duration when he
    was checking for room availability. Now if Joe selects only the start of the meeting, the application already knows
    the duration and so it will make the booking last 2 hours.</p>
​
<p>But wait! That’s not all. Up to this point, all user’s requests had no problems. Let's say that our Joe has had a
    long vacation, he is back in the office again, but lost track of dates:</p>
​
<p>
    <strong style="color:#381457">User</strong> : <em>Book</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Do you want me to book you a seat or a meeting room?</em><br>
    <strong style="color:#381457">User</strong> : <em>Meeting room</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Alright do you want to book a specific meeting room or should I
    just book you one that is free?</em><br>
    <strong style="color:#381457">User</strong> : <em>What is available?</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>For which time frame(s) do you want to see available
    rooms?</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>You can tell me any time you want or you can use one of shortcuts
    bellow.</em><br>
    <strong style="color:#381457">User</strong> : <em>20.3.2008</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Unfortunately you cannot book or check seat availability in the
    past.</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Please tell me a time or a time range you want to see available
    rooms for.</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>For example: Today, Tomorrow, Thursday, 24.10. or something like
    next week or from 10:30 to 11:15</em><br>
    <strong style="color:#381457">User</strong> : <em>Ok what about tomorrow?</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Here is a list of available meeting rooms in your preferred area
    for tomorrow:</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>1. R.121</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>1. R.122</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>1. R.123</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>1. R.124</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>1. R.125</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>These are the first ones I found. But there are some more.</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Do you want to have some of these? You can also tell me, which
    specific one do you want to have</em><br>
    <strong style="color:#381457">User</strong> : <em>Yes</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Alright</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>What room would that be?</em><br>
    <strong style="color:#381457">User</strong> : <em>R.124</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>Can you specify the time for me please?</em><br>
    <strong style="color:#381457">User</strong> : <em>From 10:00 just for a quick call</em><br>
    <strong style="color:#9d9d9d">Bot</strong> : <em>I have book room R.124 for tomorrow from 10:00 to 10:30 for
    you.</em><br>
</p>
​
<p>Even in case of a longer conversation and with an invalid date, the bot was able to provide Joe with a
    reservation.</p>
​
<p>Again, I will show you the checklist that the chatbot had to go through:</p>
<ul>
    <li>Intent - make a booking</li>
    <li>What - meeting room</li>
    <li>Specification:<br>
        <ul>
            <li>Check available meeting rooms</li>
            <li>When - with validation</li>
            <li>Want to book one?</li>
        </ul>
    </li>
    <li>Specific room selection</li>
    <li>When - with specific time selection</li>
</ul>
​
<h2>Think in checklists</h2>
<p>The main point of these examples is to introduce the checklist philosophy. Every conversation that we have in the
    system is designed as a checklist with multiple options. It's not a simple checklist where you just confirm an item
    and move on to the next one. Some of the items can be optional, however at least one has to be mandatory. Each item
    on the checklist can have its own checklists or policies. There can be policies that end the conversation on the
    spot or point to another checklist where the conversation continues. Some of the policies and transitions can be
    seen in the previous examples.</p>
​
<p>For example, for time specification we want only the current day or a day in the future, but not in the very distant
    future. For room bookings, only single-day reservations are allowed. Furthermore, when specifying a room, we have to
    select from a place that exists in the system database.</p>
​
<h2>Conclusion</h2>
<p>Conversations with our chatbot are based on checklists with predefined policies to follow. The user is given an
    illusion of choice with a first request that can be created any way the user desires, and afterward the control of
    conversation flow is entirely coded in the chatbot. From a developer’s point of view, that gives us an easy way to
    test these conversations, and develop each branch of conversation independently.</p>
<p>From the user's point of view, the bot asks for missing pieces of information. Thanks to the firm grip on the
    conversation, the user should not end up in a situation where he doesn't know what to answer or how to reach a
    certain goal.</p>
<p>So is it artificial intelligence? No. It's a state machine that follows pre-set lines of conversation. However, the
    conversation can be very complex, and when it is complex enough, users might come to the conclusion that this is
    what AI looks like.</p>


Written by: Vojtech Kaisler