AI/ML

Integrate Amazon Kendra and Amazon Lex using a search intent


Customer service conversations typically revolve around one or more topics and contain related questions. Answering these questions seamlessly is essential for a good conversational experience. For example, as part of a car rental reservation, you have queries such as, “What’s the charge for an additional driver?” or, “Do you have car seats for kids?” Starting today, you can use a search intent in your Amazon Lex bots to integrate with Amazon Kendra, so your bots can surface answers from Kendra.

Amazon Kendra was recently made generally available to all AWS customers, with exciting new features. Amazon Kendra provides you with a highly accurate and easy-to-use enterprise search service powered by machine learning. It offers a more intuitive way to search—using natural language—and returns more accurate answers, so your end-users can discover information stored within your organization’s vast amount of content.

We previously described how you can add an AWS Lambda function in an Amazon Lex bot to integrate with Kendra. For more information, see Smarter FAQ bots with Amazon Kendra. With this approach, you need to write and maintain integration code, and any updates to the configuration require updating this code. Now you can can add a search intent to get the answers you’re looking for from FAQ documents. You simply define the search index parameters in the intent as part of the bot definition. The bot queries the Amazon Kendra search index during the interaction if the user input doesn’t match any of the other configured intents. The search query responses are populated with request attributes that the bot can use in its response. You don’t have to write any Lambda code. The integration is simple, and you can seamlessly deliver natural language answers from Amazon Kendra in your Amazon Lex conversations.

This post shows how you can integrate an Amazon Lex bot with Amazon Kendra using a search intent, so you can quickly build a bot to provide answers in a conversation. The following diagram illustrates this solution.

Building a Lex bot

We will use the same conversation from the previous post to model a bot conversation:

User: Where’s the IT Help Desk?
Agent: 2nd floor; room 201 (two rights after you get out of the elevators).
User: Can I come in at noon?
Agent: Sure. What’s the nature of your problem?
User: I have a cracked laptop screen.
Agent: For verification purposes, can I get the last four digits of your employee ID?
User: 1234.
Agent: Got it, we’ll see you then to take a look at your screen.
User: How long does it take to fix a screen?
Agent: Laptop screen repairs typically take 4 hours.
User: What do I need to bring with me for a screen repair?
Agent: For a laptop screen repair, please bring your employee badge, laptop, and VPN fob.
User: How do I access my documents while my laptop is being repaired?
Agent: You can use Amazon Workdocs to access your documents.
User: Can I use WorkDocs on my tablet?
Agent: Yes. Users can access Amazon WorkDocs using free applications for iPad, Kindle Fire, and Android tablets that you can download from iTunes, Amazon Appstore for Android, and Google Play. Users can also access Amazon WorkDocs using the web browser on any mobile device.
User: When does the help desk close?
Agent: Our hours are from 11 AM to 2 PM.
User: Is there a coffee shop nearby?
Agent: There is one on the third floor and it’s open from 8 AM to 4 PM daily.

The first step is to build an Amazon Lex bot with intents to book an appointment and check appointment status. The MakeAppointment intent elicits the information required to make an appointment, such as the date, time, employee ID, and the nature of the issue. The CheckAppointmentStatus intent provides the status of the appointment. When a user asks a question that the Lex bot can’t answer with these intents, it uses the built-in KendraSearchIntent intent to connect to Amazon Kendra to search for an appropriate answer.

Deploying the sample bot

To create the sample bot, complete the following steps. This creates an Amazon Lex bot called help_desk_bot and a Lambda fulfillment function called help_desk_bot_handler.

  1. Download the Amazon Lex definition and Lambda code.
  2. In the AWS Lambda console, choose Create function.
  3. Enter the function name help_desk_bot_handler.
  4. Choose the latest Python runtime (for example, Python 3.8).
  5. For Permissions, choose Create a new role with basic Lambda permissions.
  6. Choose Create function.
  7. Once your new Lambda function is available, in the Function code section, choose Actions, choose Upload a .zip file, choose Upload, and select the help_desk_bot_lambda_handler.zip file that you downloaded.
  8. Choose Save.
  9. On the Amazon Lex console, choose Actions, and then Import.
  10. Choose the file help_desk_bot.zip that you downloaded, and choose Import.
  11. On the Amazon Lex console, choose the bot help_desk_bot.
  12. For each of the intents, choose AWS Lambda function in the Fulfillment section, and select the help_desk_bot_handler function in the dropdown list. If you are prompted “You are about to give Amazon Lex permission to invoke your Lambda Function”, choose OK.
  13. When all the intents are updated, choose Build.

At this point, you should have a working bot that is not yet connected to Amazon Kendra.

Creating an Amazon Kendra index

You’re now ready to create an Amazon Kendra index for your documents and FAQ. Complete the following steps:

  1. On the Amazon Kendra console, choose Launch Amazon Kendra.
  2. If you have existing Amazon Kendra indexes, choose Create index.
  3. For Index name, enter a name, such as it-helpdesk.
  4. For Description, enter an optional description, such as IT Help Desk FAQs.
  5. For IAM role, choose Create a new role to create a role to allow Amazon Kendra to access Amazon CloudWatch Logs.
  6. For Role name, enter a name, such as cloudwatch-logs. Kendra will prefix the name with AmazonKendra and the AWS region.
  7. Choose Next.
  8. For Provisioning editions, choose Developer edition.
  9. Choose Create.

