Overview: In this blog, I will walk you through the whole process of making chatbots using Amazon Lex and Lambda function.
Letâs take a look at the Chatbot Technology and AWS Service used in this blog:
What is Chatbot Technology? Chatbot is a service or tool that you can communicate with via chat interface. Chatbot understands what you are trying to imply and replies with a relevant message or directly completes the desired task for you.
What is Amazon Lex Bot? Amazon Lex is a fully managed service for building conversational interfaces into any application using voice and text which provides the advanced deep learning functionalities of automatic speech recognition (ASR) for converting speech to text, and natural language understanding (NLU) to recognize the intent of the text. Amazon Lex enables you to quickly & easily build chatbots with highly engaging user experiences and lifelike conversational interactions. As a fully managed service, Amazon Lex scales automatically, so you donât need to worry about managing infrastructure.
We Leverage Lexâs integration with AWS Lambda to execute and validate logic or data processing on the backend.
Building Chatbots using Amazon Lex: In this blog, we will be creating two chatbots âLoan Statusâ and âBanking Servicesâ.
1. Build and Test âLoan Statusâ chatbot: In this module, we will build a chatbot âLoan Statusâ in Lex which would be used to handle information queries coming from customers and answer some of the customerâs questions checking the requirement to apply a loan, tracking their loan status and required documents to apply for personal loan.
Create a Lex bot: Use the Lex Console to create a bot named âLoan Statusâ. Fill all the details given below in the screenshot and click Create.
Create the intent: Letâs create our intent âHelloâ in the Lex bot.
Configure sample utterances: By providing sample utterances for a given intent, you can teach Amazon Lex different ways a user might convey an intent. Adding two sample utterances to the intent âHiâ and âHelloâ.
Configure Slots: Slots are parameters we define to capture inputs from our customers. In this example, the input parameter the bot needs in to fulfill the informational query by addressing customer using customer name.
Because there is a built-in slot for names, we will leverage it for this intent and configure a slot Name with built-in type AMAZON.GB.FIRST_NAME. And the Prompt would be a question asked by bot to get the customer name and store this name to the Name parameter in slot.
Here we have a Prompt âWhat is your Name?â
Once Customer will answer his/her Name it will store in the slot for further use and bot will call the customer by Name.
Here you can see after getting Promptâs response from customer bot Response would be âHi{Name}, My Name is Mathewbot!! How can I help you?â After writing the Response from chatbot we will save this âHelloâ intent.
Create the intent: Letâs create our intent âApply Loanâ in the Lex bot.
Configure sample utterances: Adding sample utterances to the intent:
¡ How to apply for a loan in your bank
¡ Can I apply for a loan
¡ What is the procedure to apply for a loan
Configure Slots: In this example the bot needs in to fulfill the informational query by addressing requested loan type.
We will create a Slot type named Loantype and store 4 values (Home, Car, Personal and Education).
Then configure a Slot Name typeofloan with this Slot type in the intent. And the Prompt would be a question asked by bot to get the type of loan customer wants to apply and store this name to the Name parameter in slot.
Here we have a Prompt âWhat type of loan you are applying for?â
Once Customer will answer type of loan it will store in the slot for further use.
Here you can see after getting Promptâs response from customer bot Response would be: âTo apply for a {typeofloan} loan, you can either do it online or in person to the nearest bank branch. you can visit the official website of the bank and provide details such as name, income, employment and property documents to apply for a {typeofloan} loan. Once application submission is over, the bank will process your application and approve your {typeofloan} loanâ After writing the Response from chatbot we will save this âHelloâ intent.
Text Bot :
2. Build and Test âBank Servicesâ chatbot using Lambda:In this module, we will build a chatbot âBanking Servicesâ in Lex using lambda which would be used to handle customer requests for fetching some personal details like their bank balance from their savings and current account.
Create a Lex bot: Use the Lex Console to create a bot named âBank Servicesâ. Fill all the details given below in the screenshot and click Create.
Create the intent: Letâs create our intent âCheck Balanceâ in the Lex bot.
Configure sample utterances: Adding sample utterances to the intent:
¡ Can I check my bank balance
¡ how much money I have in my bank account
¡ check my bank balance
Configure Slots: In this example the bot needs in to fulfill the requested details by addressing requested bank account type and PIN Number to verify the account.
We will create a Slot type named account type and store two values (Current and Savings).
Then configure a Slot Name accounttype with created Slot type in the intent. And the Prompt would be a question asked by bot to get the type of loan customer wants to apply and store this name to the Name parameter in slot.
Here we have a Prompt âWhat type of account do you have Current or Savings?â
Because there is a built-in slot for four-digit number as PIN, we will leverage it for this intent and configure a slot Name PinNumber with built-in Slot type AMAZON.FOUR_DIGIT_NUMBER.
Here we have a Prompt âWhat is your PIN number for your {accounttype} account?
Once Customer will fill their account type and Pin Number they will be stored in the slots for further use.
Here you can see after getting Promptâs response from customer bot uses a Confirmation Prompt which is used to ensure all the details by customers are correct.
To confirm Confirmation Prompt âAre you sure your {accounttype} is correct?â If customer respond with âyesâ then a lambda function named Check BalanceLambda will be triggered where we have provided the python code to get all the details customer is asking for.
To cancel Confirmation Prompt âPlease enter your correct account typeâ.
After writing the Response from chatbot we will save this âCheck Balanceâ intent.
Text Bot :
Summary: In this blog we have seen how to create a chatbot using Aws services. In my future blogs I will be covering more features of chatbots as well as itâs integration and connection with websites and other AWS Services.