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

4. Design Messages in Chatbots

Charles Waghmare1 
(1)
Mumbai, India
 

In this chapter, we focus on how we can create messages effectively in chatbots to build a better customer experience. We aim to develop an understanding of the customer experience, design messages in chatbots with various messaging properties, and see how to create a rich and intuitive customer experience by adding controls and card functionalities in the messages. Let’s being with an introduction to customer experience.

Customer Experience: An Introduction

A couple of decades ago, the software business revolved around software development, implementation, and application management services. Then came the era when many innovative mobile devices were launched; apps were developed; analytics such as sentiment analysis, social media command centers, dashboards, and Power BI were launched; and, finally, infrastructures moved into the cloud and we saw Office 365, Amazon Web Services, and software-as-a-service products. Today, we are living in a world of digital transformation in which product companies launch new technologies to create better customer experiences. The realm of digital transformation includes various technologies such as Azure, AI, chatbots, cognitive services, Pega, Liferay, C4Hana, SAP Hybris, salesforce marketing, commerce clouds, Microsoft CRM Dynamics, Jira, and more. IT companies use these technologies to create a digital customer experience.

Currently, there is paradigm shift in which both product and service companies aim to create a great customer experience. What exactly is a great customer experience? A customer experience is said to be a combination of the reactions, emotions, and perceptions a customer experiences while using different media to interact or collaborate with a business, product, or employee.

Customer experience builds the bridge between customer and organizational business goals. Success is achieved by creating a connection between the customer experience and customers’ needs in such a way that delivers business value at an accelerated pace for the business and the customer.
../images/478917_1_En_4_Chapter/478917_1_En_4_Fig1_HTML.png
Figure 4-1

What is the customer experience?

In this chapter, we focus on the great customer experience produced by Azure chatbots. However, to produce a great customer experience, we need to design the user experience in the chatbot. Let’s look at how to design a chatbot to create a great user experience.

Chatbots for a Greater Customer Experience

Azure chatbots can be designed using various features such as buttons, images, text, and rich cards displayed in the form of a list or carousel. If the chatbot sits inside channels such as Facebook Messenger, Slack, Skype for Business, and others, then rendering these features depends on the channels. There are cases when features are not supported by channels. In these situations, the channel tries to “down-render” the message contents in the form of text or as a static image, which affects appearance. There are exceptional cases when a channel cannot support a few features at all. For example, GroupMe clients installed on devices cannot display a typing indicator while interacting with a user.

Rich User Controls

Rich user controls are common user interface controls such as buttons, images, carousels, and menus that the bot presents to the user and with which the user engages to communicate choice and intent. A bot can use a collection of user interface controls to mimic an app or can even run embedded within an app. When a bot is embedded within an app or web site, it can represent virtually any user interface control by leveraging the capabilities of the app that is hosting it.

Web site developers have been using modern user interfaces to engage users with mobile apps or web sites to produce a great user experience. The same philosophy can be adopted by chatbots by using modern user controls to understand user expectations. When booking an airline ticket, if the chatbot shows a Book Ticket button at the end, then it is convenient for users to achieve expectations with a single action, rather than forcing users to type “book ticket” so the bot can proceed with the booking. The latter case may contain typos, which results in a delay and confusion for the user and the chatbot. As another example, if a user wants to know nearby restaurants and the chatbot can display the top-five nearby restaurants from a Form button, it is quite convenient for the user to make a choice, which creates a good customer experience.

Cards

Cards allows chatbots to display their message in the form of visual, audio, and/or selectable messages, and assist in conversation flow. If a user is required to select an item from a set list, the chatbot can then display a carousel of cards, each containing an image, text for instructions, and one button for making a choice. If a user wants to select multiple items from a given list, then the chatbot can display a smaller single image and a collection of buttons with various options for the user to make a choice. Cards provide in-depth information using audio or video output, or receipts that detail a shopping experience, for example. There are different kinds of cards available and each depends on the business requirement for which the chatbot was developed. Cards create a seamless engagement with users. Let’s look at some different kinds of cards, the type of action they promote, and their recommended use.