Adding your FAQ content

While Amazon Kendra creates your new index, upload your content to an Amazon Simple Storage Service (Amazon S3) bucket.

  1. On the Amazon S3 console, create a new bucket, such as kendra-it-helpdesk-docs-<your-account#>.
  2. Keep the default settings and choose Create bucket.
  3. Download the following sample files and upload them to your new S3 bucket:

When the index creation is complete, you can add your FAQ content.

  1. On the Amazon Kendra console, choose your index, then choose FAQs, and Add FAQ.
  2. For FAQ name, enter a name, such as it-helpdesk-faq.
  3. For Description, enter an optional description, such as FAQ for the IT Help Desk.
  4. For S3, browse Amazon S3 to find your bucket, and choose help-desk-faq.csv.
  5. For IAM role, choose Create a new role to allow Amazon Kendra to access your S3 bucket.
  6. For Role name, enter a name, such as s3-access. Kendra will prefix your role name with AmazonKendra-.
  7. Choose Add.
  8. Stay on the page while Amazon Kendra creates your FAQ.
  9. When the FAQ is complete, choose Add FAQ to add another FAQ.
  10. For FAQ name, enter a name, such as workdocs-faq.
  11. For Description, enter a description, such as FAQ for Amazon WorkDocs mobile and web access.
  12. For S3, browse Amazon S3 to find your bucket, and choose workdocs-faq.csv.
  13. For IAM role, choose the same role you created in step 9.
  14. Choose Add.

After you create your FAQs, you can try some Kendra searches by choosing Search console. For example:

  • When is the help desk open?
  • When does the help desk close?
  • Where is the help desk?
  • Can I access WorkDocs from my phone?

Adding a search intent

Now that you have a working Amazon Kendra index, you need to add a search intent.

  1. On the Amazon Lex console, choose help_desk_bot.
  2. Under Intents, choose the + icon next to add an intent.
  3. Choose Search existing intents.
  4. Under Built-in intents, choose KendraSearchIntent.
  5. Enter a name for your intent, such as help_desk_kendra_search.
  6. Choose Add.
  7. Under Amazon Kendra query, choose the index you created (it-helpdesk).
  8. For IAM role, choose Add Amazon Kendra permissions.
  9. For Fulfillment, leave the default value Return parameters to client selected.

  10. For Response, choose Message, enter the following message value and choose + to add it:
    ((x-amz-lex:kendra-search-response-question_answer-answer-1))

  11. Choose Save intent.
  12. Choose Build.

The message value you used in step 10 is a request attribute, which is set automatically by the Amazon Kendra search intent. This response is only selected if Kendra surfaces an answer.  For more information on request attributes, see the AMAZON.KendraSearchIntent documentation.

Your bot can now execute Amazon Kendra queries. You can test this on the Amazon Lex console. For example, you can try the sample conversation from the beginning of this post.

Deploying on a Slack channel

You can put this solution in a real chat environment, such as Slack, so that users can easily get information. To create a Slack channel association with your bot, complete the following steps:

  1. On the Amazon Lex console, choose Settings.
  2. Choose Publish.
  3. For Create an alias, enter an alias name, such as test.
  4. Choose Publish.
  5. When your alias is published, choose the Channels
  6. Under Channels, choose Slack.
  7. Enter a Channel Name, such as slack_help_desk_bot.
  8. For Channel Description, add an optional description.
  9. From the KMS Key drop-down menu, leave aws/lex selected.
  10. For Alias, choose test.
  11. Provide the Client Id, Client Secret, and Verification Token for your Slack application.
  12. Choose Activate to generate the OAuth URL and Postback URL.

Use the OAuth URL and Postback URL on the Slack application portal to complete the integration. For more information about setting up a Slack application and integrating with Amazon Lex, see Integrating an Amazon Lex Bot with Slack.

Conclusion

This post demonstrates how to integrate Amazon Lex and Amazon Kendra using a search intent. Amazon Kendra can extract specific answers from unstructured data. No pre-training is required; you simply point Amazon Kendra at your content, and it provides specific answers to natural language queries. For more information about incorporating these techniques into your bots, please see the AMAZON.KendraSearchIntent documentation.

 


About the authors

Brian Yost is a Senior Consultant with the AWS Professional Services Conversational AI team. In his spare time, he enjoys mountain biking, home brewing, and tinkering with technology.

 

 

 

As a Product Manager on the Amazon Lex team, Harshal Pimpalkhute spends his time trying to get machines to engage (nicely) with humans.

 

 

 

 

 

Source link

Related posts

How to Reduce Overfitting With Dropout Regularization in Keras

Newsemia

MIMIC Chest X-Ray database to provide researchers access to over 350,000 patient radiographs

Newsemia

#6: Autonomy: The Quest to Build the Driverless Car – And How It Will Reshape Our World

Newsemia

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy

COVID-19

COVID-19 (Coronavirus) is a new illness that is having a major effect on all businesses globally LIVE COVID-19 STATISTICS FOR World