© Charles Waghmare 2019
C. WaghmareIntroducing Azure Bot Servicehttps://doi.org/10.1007/978-1-4842-4888-1_3

3. Design Azure Chatbots

Charles Waghmare1 
(1)
Mumbai, India
 

In this chapter, we learn how to design Azure chatbots. We start with an introduction to the Microsoft Bot Framework and examine the start-to-finish workings of chatbots and the requirements necessary for creating Azure chatbots. Last, we look at a real implementation of an Azure chatbot.

Introduction to the Microsoft Bot Framework

In 2016, Microsoft released Bot Framework to develop intelligent applications. This framework was designed to be used for customized development and deployment in channels such as Skype, Facebook Messenger, and Telegram. Bot Framework has many advantages and its services communicate easily with different applications. Skype–Cortana integration (the best example) is used to gather information such as news, weather, tips, and tricks. Using the Microsoft Bot Framework, real-time functionalities, such as booking a hotel and ordering food online, and FAQ readers are developed using communication channels such as Skype, Slack, e-mail, and GroupMe. With the help of bots, it is easy to connect across platforms and go serverless.

To build bot applications using this framework, we can use .NET Software Development Kit (SDK) and Node.js SDK. SDKs help build applications with dialog and built-in prompts to make an interactive application. The REST API is used to develop applications. With such functionality, an application becomes very easy to use and is interactive (Figure 3-1).
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig1_HTML.png
Figure 3-1

Integration of bots with different online services

Let’s now look at some of the benefits of the Microsoft Bot Framework.

Accelerated Development

Using the Microsoft Bot Framework, you can build, connect, deploy, and manage intelligent chatbots that interact with users through web sites, mobile apps, Cortana, Microsoft Teams, Skype, Slack, Facebook Messenger, and more.

Azure Bot Service provides developers with an integrated environment for chatbot development using Microsoft Bot Framework connectors and bot-builder SDKs. With such functionality, developers can use out-of-the-box templates, such as forms, in business scenarios; and language, questions, and answers can be used for user engagement.

Creation of Intelligent Bots with Cognitive Services

You can build a bot that recognizes users in photos, moderates user content, provides smart recommendations, translates languages, and more. Cognitive Services facilitates your bot in seeing, hearing, understanding, and interpreting in a human way.

User Engagement

Chapter 2 described the integration of chatbots with business applications. Our objective behind the integration of chatbots with other applications is to demonstrate the convenience of an Azure chatbot. A high level of coding is not necessary. Using the standard services available in Azure Portal, integration is easy to achieve.

Cognitive Services: Introduction

Because we are focusing on Azure technology, let’s take a look at what Azure Cognitive Services offers. Azure Cognitive Services includes APIs, SDKs, and other services that help developers build intelligent applications without being connected to AI, big data, or background knowledge. Azure Cognitive Services enhances Microsoft machine learning techniques and enables developers to create intelligent applications by adding cognitive features such as emotions, speech and vision recognition, facial interpretation, video detection, and speech and language understanding into their applications. The ultimate goal of Azure Cognitive Services is to help developers build smart applications that can see, speak, hear, understand, interpret, and reason. The following lists the different categories of Azure’s vision, speech, language, search, and knowledge APIs.

Vison API
  • Computer vision: Provides access to process images by the system and returns the correct image or information.

  • Custom vision service : Builds custom image classifiers.

  • Content moderator: Helps to monitor and track possible offensive, undesirable content and virus attacks.

  • Face API: Accesses advanced face algorithms and enables functionalities such as facial detection and recognition.

  • Emotion API: Accepts an image as an input and provides output (such as anger, fear, shame, surprise, and others) across a set of emotions for each face in the image.

  • Video indexer: Enables developers to pull insights from video.

Speech APIs
  • Speech service : Adds speech-enabled features to applications.

  • Custom speech service : Creates customized language models and acoustic models compatible with your application and users.

  • Bing Speech API : Searches content using speech.

  • Translator speech : Performs language translation.

  • Speaker recognition : Allows identification and verification of speakers based on algorithms.

Language APIs
  • Bing Spell Check : Performs contextual grammar and spell checking.

  • Language understanding service (LUIS) : Allows your application to understand what a person wants in their own words.

  • Linguistic analysis : Provides NLP tools to identify text structure.

  • Text analytics : Provides NLP for raw text to perform sentiment analysis, key phrase extraction, and language detection.

  • Translator text : Provides machine-based text translation in close to real time.

  • Web language model : Allows for NLP word prediction, sequencing, completion, and breaking strings of word without spaces.