Microsoft Bot Service cards are objects that can be programmed. They contain standardized collections of rich user controls compatible with a wide range of channels, such as Facebook Messenger, Slack, Skype, and others. The following is a list of cards available with Microsoft Bot Service and the best way to use them effectively in chatbots.
  • Adaptive cards: Adaptive cards (Figure 4-2) are typically used for cross-channel card deployment. They can adapt the look and feel of the host channel.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig2_HTML.jpg
    Figure 4-2

    Sample adaptive card

  • Animation cards: Animation cards (Figure 4-3) play GIFs or short videos.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig3_HTML.jpg
    Figure 4-3

    Sample animation card

  • Audio cards: Audio cards (Figure 4-4) are used to play audio.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig4_HTML.jpg
    Figure 4-4

    Sample audio card

  • Hero cards: Hero cards (Figure 4-5) typically contain a single picture, with text and multiple buttons. They are used to highlight the user’s choice visually.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig5_HTML.jpg
    Figure 4-5

    Sample hero card

  • Thumbnail cards: Thumbnail cards (Figure 4-6) contain one thumbnail image, text, and multiple buttons. They are used to highlight buttons visually for the user.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig6_HTML.jpg
    Figure 4-6

    Sample thumbnail card

  • Receipt cards: Receipt cards (Figure 4-7) provide comprehensive receipts to users that list the items purchased by the user.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig7_HTML.jpg
    Figure 4-7

    Sample receipt card

  • Sign-in cards:Sign-in cards (Figure 4-8) are used to enable user login. These cards normally contain text with instructions and one or more buttons for users to make a choice.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig8_HTML.jpg
    Figure 4-8

    Sample sign-in card

  • Suggested action cards: Suggested action cards (Figure 4-9) contain multiple buttons linked to actions. When a button is pushed, the card disappears.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig9_HTML.jpg
    Figure 4-9

    Sample suggested action card

  • Video cards: Video cards (Figure 4-10) play videos using a URL or they stream videos.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig10_HTML.jpg
    Figure 4-10

    Sample video card

  • Carousel cards: Carousel cards (Figure 4-11) are presented as a collection that allows users to view, at a glance, a series of possible user choices.
    ../images/478917_1_En_4_Chapter/478917_1_En_4_Fig11_HTML.jpg
    Figure 4-11

    Sample carousel cards

Cards allow you to design your bot once and have it work across a variety of channels. However, not all card types are fully supported across all available channels.

As stated earlier, an important thing to remember during the design of a chatbot is to use common user interface elements. The principal design objective is to resolve user problems in the most efficient way possible and avoid integration of natural language into the chatbot to make it more complex. Try using the least user interface controls to enable the chatbot to resolve user problems; add other elements if user interface controls cannot help.

Text and Natural Language Understanding

A chatbot accepts input from users in the form of text and has a parsing ability using regular expression matching or natural language understanding APIs such as LUIS. Depending on the type of input provided by the user, natural language understanding may or may not be a good solution. For example, let’s say you want your chatbot to request the user’s name. For our example, let’s assume the user is named Chris. Here are some different possibilities of how Chris will enter his name:
  • Chris

  • My name is Chris

  • Chris Stevens

  • Mr. Kris Stevens

A specific question was asked, but the answers may be entered in a variety of formats that may confuse the chatbot, and thus the user, and may lead to a bad user experience. Another open-ended question is: How are you feeling today? Again, a different combination of answers can be expected from users. What is the weather outside? This question can trigger multiple combinations of answers.

The important thing to keep in mind is to ask specific questions without having to use a LUIS service; this helps reduce chatbot complexity. A question such as “How are you feeling?” could have the answers Good, OK, or Bad, allowing the user to make an easy choice. There are DevOps chatbots that run on specific commands used to manage VMs. The Start/VM1 command triggers the first VM to start. The command Reboot/VM2 reboots trigger VM2.

In short, avoid using natural language understanding and ask specific questions, making use of cards and user controls to create a great customer experience and reduce complexity.

Knowledge-based chatbots or question-and-answer chatbots can answer user questions based on documents or information loaded in a database. QnA Maker and Azure Search are both technologies designed specifically for this type of scenario. A user may ask a general question. When designing a chatbot that answers questions based on structured or unstructured data from databases, web pages, or pools of documents, consider using technologies designed specifically to address this scenario. Do not attempt to resolve the problem with natural language understanding such as LUIS.

