Create a BankingBot with English and Spanish support in the Amazon Lex V2 console

TUTORIAL

Module 2: Add English (US) Intents

You will configure your BankingBot by creating intents and slots for English (US)

What you will accomplish

In this module, you configure your BankingBot by creating intents and slots for English (US). Remember that an intent is an action that the user wants to perform, and a slot is the input data the bot needs to fulfill it. For this Module, you will create the following intents that allow the user to interact with the financial institution:

  • Welcome: greets users.
  • CheckBalance: checks the balance of the account specified by the user and references input data from two slots: accountType and dateofBirth.
  • FollowupBalance: provides details of transactions made in an account over a period of time and references data from two slots: accountType and dateofBirth.
  • TransferFunds: transfers funds between accounts and references input data from three slots: sourceAccountType, targetAccountType, and transferAmount.
  • FallbackIntent: provides a default response when no other intent matches the user input data.

 Time to complete

30 minutes

 Requires

Completion of Module 1

Implementation

Step 1: Create the Welcome Intent

First, start by creating the Welcome intent. BankingBot is friendly and the Welcome intent provides a simple greeting to users.

In the Amazon Lex Intent editor, select NewIntent.

In the Intent details section, for Intent name, replace NewIntent with Welcome.

In the Sample utterances section, either type or copy/paste the following utterances.

These phrases will trigger the Welcome intent for the BankingBot to respond.

Hi
Hello
I need help
Can you help me?

In the Closing responses section, for Message, add the following text.

This phrase is the BankingBot's Welcome intent response to the user's utterances.

Hi! I'm BB, the BankingBot. How can I help you today?

Choose Save intent. Then, choose Build.

Now, test your intent. Choose Test to open a chat window and type hi to your BankingBot.

Congratulations! You've created your first intent.  Lets create the remaining intents.

Step 2: Create the CheckBalance Intent

The CheckBalance intent allows a user to check an account balance. The bot validates the user by requesting their date of birth, then asks which account they want to check. Since this intent requires slots, we will first create two custom slot types before creating the intent. Unlike other intents you are creating, this one requires a Lambda function for fulfillment so ensure you’ve completed all tasks in the previous Module before continuing.

Step 2a: Create the custom slot type

In the left navigation pane of the Lex V2 console, navigate to BankingBot > Bot versions > Draft version > All languages > English (US) > Slot types. Choose Add slot type, then choose Add blank slot type.

In the Add blank slot type dialog box, for Slot type name, type accountType. Then, choose Add.

On the Slot types editor page, for Slot value resolution, choose Restrict to slot values.

For Slot type values, add Checking, Savings, and Credit. You can also add synonyms in the second column to help the bot recognize additional references to the Credit slot. For example, add credit card, Visa, and Mastercard.

Choose Save slot type.

Congratulations! You now have your first custom slot type.

Step 2b: Create the intent

Now, create the CheckBalance intent. This intent allows a user to check an account balance. The BankingBot first validates the user by requesting their date of birth and then asks which account they want to check. It uses the accountType custom slot and Lambda function for fulfillment.

In the left navigation pane of the console, navigate to BankingBot > Bot versions > Draft version > All languages > English (US) > Intents. Choose Add intent, then choose Add empty intent.

For Intent name, type CheckBalance. Then, choose Add.

In the Sample utterances section, either type or copy/paste the following utterances in the Plain Text tab then choose Save intent.

What's the balance in my account?
Check my account balance
What's the balance in {accountType} ?
How much do I have in {accountType} ?
I want to check the balance
Can you help me with account balance?
Balance in {accountType}

In the Slots section, choose Add slot.

On the Add slot dialog, specify the following:

  • For Name, type accountType.
  • For Slot type, choose accountType.
  • For Prompts, type Sure. For which account would you like the balance?

Choose Add.

Add the second slot by again selecting Add Slot.   

On the Add slot dialog, specify the following:

  • For Name, type dateofBirth.
  • For Slot type, choose AMAZON.Date.
  • For Prompts, type For verification purposes, what is your date of birth?

Choose Add.

Choose Save intent.

Great! You've created the CheckBalance intent and set up two slots: accountType and dateofBirth.

Step 2c: Create the context

To prepare for the FollowupCheckBalance intent, you need to save the CheckBalance intent context as an output for future use. In this way, when conversing with BankingBot, the user can request a second account balance with the FollowupCheckBalance intent, and the BankingBot will use the context to know the user's date of birth and not prompt for the same verification information again.

In the Contexts section, for Output contexts, choose New context tag.

In the Add new context tag dialog box, for Context tag name, type contextCheckBalance. Then, choose Add.

Step 2d: Activate Fulfillment and Test

In the Fulfillment section, toggle the slider to Active.  Choose Save intent.