Search APIs
  • Bing News Search : Returns a list of news articles relevant to a user’s query.

  • Bing Video Search : Returns a list of videos relevant to a user’s query.

  • Bing Web Search : Returns a list of search results relevant to a user’s query.

  • Bing Autosuggest : Allows you to send a partial search query to Bing and prepopulates suggested queries.

  • Bing Custom Search : Allows you to create custom search experiences.

  • Bing Entity Search : Returns information about entities relevant to a user’s query.

  • Bing Image Search : Returns a display of images relevant to a user’s query.

  • Bing Visual Search : Returns insights about images, such as visually similar images and shopping sources for products found in the image.

Knowledge APIs
  • Custom decision service : Helps to create intelligent systems for contextual decision making, personalizing and optimizing the user experience.

  • QnA Maker : Allows you to create a question-and-answer service from your semistructured content.

Cognitive services available in Azure support the following languages to allow users to communicate with your applications in a natural way:
  • Chinese

  • English

  • French

  • German

  • Italian

  • Japanese

  • Korean

  • Portuguese

  • Spanish

Different Types of Chatbots Using Azure Bot Service

Azure Bot Service provides different types of bot services that help create and deploy chatbots for specific business scenarios. In this section, we examine the background workings of different chatbots, such as commerce, information, knowledge, enterprise, Cortana, and IoT chatbots.

Commerce Chatbots

Using Azure LUIS and Azure Bot Service, developers can create conversational interfaces for various business purposes, such as ordering pizza, checking account status, and looking for a new movie, which can transform the user experience. For example, pizza restaurants can process requests using text and audio, and use a speaker-enabled audio service for drive-through orders—all of which complement traditional methods of workers accepting requests over the phone and via e-mail. The workflow in Figure 3-2 is as follows:
  1. 1.

    The customer accesses their mobile app.

     
  2. 2.

    User authentication occurs using the business-to-consumer (B2C) Azure Active Directory.

     
  3. 3.

    Using the bot, the user requests information.

     
  4. 4.

    Cognitive Services processes the natural language request.

     
  5. 5.

    The response is reviewed by the customer, who has the option to refine information.

     
  6. 6.

    When the user is satisfied, the chatbot pushes the order through for delivery.

     
  7. 7.

    Azure Application Insights captures personas.

     

Note

Personas are virtual trends or views of users who have accessed AI-enabled services. They are stored temporarily in the system. For example, a user from India asks a chatbot to provide a list of all United Nations presidents. This view is stored in the system as a persona. If some other user asks a similar question related to the United Nations, then the chatbot first references personas to find a quick answer before querying the database.

../images/478917_1_En_3_Chapter/478917_1_En_3_Fig2_HTML.jpg
Figure 3-2

Background workings of commerce chatbots

Information Chatbots

Informational chatbots are designed to answer questions defined in the form of a knowledge set or FAQ using Azure Cognitive Services. QnA Maker attempts to answer more open-ended questions using Azure Search. A typical workflow is shown in Figure 3-3.
  1. 1.

    A user accesses their device.

     
  2. 2.

    The Azure Active Directory authenticates the user.

     
  3. 3.

    The user posts a query inside the chatbot.

     
  4. 4.

    Cognitive Services returns a FAQ created using QnA Maker .

     
  5. 5.

    A user defines a valid search string if the FAQ is irrelevant.

     
  6. 6.

    The chatbot processes the query and submits the query to Azure Search, which returns information based on available data.

     
  7. 7.

    Application Insights captures the user personas.

     
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig3_HTML.jpg
Figure 3-3

Background workings of information chatbots

Enterprise Chatbots

Using LUIS and Azure Bot Service, enterprises can build powerful productivity chatbots to streamline common activities by integrating with external systems such as Office 365 Calendar, customer cases stored in Microsoft Dynamics CRM, and much more. A typical workflow is shown in Figure 3-4.
  1. 1.

    A user accesses the enterprise’s productivity chatbot.

     
  2. 2.

    Azure Active Directory authenticates the user’s identity.

     
  3. 3.

    The chatbot queries Office 365 Calendar using Azure Graph.

     
  4. 4.

    Using data collected from the calendar, the chatbot accesses information in another system (for example, Microsoft Dynamics CRM ).

     
  5. 5.

    Information is returned to the user.

     
  6. 6.

    Application Insights tracks user personas in the organization.

     
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig4_HTML.jpg
Figure 3-4