In a scenario in which users want to order a hamburger, they can engage with a chatbot with questions such as: Where is the nearest burger joint? Where is the nearest MacDonald’s within three miles? Show me combo burger offers. In this type of scenario, natural language understanding may be useful, and a LUIS API can extract the main component of words from a user’s question to understand intent and provide the desired answer. When developing chatbots using natural language models, it is dangerous to assume that users will provide all the information needed in their questions. However, design your chatbot in such a way that users do not have to repeat the same question in different ways. Request precise information from the user.

There are chatbots that use cognitive technology, such as speech, for input and output. With these chatbots, speech is the only means of communicating with users.

Choosing among Rich User Controls, Text and Natural Language, and Speech

Naturally, human beings like to communicate with each other using a combination of gestures, voice, and symbols. Similarly, one can design chatbots using rich user controls, text, and speech. These communication methods can be joined together; there is no need to choose one over the other. I illustrate this with a cooking example. This particular cooking chatbot shows users recipes in the form of images or videos. To choose a specific recipe, users simply touch the screen (this chatbot is enabled with rich user controls). In addition, users can input information to search for a specific recipe. While designing, incorporate user experience elements that support different ways in which users can interact with a chatbot.

Key Chatbot Message Concepts

At this point, we have learned about the following elements of chatbots: rich user control cards, natural language understanding, and speech techniques that are used while designing chatbots. Now we’ll focus on creating messages in chatbots and adding media attachments, rich cards, speech messages, and input/suggested messages. However, before delving into these subjects, let’s go through some key concepts used frequently in chatbot development.

Connector

The Bot Frame Connector provides a single REST API that facilitates communication between chatbot and user by transmitting messages from the chatbot using channels such as Skype, e-mail, and Facebook Messenger, and then transmits back from the channels to the chatbot.

Activity

The connector uses an activity object to transmit information back and forth between chatbots and users (i.e., channels). The most common object is message activity, but there are other activity objects:
  • ConversationUpdate: The chatbot was added to the conversation and users are added or removed from the conversation.

  • ContactRelationUpdate: The chatbot was added or removed from the user’s contact list.

  • Typing: During a conversation, the user or chatbot is compiling a response.

  • UserDeleteData: The user has requested the bot to delete user data it may have stored.

  • EndOfConversation: Marks the end of a conversation

  • Event: A communication was sent to the user by the chatbot that is invisible or not seen by the user during the chat.

  • Invoke: The user is requesting the bot to perform a specific operation.

  • MessageReaction: A user is reacting to the message by, for example, clicking the Like button.

Dialog

Dialog is used to model and manage conversations between a chatbot and users. A dialog maintains a stack of dialogs that are active during a conversation. Dialogs are portable across computers, which makes it possible to scale chatbot implementation.

FormFlow

FormFlow is used to collect information from users during conversations with a chatbot. For instance, when a user wants to order a pizza, the chatbot must get information from the user, such as type of crust, type of pizza, toppings, and so on. With basic guidelines, FormFlow can generate dialogs automatically to manage a pizza order conversation, for example.

State

The Bot Builder Framework has the capability of storing and retrieving state information pertaining to the user, the conversation, and user-specific information within the context of a specific conversation. During a conversation, information present in the state can be reused. In short, the state is a kind of database; in the Bot Builder Framework, data storage is possible in SQL Server.

Now let’s focus on message properties that can be used during conversations between users and a chatbot.

Create Messages

During communication with users, chatbots send information to users and receive information from users as well. The information exchange exists in the form of plain text, text to be spoken, suggested actions, media attachments, rich cards, and channel-specific data.

Send a Customized Message

Using the Activity object and setting the necessary properties, a custom plain-text message can be shared a with user. The property can be set to plain, markdown, or XML; the default in Bot Framework is markdown. Here is an example:
Message – "Hello World"
Message format set – Plain text

Attachments

The Attachments property of a message activity is used to send and receive media attachments such as images, audio, videos, files, and rich cards.

Entities

The Entities property of a message consists of an array of open-ended schema.org objects that allow for an exchange of common contextual metadata between the channel and the bot—for example, “mention” someone during a conversation, share location-related information using geographic coordinates or a postal address.

Channel Data

