Build an AI powered agent for Amazon Connect using AWS QnABot
In the age of rapidly deployable and configurable contact center technology, organizations across all verticals, sectors, and industries are reevaluating the ways they engage with their end customers as well as the services they provide. Customers are looking for more dynamic, intuitive, and responsive ways to engage with businesses and governments. Using cloud based technologies and artificial intelligence, customers can engage with businesses like never before, and businesses are enabling these experiences using Amazon Connect, Amazon Lex, and AWS QnABot.
Amazon Connect, a cloud based omnichannel contact center, allows you to provide exceptional customer service by integrating with backend CRMs, APIs, and knowledge bases. To enhance the customer experience and improve self-service, you can incorporate Amazon Lex based chat bots directly into your Amazon Connect contact center. Amazon Lex allows your customers to use natural language statements to quickly identify the call reason, automate high volume and simple tasks, or get answers to their most frequently asked questions.
Overview of solution
The AWS QnABot solution allows users to query a knowledgebase curated through the QnA Content Designer. Using Amazon Connect’s ability to invoke QnABot via Amazon Lex, customers can expand their contact center’s self-service functionality by minimizing the need for customer service representatives to spend time answering frequently asked questions. Examples could be hours of operation, policy information, school schedules, or any other type of frequent questions. In order to optimize the user experience for voice via Amazon Connect, there are configurations and parameters that provide a more natural and intuitive interface.
In this post, we will walk through some options and configurations that will enable you to build a natural conversational interface, leverage QnABot functionalities, and use QnABot as a routing function within an Amazon Connect contact center.
You may want to review this video, that shows you how to integrate Amazon Connect with QnaBot.
Creating and Configuring a Connect Instance
• Log in to the QnABot Content Designer, choose the tools menu (☰) and choose Connect
• Follow the step-by-step directions to create a contact center using QnABot to answer users’ questions
Enhancing QnABot within Amazon Connect
The image above shows beginning of the sample contact flow that sets logging behavior to true, allows the caller to select their desired language, and defines how prompts are set to be played out to the user. The multi-language flow is provided if you deployed QnABot in V2-only mode in QnABot 4.7 and is the default for any deployment in version 5.
The language is controlled by the Set voice block in the contact flow. If you have deployed LexV2 (QnaBot 4.7 or later), check the Set language attribute checkbox to send the language to QnABot.
Checking this box will allow you to return curated responses in different languages. Make sure that the language you set in the contact flow has been configured as a supported language in QnABot. This is done using the “LexV2BotLocaleIds” CloudFormation parameter.
Make sure that ENABLE_MULTI_LANGUAGE_SUPPORT is set to true in QnABot. This will automatically translate any non-English input into English. The input will then be matched against the questions in the QnABot database. For each answer you can use handlebar syntax to specify a pre-translated response to be returned, or you can let the answer be auto translated into the desired language.
For more details on how to configure language specific responses, refer to the blog post on Building a multilingual question and answer bot with Amazon Lex.
The example contact flow uses Amazon Polly’s Neural Text-to-Speech Voices within the QnABot workflow. These new voices deliver groundbreaking improvements in speech quality through a new machine learning approach, making automated conversations sound more lifelike by improving the pitch, inflection, intonation, and tempo.
Prompting the User
To call an Amazon Lex chatbot from Amazon Connect, you need to provide an initial prompt in the Get Customer Input block. In the example contact flow, there are three types of prompts defined: an initial prompt, the next prompt, and a default prompt.
The initial prompt lets you greet the user for the first time. You can provide a customized or friendly greeting to let the user know how to use the system or provide some sample questions.
Within the QnABot invocation, the sample contact flow passes in the defaultPrompt to ensure there is a prompt for the next invocation.
The default prompt defines what gets played out to the user if a next prompt is not explicitly defined within a QnABot response. This can be something like “Ask another question, say return to main menu, or ask to speak to a representative”. In this way, we guarantee that there is always a prompt played out to the user. This default prompt is always passed into the Get Customer Input block as the next prompt in case it is not set within the question.
The next prompt feature lets you explicitly define a prompt that overwrites the default prompt using QnABot Handlebars and Amazon Lex session attributes. Defining the next prompt lets you create guardrails and recommended paths for users to follow as they traverse the experience. By default, we assign the next prompt using the connect_nextPrompt attribute name.
For example, if you have a question like “When is your business open?” the logical response might be “We have two offices with different hours. Which location are you referring to?” Without the connect_nextPrompt construct, the user would get played the default message before being able to respond, breaking the conversational chain.
To see an example of how to use connect_nextPrompt, you can import the Connect sample questions in the QnaBot Designer. Select Import, extend the Examples/Extensions section and load the ConnectWizardQnA examples.
Choose Edit in the menu and search for the ConnectHelper.Hours question using the top search bar (labelled “Filter items by ID prefix”) and clicking on the pencil icon on the right hand side. This will bring up the configuration for that particular question.
The ConnectHelper.Hours sample question shows how to set a next prompt to provide a user a recommended next step or question.
Before invoking the bot again, the sample contact flow sets the prompt to the next prompt that is returned from QnABot.
By overwriting the default prompt with the next prompt attribute, we can guide the user into being more detailed about the information they need while keeping the chain of conversation, although it requires you to have specific questions and answers to respond to the next step in the conversation.
You can configure a feature called Barge In for Amazon Lex within Amazon Connect. This allows users to interrupt a prompt with their response, which is useful for longer menus where users want to provide an input before the entire message plays. In the example contact flow, this feature is enabled for you by setting the a session attribute (x-amz-lex:barge-in-enabled:*:* = true) in the Get customer input block.
This feature, combined with the new CONNECT_ENABLE_VOICE_RESPONSE_INTERRUPT setting in QnABot 4.3+, allows you to write longer form responses to questions that can be interrupted by users. By setting this option to true, QnABot automatically passes the text after the first sentence into the connect_nextPrompt session attribute along with the default or assigned next prompt, enabling barge-in. This allows content designers to simplify how they write longer responses without having to explicitly set the next prompt within the question. For example:
The ConnectHelper.Constitution question shows an example of a long form response that a user may want to interrupt before completion to ask their next question.
Using QnABot Session Attributes within Amazon Connect
Within the sample contact flow, the sample flow checks for session attributes like qnabot_gotanswer and nextAction to determine whether to route the caller to another part of the contact center or into a question not found scenario.
The handlebar construct allows you to build more complicated workflows inside of Amazon Connect—like error handling or routing to other parts of the contact center.
In version greater than 4.1, QnABot returns a parameter on every invocation called qnabot_gotanswer, which returns whether or not a matching question was found. For versions before 4.1, you could optionally create a custom “no hit” question that sets the session attribute to false. This attribute combined with the built in Loop block within Connect allows you to build error handling workflows.
For example, you may want a workflow that can route users to agents instead of back to QnABot if they are experiencing errors or cannot find the answers to their questions.
Setting attributes like nextAction let you build workflows that can route users into other parts of the contact center.
In some use cases, you may want to let users speak to agents or engage in other parts of self-service that are already built. The ConnectHelper questions—ConnectHelper.Menu, ConnectHelper.Agent, and ConnectHelper.Goodbye—demonstrate how to leverage this capability.
The ConnectHelper.Menu question demonstrates how to set a next action attribute within a question that can be used to route the user to another part of the contact center.
QnABot stores the response of the previous question (among other data) inside of a Lex session attribute called qnabotcontext. Using a QnABot feature called Document Chaining, you can enable a “repeat” function by passing the session attribute qnabotcontext back into the Get Customer Input block.
Passing in the previous qnabotcontext allows you to reference attributes stored inside the previous invocation of QnABot.
The ConnectHelper.Repeat question uses a feature called Document Chaining to either repeat the answer to the previous question or route the user to the a default menu if no question has been asked.
QnABot Topics and Navigation
Since Amazon Connect can accept Lex Session attributes from a previous invocation, you can leverage the same concepts around Topics and Navigation workflows either from the web based UI or Amazon Connect. In the example contact flow, these attributes are fed back into the Get customer input block as input attributes. Topic is a top level session attribute that is returned from the previous invocation of QnABot, so this attribute gets sent directly into the next invocation. Navigation session attributes are included in the qnabotcontext attribute as of version 4.2.2 (prior to 4.2.2, these attributes were top level attributes).
Customizing the response by Channel
The way people expect information changes based what channel they’re using. The default Answer will be returned for both voice and text (chat) if no other answer has been provided. However, you have the option to configure a separate SSML Answer which can be used to provide a different version of the answer if the customer is using a voice channel. Over chat it is easy to read a list of URLs, but over the phone that same list of long URLs is not easy to understand and you may have to provide a shorter URL that will point the user to additional information.
You can also use SSML tags to modify how information is spoken back. For example, <speak><say-as interpret-as=”digits”>123</say-as></speak> is spoken back as “one, two three”, where <speak><say-as interpret-as=”number”>123</say-as></speak> is read back as, “one hundred and twenty three”.
Reporting on Amazon Connect interactions
By passing in the Contact ID as connectContactId from Amazon Connect, you can leverage it in reporting.
QnABot records the invocation details and session attributes every time the bot is called inside of an Amazon ElasticSearch cluster that is provisioned for you when you launch the solution. This cluster includes default dashboards to monitor the performance of the bot, including questions that were asked that you didn’t have answers to. By passing in the Contact ID, you can look at specific users that called the bot from Amazon Connect and view the user journey they took from one question to another. This type of analysis can be useful if you’re looking to understand the way your end users are interacting with the bot or if you should build additional guardrails or suggestions that would improve the experience.
Tuning and Error Handling
Like any other AI powered system, it’s important to continuously train and monitor your bot to improve customer experience. QnABot offers tuning recommendations and monitoring capabilities to ensure your customers are able to find the answers to their questions.
Over a voice interface, sometimes filler words can cause QnABot to transcribe an unintentional input. To accommodate for this, QnABot offers a CONNECT_IGNORE_WORDS setting that can be used to strip out unintentional inputs to better understand questions or provide better error handling. The setting accepts a comma delimited list for the words transcribed by filler sounds (for example e,a,uh,uhh,ah,ahh,um,umm). By monitoring the inputs to QnABot, you can build out such an exclude list to improve the performance of the bot while learning more about the questions being asked to your bot.
To avoid incurring future charges, delete the resources created via the template by navigating to the AWS CloudFormation service, select the QnABot stack created by the template, and click delete. This will remove all resources created by the template. You can also delete the Amazon Connect instance in the Amazon Connect service console.
Using session attributes, QnABot settings, and other channel specific constructs, you can improve how users engage with QnABot when using Amazon Connect. While this post is not an exhaustive list of how to improve the experience, using these parameters you can design a better customer experience that lets your users get to the information they need in an intuitive, interactive manner.
Combining Amazon Connect with QnABot allows your customer service representatives to spend time with your customers on more complex tasks while also providing users with a better experience through self-service. Customer satisfaction increases all while costs decrease since you’re consuming fewer connected minutes and maximizing agent utilization.
About the author
Thomas Rindfuss is an Amazon Connect consultant for AWS Professional Services. He delivers proof-of-concept projects, re-usable artifacts, and leads implementation projects to assist customers in transforming their contact centers to Amazon Connect and the AWS platform.