Background workings of enterprise chatbots

Cortana Chatbot

Using a Cortana chatbot, anybody can schedule a mobile auto maintenance appointment using a cognitive voice service. Cortana chatbots act as a personal assistant. In this example, it helps the user speak with a representative of any auto shop to schedule an appointment. The chatbot can provide users with a list of maintenance services, availability, and time required to implement the service. Before scheduling an appointment, Cortana checks for meeting conflicts and, based on a free slot, an appointment is scheduled. A typical workflow is shown in Figure 3-5.
  1. 1.

    A user access a Cortana chatbot from their device.

     
  2. 2.

    Using text or voice request, Cortana processes the request.

     
  3. 3.

    Because of the integration of Cortana with a calendar, conflicts are checked before scheduling an appointment.

     
  4. 4.

    The chatbot sends a query to the auto service representative regarding available appointment times.

     
  5. 5.

    The user chooses the appointment time and sends a confirmation.

     
  6. 6.

    Application Insights analyzes future developments for the Cortana chatbot.

     
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig5_HTML.jpg
Figure 3-5

Background workings of a Cortana chatbot

IoT Chatbots

IoT chatbots make it easy to control devices around the home, such as lighting, using voice or interactive chat commands. A typical workflow is shown in Figure 3-6.
  1. 1.

    A user logs in to Skype and accesses the IoT chatbot.

     
  2. 2.

    Using voice or text commands, the user requests the IoT chatbot to turn on the lights in their home.

     
  3. 3.

    The request is transmitted to a third-party service that has access to the IoT device.

     
  4. 4.

    The request is shared with the user.

     
  5. 5.

    Application Insights identifies user patterns and generates new ideas for developing IoT chatbots.

     
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig6_HTML.jpg
Figure 3-6.

Background workings of IoT chatbots

IoT chatbots are so simple that users can use channels such as Skype or Slack as chatbots to interact with home devices, as just described.

Designing Chatbots

As we have seen so far in this chapter, the Microsoft Bot Framework allows users to create innovative chatbots to resolve business problems. In the following sections, we look at how to design chatbots that align with best practices and lessons learned.

If you are designing a chatbot, this means you are designing for all people who will be using it. Chatbots can be used over mobile apps, web sites, phone calls, and e-mail, so you need to put in your best effort to make them usable by people over other services they have. The goal of designing a chatbot is to attract users and continue the momentum of its use. To achieve this, it is important to set business goals and identify the precise factors for the chatbot being developed.

Most successful web sites and apps deliver good user experiences, and chatbots are no different in this regard. Therefore, when designing your chatbot to produce a good user experience, priority should be given to the user experience factor. Other factors include the following:
  • Chatbots should resolve user problems with a minimal number of steps (in other words, minimal user interactions between the bot and the user).

  • Priority should be given to resolve problems better, easier, and faster to produce a good user experience.

  • Chatbots should be integrated with frequently used applications or platforms.

  • Chatbots should be easy to find.

None of these factors is linked to the intelligence of the chatbot or the cognitive services with which the chatbot is enabled. From a user perspective, as long as the problem is resolved with a minimal number of steps and it delivers a good user experience, users do not care about the technicalities of a chatbot. A great chatbot user experience does not require users to type too much, talk too much, repeat themselves, or explain things the chatbot should know. The process of designing a successful chatbot can be compared with successful web sites or mobile apps that improve through lessons learned and user feedback; the same applies to chatbots.

Some Factors Do Not Guarantee Bot Success

When designing your bot, be aware that none of the following factors necessarily guarantee its success:
  • The intelligence of the bot: Not all chatbots are designed with cognitive services such as sound, text, image, and others, and many bots have little advanced machine learning or natural language capabilities. A chatbot may include these capabilities if it is designed to resolve business problems. However, there is no link between chatbot intelligence and user adoption of the chatbot.

  • Best vocabulary: The chatbot you design may have the best vocabulary or the ability to engage users in useful conversation or jokes, but unless it addresses business problems, these capabilities have less importance. Some chatbots have no conversational capability but still produce a great user experience.

  • Cognitive experience: You need to be careful when considering a cognitive experience with, for example, voice recognition. Sometimes this capability is frustrating for users. Therefore, think of business problems, then think twice about whether voice recognition will resolve those problems. Otherwise, a great user experience is not necessarily one that creates a chatbot that produces “noise,” which may disturb users and groups of users.

The First Impression of a Chatbot Really Matters