Channel data are used to implement channel-specific functionality, such as creating a custom e-mail message, a full-fidelity Slack message, a Facebook notification, a Telegram message, and a line message.

Text-to-Speak

The Speak property of a message can be used to specify the text to be spoken by a bot on a speech-enabled channel.

Suggested Actions

The SuggestedActions property of a message activity can be used to show buttons that the user can use to submit input. The buttons disappear after the user makes a selection.

Add Media Attachments to Messages

An exchange of messages between a user and a chatbot may contain media attachments (e.g., image, video, audio, file). The Attachments property of the Activity object contains a list of Attachment objects that contain media attachments and rich cards used in the message. The connector service transmits data in such a way that channels are able to retain messages. If the attachment is a file, the hyperlink is displayed in the conversation.

To add a media attachment to a message, create an Attachment object for the message activity and define the ContentType, ContentURL, and Name properties. Here is some sample code in C#:
replyMessage.Attachments.Add(new Attachment()
{ ContentUrl = "https://www.charleswaghmare.com.png",
    ContentType = "image/png",
    Name = "Charles_waghmare.png"
});
Listing 4-1

Adding a media attachment

Add Rich Card Attachments to Messages

An exchange of a message between a user and a chatbot can contain rich cards in the form of lists or carousels. The Attachments property of the Activity object contains a list of Attachment objects: rich cards and media attachments within the message. Earlier in the chapter, we saw different types of rich cards, such as adaptive, animation, audio, hero, thumbnail, receipt, sign-in, and video.

To display rich cards in a list format, set the activity’s AttachmentLayout property to "list"; to display multiple rich cards in a carousel format, set the activity’s AttachmentLayout property to "carousel". If the carousel format is not supported, then rich cards are displayed in the list format. Normally, all chatbot responses are created with adaptive cards. Check out the example in Figure 4-12.
../images/478917_1_En_4_Chapter/478917_1_En_4_Fig12_HTML.jpg
Figure 4-12

Response using an adaptive card

Process Events within Rich Cards

To process events within rich cards, there are CardAction objects to specify the action that should take place when a user clicks a buttons or taps a card. Here is a list of CardAction options:
  • Open URL: Try opening the URL in the browser.

  • IM Back: The chatbot receives the text the of message when the user clicks a button or taps a rich card. This message is visible to all participants in the chatbot.

  • Post Back: The chatbot receives the text of the message when the user clicks a button or taps a rich card. Some channels may display this text in the message feed and it will be visible to all conversation participants.

  • Call: Then, Call Destination with phone call: Tel: 999222

  • Play Audio: Using this URL of the audio to be played

  • Play Video: Using this URL of the video to be played

  • Show Image: Using this URL of the image to be displayed

  • Download File: Using this URL of the file to be downloaded

  • Sign In: Using this URL of OAuth flow to be initiated

These card actions are used to add different rich cards to the conversation between the chatbot and the user.

Add Speech to Messages

To create a speech-enabled chatbot, you can construct messages—in other words, precise text to be spoken by the chatbot. You can also influence the state of the user’s microphone by specifying an input to indicate whether the chatbot is able to accept, is expecting, or is ignoring the user message. There are multiple ways to specify text to be spoken by a chatbot on a speech-enabled channel. You can use message properties such as Speak, call the IDialogContext.SayAsync() method , and specify prompt options—Speak and retry—in the message prompt.

To specify text to be spoken by a chatbot, you can use a plain-text string or a string that is formatted in Speech Synthesis Markup Language, which is an XML-based markup language that enables you to control various characteristics of your chatbot, such as voice, rate, volume, pronunciation, pitch, and more.

To influence the user’s microphone to indicate whether the speech-enabled chatbot is accepting, expecting, or ignoring inputs given by user, the message properties should be set to InputHints.AcceptingInput to indicate the chatbot is ready for input and is not waiting for a response from the user. The Message property should be set to InputHints.ExpectingInput indicates the chatbot is waiting for a response from the user. Last, the Message property should be set to InputHints.IgnorningInput indicates the chatbot is unready to accept input from the user.

Add Suggested Actions to Messages