Choose Build and wait for it to complete.  Now choose Test and test the CheckBalance intent by typing an account type, like savings. It should prompt you for a date of birth and then return a balance.  You can enter any date for testing.  

You can also use the Conversation flow section to view the current state of your conversation flow and links to help quickly locate specific utterances, slots, or prompts

Step 3: Create the FollowupBalance Intent

On the Intent editor page, under Intents, choose Add intent, then choose Add empty intent.

In the Add empty intent dialog box, for Intent name, type FollowupBalance. Then, choose Add.

On the Intent editor page, in the Intent details section, for Description, type Intent to provide detail of expenses made in an account over a period of time.

In the Contexts section, for Input contexts, choose the contextCheckBalance input context you created in Step 2.

In the Sample utterances section, either type or copy/paste the following utterances in the Plain Text tab then choose Save intent.

How about my {accountType} account
What about {accountType}
And in {accountType} ?

In the Slots section, choose Add slot.

On the Add slot dialog, specify the following:

  • For Name, type accountType.
  • For Slot type, choose accountType.
  • For Prompts, type You'd like the balance for which account?

Choose Add.

Again select Add slot.

On the Add slot dialog, specify the following:

  • For Name, type dateofBirth.
  • For Slot type, choose AMAZON.Date.
  • For Prompts, type For verification purposes, what is your date of birth?

Choose Add.

In the Slots section, expand the dateofBirth slot and choose Advanced options.

In the Default values section, type the context and slot value for the CheckBalance intent #contextCheckBalance.dateofBirth and choose Add default value. Then, choose Update slot.

In the Fulfillment section, toggle the slider to Active.  Choose Save intent. 

Now lets test that the FollowupBalance intent is using the dateofBirth slot from the CheckBalance intent. Choose Build and wait for the it to complete then select Test.

Type an account type to BankingBot, like savings. BankingBot should prompt you for a date of birth and then return a balance. You can use any date for testing.  Now, ask for balance on another account, for example checking. BankingBot should return the balance without prompting for another verification.

Note: The context will timeout after 90 seconds and prompt the user for verification again.

Step 4: Create the TransferFunds Intent

The TransferFunds intent offers the functionality of moving funds from one account to a target account. For this, you learn how to create two different slots using the same slot type and how to configure confirmation prompts and declines.

On the Intent editor page, under Intents, choose Add, then choose Add empty intent.

In the Add empty intent dialog box, for Intent name, type TransferFunds. Then, choose Add.

On the Intent editor page, in the Intent details section, for Description, type Help users transfer funds between bank accounts.

In the Sample utterances section, either type or copy/paste the following utterances in the Plain Text tab then choose Save intent.

I want to transfer funds
Can I make a transfer?
I want to make a transfer
I'd like to transfer {transferAmount} from {sourceAccountType} to {targetAccountType}
Can I transfer {transferAmount} to my {targetAccountType}
Would you be able to help me with a transfer?
Need to make a transfer

In the Slots section, choose Add slot.

On the Add slot dialog, specify the following:

  • For Name, type transferAmount.
  • For Slot type, choose AMAZON.Number.
  • For Prompts, type How much would you like to transfer?

Choose Add.

Again, choose Add slot.

On the Add slot dialog, specify the following:

  • For Name, type sourceAccountType.
  • For Slot type, choose accountType.
  • For Prompts, type Which account would you like to transfer from?

Choose Add.

Again, choose Add slot.

On the Add slot dialog, specify the following:

  • For Name, type targetAccountType.
  • For Slot type, choose accountType.
  • For Prompts, type Which account are we transferring to?

Choose Add.

Expand the Confirmation section and specify the following:

  • For Confirmation prompt, type Got it. So we are transferring {transferAmount} from {sourceAccountType} to {targetAccountType}. Can I go ahead with the transfer?
  • For Decline response, type The transfer has been cancelled.
  • Toggle the slider to Active

Choose Save intent.
 

In the Closing response section, expand Response sent to the user after the intent is fulfilled and under Message Group add the following:

  • For Message, type The transfer is complete. {transferAmount} should now be available in your {targetAccountType} account.
  • Toggle the slider to Active

Choose Save intent. Then, choose Build.

Step 5: Create the Fallback Intent

The Fallback intent is used when the bot can't understand or identify a specific intent. It serves as a catch-all intent and can guide the user to rephrase their question or provide hints about the commands the bot understands.  

On the Intent editor page, under Intents, choose FallbackIntent.

In the Closing response section, expand Response sent to the user after the intent is fulfilled and under Message Group add the following:

  • For Message, type Sorry I am having trouble understanding. I can help you find your account balance, transfer funds, and make a payment.
  • Toggle the slider to Active

Choose Save intent. Then, choose Build.
 

Conclusion

In this module, you configured your BankingBot with five intents for English (US).

In the next module, you configure your bot with the intents for Spanish (US).

Add Spanish (US) Intents

Was this page helpful?