When we develop a mobile app, the first user interface we think of showing to users is a menu as soon as they open a mobile app. From there, they navigate to different places in the app. Intuitively, looking at the user interface, users understand different areas, such as the About Us page, team details, downloading, privacy policy, and others. When we develop a chatbot, we need to think similarly. Let’s look at a couple chatbot user interfaces.

In Figure 3-7, the first user interface starts with an open-ended question: How can I help you? If users do not know what the chatbot can do, there is strong possibility they may get confused and ask a number of queries to resolve issues. If the chatbot doesn’t explain what it can do, how will users know its capabilities?
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig7_HTML.jpg
Figure 3-7

Design 1 of chatbot user interface

If you look at design 2 in Figure 3-8, it looks very precise. In this user interface, the chatbot definitely informs users of what it can do. If you provide menu options, as in the case of mobile apps, users are likely to find information with a minimal number of steps. In addition, having menus in place saves users time by not requiring them to enter text or too many character the chatbot may not understand. With menu options, users can access information with one click.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig8_HTML.jpg
Figure 3-8

Design 2 of chatbot user interface

Menu options do not necessary imply the chatbot is intelligent; however, they help to provide a better user experience. In addition to a menu, you can also add a form and, based on user input, the chatbot can parse input to relevant information. You can pose more specific questions in the user interface. For example, if your chatbot can effect pizza delivery, it could ask: What type of crust do you want for your pizza? The options could be as follows:
  • Thin

  • Pan

  • Double

On making that selection, another question could pop up: What kind of pizza do you want?
  • Vegetarian

  • Chicken

  • Meat

And so on. Posing specific questions takes users to destinations and produces a better user experience. Another important aspect: If your chatbot collects personal data, the chatbot user interface should have a privacy policy and inform users for what purpose and in what manner their data will be used.

Conversation Flow

In general, web sites or mobile apps have multiple user interfaces that are nothing but multiple screens. These user interfaces are connected with each other and, based on input provided in the user interface, redirection to another user interface takes place. Mostly, web sites or mobile apps have one main screen where all navigation links to other user interfaces are present, or users are asked to enter some other input before being redirected to an alternate screen. User interfaces consist of visually appealing designs and colors. To conclude, web sites and mobile apps contain user interfaces that need to be designed meticulously so that users do not get confused while navigating to different links. In addition, they should be able to reach the home page from any other user interface.

Similarly, chatbots also have multiple user interfaces, with one being the main user interface, similar to web sites and mobile apps. But user interfaces in chatbots contain dialog so the user can interact with the chatbot. Dialog can instruct users to take action before they get their results. The chatbot user interface could be plain text, with dialog to links or images, or it could be an input form where users are forced to enter information to get output.

Dialogs help developers to separate various scenarios and build user interfaces for each corresponding scenario. For example, developers can create a different dialog for users to choose their type of pizza crust and another dialog for users to make a payment after order confirmation.

Figure 3-9 shows the flow of a traditional application compared to the dialog flow of a bot.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig9_HTML.jpg
Figure 3-9

Comparison conversation flow in a traditional application vs. a chatbot

In Figure 3-9, we see the traditional app’s main screen invokes a New Order user interface, which remains in control until it is either closed or invokes another user interface. When the New Order user interface is closed, the user is redirected to the main screen. The user has to navigate multiple user interfaces.

With a chatbot, everything begins with the root dialog. The root dialog invokes the New Order dialog. The New Order dialog is in control until it invokes other dialog or closes it. If the New Order dialog closes, then control of the conversation is returned to the root dialog. The user interface stays the same even if the flow of information is the same as in the web app.

Dialog Stack

A dialog stack is when one dialog invokes another; the chatbot builder adds new dialog to the stack of dialogs. Dialog set at the top of the stack is in control of the conversation with the user. Every new message sent by the user during a conversation is processed by dialog, which is at the top of the stack until it is closed or redirects to another dialog. After the dialog is closed, it is removed from the stack and returns to the previous dialog in the stack, which takes control. Understanding the concept of how a dialog stack is constructed and deconstructed by the chatbot builder is important.

Dialogs, Stacks, and Humans

During the actual working of a chatbot, users navigate across dialogs, create a dialog stack, and return to where they started. Referring back to Figure 3-9, the user starts with the root dialog, invokes the New Order dialog, and, finally, the Product Search dialog. At the final stage, the user selects a product, confirms it in the Product Search dialog, and completes the order. The user exits the New Order dialog after the order is confirmed, then arrives back at the root dialog. In an ideal situation, users follow a linear path, but this doesn’t happen often because people frequently change their mind. Let’s consider the example in Figure 3-10.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig10_HTML.jpg
Figure 3-10