By adding suggested actions to your conversations, you can tap a button to provide input to a chatbot. Also, users do not have to type text and, as a result, there is an improved user experience that is facilitated by providing intuitive buttons for users to answer questions and select responses from multiple choices. In addition, buttons in the form of cards double the user experience because, as soon as they are tapped, they disappear from the screen. As a result, users are prevented from tapping stale buttons during a conversation.

To add suggested actions to a message, set the SuggestedActions property of the activity to a list of CardAction objects that represent the buttons to be displayed to the user during a conversation.

Send and Receive Activities

The Microsoft Bot Framework has a REST API that facilitates chatbot and user communication through multiple channels such as Skype, Slack, e-mail, and others. Communication between a chatbot and the user takes place by transmitting a message from the chatbot to the user and vice versa. To create a reply, the connector should use the message activity object to transmit information between the user and the chatbot. Every activity contains information, such as who created the message, the context of the message, and the recipient of the message. By calling Connect with Message activity “Reply to Activity,” you can create and send a reply message. Furthermore, you can send a nonreplyable message by calling the message property SendtoConversation. The CreateMessage activity method helps to create the new message and sets all property values as needed.

To start a new conversation by a chatbot with one or more users, the message activity Create Direct Conversation is used to create a private conversation. The message activity Create Conversation helps to create new conversations and opens them with one or more users. Last, the Send to Conversation method helps in sending newly created messages.

Implement Global Message Handlers

Users commonly attempt to access certain functionalities they have used while interacting with web sites or mobile apps. These common functionalities are help, cancel, or start over. These actions are often used in the middle of a conversation when the chatbot is expecting a different input from the user. By deploying global handlers such as help, cancel, or start over, you can design your chatbot to handle such requests and act accordingly. Check out the example in Figure 4-13.
../images/478917_1_En_4_Chapter/478917_1_En_4_Fig13_HTML.jpg
Figure 4-13

Message handlers

Intercept Messages

Messages between chatbots and a group of users can be intercepted by middleware functionality in the Microsoft Bot Framework. For each intercepted message, you can save or inspect the message, or create a conversation log. By default, the Bot Framework does not save this information automatically for privacy reasons. It is a best practice to tell users that their conversation with the chatbot is being saved and to explain the specific reason for saving it.

Send Proactive Messages

A chatbot usually sends messages to users that are related directly to the user’s prior input. But, in some cases, it is useful for a message not to be related directly to the last message sent by the user. These messages are called proactive messages . There are various business scenarios in which proactive messages are useful. If the user has set up a reminder in a bot, then the chatbot will send the reminder in the form of a proactive message when the time for the event is near. Furthermore, a chatbot can be asked to keep a close eye on sales offers and then trigger notifications when there is a dip in price. When this is set up and a price decrease occurs, the chatbot delivers an e-mail notification to the user. In another situation, a user may want to make a hotel reservation based on a price cap. When the chatbot finds a reservation that meets the user’s requirement, it sends a notification to the user. Proactive messages are also used to inform users that their input is getting processed or the chatbot is waiting for user input to continue the conversation.

A point to remember before sending proactive messages is not to send multiple proactive messages in a short span of time because this may confuse the user. Also, do not send proactive messages to someone who has never used a bot, because it may result in an unexpected scenario (Figure 4-14) .
../images/478917_1_En_4_Chapter/478917_1_En_4_Fig14_HTML.jpg
Figure 4-14

Unexpected proactive message

In the example in Figure 4-14, we can infer that the user has set up a reminder for hotel prices to drop by certain limit. However, while booking a reservation for a different trip, a notification pops up and the user gets confused. This situation can be handled in a better way, such as displaying reminder setups in a different color, sending notifications after a booking is completed, canceling the current booking and delivering a notification, or interrupting the current booking until the user responds, then switching back to the current booking.

Ad hoc private messages are the simplest form of proactive messages, and chatbots inject them into messages whenever triggered, regardless of whether a user is engaged in a separate conversation with a chatbot. Chatbots can also send a dialog-based proactive message to a user. In this case, the chatbot must first collect and save information from the current conversation.

Summary

With this, we come to the end of this chapter. During our journey in this chapter, we enhanced our familiarity with the customer experience and then examined how we can make conversations between chatbots and users intuitively strong by using rich controls and cards. Last, we looked at connectors and different message properties to help us build conversations in the most efficient and intuitive ways.

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

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