User dialog

Although the bot may have constructed a logical stack of dialogs, users may decide to do something entirely different or ask a question unrelated to the current topic. In Figure 3-10, the user asks a question instead of providing the yes-or-no response expected. How should the chatbot dialog respond?
  • Force the user to answer the first question.

  • Attempt to solve the user’s question and then move back to yes/no question.

  • Disregard all previous dialog, reset the entire dialog stack, and start from the beginning.

There is no right answer to this question. The best solution to this kind of situation is related to the scenario and the way the user expects the chatbot to respond. As conversation becomes complex, managing dialog stacks becomes complex. For complex branching situations, it is easy to create a logical flow to keep track of user conversations.

Design Bot Navigation

We navigate web sites and apps using menus, which are not used when working with chatbots. As seen in the previous sections, users do not necessarily interact with chatbots in linear way, which makes it challenging to design a chatbot that delivers a good user experience. Consider a few of the following issues that may arise in a nonlinear situation that occurs during a user conversation:
  • How does the user navigate backward and forward during a conversation?

  • How can the user cancel the operation (such as a request for nearby hotels, for example) during a conversation?

  • How you can ensure the user does not “get lost” during the conversation?

  • How can the user access the main menu (if there is one) during a conversation?

Specifics of bot navigation design depend largely on the features and functionality that your bot supports. To avoid the common pitfalls of poorly designed conversational interfaces, here are five personalities to help you improve your chatbot design:
  1. 1.

    The stubborn chatbot

     
  2. 2.

    The clueless chatbot

     
  3. 3.

    The mysterious chatbot

     
  4. 4.

    The Captain Obvious chatbot

     
  5. 5.

    The unforgetting chatbot

     

The Stubborn Chatbot

The stubborn bot insists on maintaining the current course of the conversation, even though the user might steer into a different context. Consider the scenario in Figure 3-11.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig11_HTML.jpg
Figure 3-11

The stubborn chatbot

To handle this type of situation, know that users can move out of context at any time. If chatbots ask the same question repeatedly when users move out of context, the chatbot is not called a “smart” bot. There is a good chance the user’s frustration level will increase and lead to a bad user experience.

The Clueless Chatbot

Clueless chatbots respond in a nonsensical manner when they do not understand user requests. A user may use common words such as help or cancel, with the expectation that the chatbot will understand and deliver the proper answer. Consider the scenario in Figure 3-12.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig12_HTML.jpg
Figure 3-12

The clueless chatbot

Ideally, we want to design chatbots to cover all possibilities, but this is close to impossible because we cannot predetermine user behavior. In the scenario presented in Figure 3-12, we can make use of middleware functionality, which logs every message and query in external data sources. By defining the logic in the middleware, we make information accessible to every exchange with the user.

The Mysterious Chatbot

The mysterious chatbot fails to acknowledge the user’s input immediately. Consider the scenario in Figure 3-13.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig13_HTML.jpg
Figure 3-13

The mysterious chatbot

The chatbot could be in an outage state or could be compiling the user request. Both situations produce a poor user experience. Therefore, it is important to indicate to the user that the chatbot is processing input. This can be sent in the form of an acknowledgment message or a graphic that indicates user input is being compiled.

The Captain Obvious Chabot

The Captain Obvious chatbot provides unsolicited information that is completely obvious and therefore useless to the user. Consider the scenario in Figure 3-14.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig14_HTML.jpg
Figure 3-14

The Captain Obvious chatbot

Design your chatbot to provide useful information so that users engage and receive a better user experience.

The Unforgetting Chatbot

The unforgetting chatbot integrates information inappropriately from past conversations into the current conversation. Consider the scenario in Figure 3-15.
../images/478917_1_En_3_Chapter/478917_1_En_3_Fig15_HTML.jpg
Figure 3-15

The unforgetting chatbot

It is important to maintain the flow of the current conversation to reduce user confusion and frustration, and to increase the chance of users engaging in conversation with the chatbot.

Summary

With this, we come to the end of this chapter. Before moving to the next one, let’s look at what we learned. We started with a down-to-earth introduction of the Microsoft Bot Framework and Azure Cognitive Services, looked at the beginning-to-end workings of Azure chatbots, saw different types of Azure chatbots (such as commerce, information, enterprise, and IoT chatbots) and, last, studied chatbot design and design challenges

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.186.109