Creating a BankingBot on Amazon Lex V2 Console with support for English and Spanish

Amazon Lex is a service for building conversational interfaces into any application. The new Amazon Lex V2 Console and APIs make it easier to build, deploy, and manage bots. In this post, you will learn about about the 3 main benefits of Amazon Lex V2 Console and API, basic bot building concepts, and how to create a simple BankingBot on the Amazon Lex V2 Console.

The new Amazon Lex V2 Console and API have three main benefits:

  • You can add a new language to a bot at any time and manage all the languages through the lifecycle of design, test, and deployment as a single resource. The new console dashboard allows you to quickly move between different languages to compare and refine your conversations.
  • The Amazon Lex V2 API follows a simplified information architecture (IA) where intent and slot types are scoped to a specific language. Versioning is performed at the bot level so that resources such as intents and slot types don’t have to be versioned individually.
  • Amazon Lex V2 Console and API provides additional builder productivity tools and capabilities that give you more flexibility and control of your bot design process. For example, you can now save partially completed work as you script, test, and tune your configuration. You can also use the Conversation flow section to view the utterances and slot types for each intent.

You can access new Amazon Lex V2 Console from the AWS Management Console, the AWS Command Line Interface (AWS CLI), or via APIs. With the enhanced console and revised APIs, you can expedite building virtual agents, conversational IVR systems, self-service chatbots, or informational bots.

Basic bot concepts

Amazon Lex enables you to add self-service, natural language chatbots to your applications or devices. You can build bots to perform automated tasks such as scheduling an appointment or to find answers to frequent customer queries such as return policies. Depending on your user base, you can also configure your bot to converse in multiple languages.

In this post, you learn the basic concepts needed to create a simple BankingBot that can handle requests such as checking account balances, making bill payments, and transferring funds. When building conversational interfaces, you need to understand five main concepts:
When building conversational interfaces, you need to understand five main concepts:

  • Intents – An intent represents an action that the user wants to perform. This enables the bot to understand and classify what task a user is trying to accomplish. Your bot can support one or more related intents and are scoped to individual languages. For this post, our BankingBot is configured to understand intents in English and Spanish, such as CheckBalance, allowing your users to check the balance in their accounts, or TransferFunds for paying bills.
  • Utterances – Utterances are phrases that are used to trigger your intent. Each intent can be trained by providing a set of sample utterances. Based on these utterances, Amazon Lex can identify and invoke an intent based on natural language user input.
  • Slots and slot types – Slots are input data that a bot needs to complete an action or fulfill an intent. For the CheckBalance intent, the bot needs information regarding which account and date of birth to verify the user’s identity. This data is captured as slots, which is used to fulfill the intents. Amazon Lex has two types of slots:
    • Built-in slots – These slots provide a definition of how the data is recognized and handled. For example, Amazon Lex has the built-in slot type for AMAZON.DATE, which recognizes words or phrases that represent a date and converts them into a standard date format (for example, “tomorrow,” “the fifth of November,” or “22 December”).
    • Custom slots – These slots allow you to define and manage a custom catalog of items. You can define a custom slot by providing a list of values. Amazon Lex uses these values to train the natural language understanding model used for recognizing values for the slot. For example, you can define a slot type as accountType with values such as Checking, Savings, and Credit. You can also add synonyms for each value, such as defining Visa as a synonym for your Credit account.
  • Prompts and responses – These are bot messages that can be used to get information, acknowledge what the user said earlier, or confirm an action with the user before completing a transaction.
  • Fulfilling the user request – As part of fulfilling the user’s request, you can configure the bot to respond with a closing response. Optionally, you can enable code hooks such as AWS Lambda functions to run business logic.

Creating the bot

Now that you know about the basic building blocks of a bot, let’s get started. We configure the BankingBot to interact and understand the five intents in English and four intents in Spanish. We start off with a basic Welcome intent and then increase the complexity of the intent confirmations by adding custom slots, Lambda functions, and context management. The following table provides an overview of our intents.

Intent Built-in
Slots
Custom
Slots
Context Prompts/
Responses
App Integration
Welcome x
CheckBalance x x Lambda
FollowupCheckBalance* x x x Lambda
TransferFunds x x x
FallbackIntent x

*As of this writing, context management is only supported in US English.

To create your bot, complete the following steps:

  1. On the Amazon Lex V2 Console, choose Bots. If you’re in the Lex V1 Console, click on Switch to the new Lex V2 Console located in the left hand menu.
  2. Choose Create bot.

Choose Create bot.

  1. For Creation method, select Create.

3. For Creation method, select Create.

  1. For Bot name, enter BankingBot.
  2. Optionally, enter a description.

Optionally, enter a description.

  1. For Runtime role, select Create a new role with basic Amazon Lex permissions.

For Runtime role, select Create a new role with basic Amazon Lex permissions.

  1. Because this bot is only for demo purposes, it’s not subject to COPPA, so select No.

Because this bot is only for demo purposes, it’s not subject to COPPA, so select No.

  1. Leave the Idle session timeout and Advanced settings at their default.
  2. Choose Next.

Choose Next.

Adding languages

This sample BankingBot is configured for both US English and US Spanish. Let’s first add US English.

  1. For Select language, choose English (US).

If you’re building a voice-based bot, Amazon Lex comes pre-integrated with the neural speech-to-text voices from Amazon Polly. Try them out and see what voice fits your bot.

  1. Choose Add another language.
  2. For Select language, choose Spanish (US).
  3. Choose Done.

Congratulations, you have successfully created your BankingBot! Now, let’s bring it to life.

Congratulations, you have successfully created your BankingBot! Now, let’s bring it to life.

Creating intents and slots

In this section, we walk you through how to create 5 intents and related slots for your bot.

Intent 1: Welcome

At this point, the console automatically takes you into the Intent editor page, where a NewIntent is ready for you to configure. The BankingBot is a friendly bot, so let’s start by creating a simple Welcome intent to greet users.

  1. Scroll to Intent details, for Intent name, replace NewIntent to Welcome.

Scroll to Intent details, for Intent name, replace NewIntent to Welcome.

  1. Under Sample utterances, choose the Plain Text tab and add the following:
    Hi
    Hello
    I need help
    Can you help me?
    

  1. Under Closing responses, for Message, enter:
    Hi! I’m BB, the BankingBot. How can I help you today?

  2. Choose Save intent.

Choose Save intent.

  1. After your intent is saved, choose Build.
  2. Now that you’ve successfully built your first intent, choose Test and give it a try.

Now that you’ve successfully built your first intent, choose Test and give it a try.

Intent 2: CheckBalance

Now let’s get a bit fancier with a CheckBalance intent. This intent allows a user to check an account balance. The bot first validates the user by requesting their date of birth and then asks which account they want to check. This intent requires you to create a custom slot type, set up the intent and finally first set up a Lambda function for fulfillment.

Creating a custom slot

Now that you have added your Lambda function, you need to create a custom slot that can capture a user’s account types with valid values such as Checking, Savings, and Credit before creating the intents. To create a custom slot, follow these steps:

  1. In the navigation pane, drill down to the English (US) version of your bot.
  2. Under English (US), choose Slot types.

Under English (US), choose Slot types.

  1. On the Add slot type menu, choose Add blank slot type.

On the Add slot type menu, choose Add blank slot type.

  1. For Slot type name¸ enter accountType.
  2. Choose Add.

Choose Add.

  1. For Slot value resolution, select Restrict to slot values.

For Slot value resolution, select Restrict to slot values.

  1. Under Slot type values, add values for Checking, Savings, and Credit.

You’ve now created a custom slot type for accountType. You can also add synonyms in the second column to help the bot recognize additional references to the Credit slot, such as credit card, Visa, and Mastercard.

You’ve now created a custom slot type for accountType.

  1. Choose Save slot type.

Congratulations! You now have your first custom slot type.

Creating the intent

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

  1. In the navigation pane, under English (US), choose Intents.
  2. Choose New intent.
  3. For Intent name, enter CheckBalance.
  4. Choose Add.

Choose Add.

  1. Under Intent details, for Description, add a description.

Under Intent details, for Description, add a description.

  1. Under Sample utterances, choose the Plain Text tab and enter the following utterances:
    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}
    

  2. Choose Save intent.

In the chatbot lifecycle, this component can be leveraged to expand the chatbot’s understanding of its users by providing additional utterances. The phrases don’t need to be an exact match for user inputs, but should be representative of real-world natural language queries.

  1. Under Slots, choose Add slot.

Under Slots, choose Add slot.

For the CheckBalance intent, we set up two slots: account type and date of birth.

  1. For Name, enter accountType.
  2. For Slot type, choose accountType.
  3. For Prompts, enter:
    Sure. For which account would you like your balance?

  4. Choose Add.

Choose Add.

  1. Choose Add slot.

Choose Add slot

  1. For Name, enter dateofBirth.
  2. For Slot type, choose AMAZON.Date.
  3. For Prompts, enter For verification purposes, what is your date of birth?
  4. Choose Add.

Choose Add.

  1. Choose Save intent.

Preparing for intent 3: FollowupCheckBalance with context

Understanding the direction and context of an ever-evolving conversation is beneficial to building natural, human-like conversational interfaces. Being able to classify utterances as the conversation develops requires managing context across multiple turns. Consider when a user wants to follow up and check their account balance in a different account. You don’t want the bot to ask the user for their date of birth again. You want the bot to understand the context of the question and carry over the date of birth slot value from this intent into the follow-up intent.

To prepare for the third BankingBot intent, FollowupCheckBalance, you need to preserve this CheckBalance context as an output for future use.

  1. Under Contexts, for Output contexts, choose New Context tag.

Under Contexts, for Output contexts, choose New Context tag.

  1. For Context tag name, enter contextCheckBalance.
  2. Choose Add.

Choose Add.Now your context is stored for future use.

  1. Under Code hooks, select Use a Lambda function for fulfillment. To create the Lambda function, please follow the instructions in Appendix B below.

Under Code hooks, select Use a Lambda function for fulfillment.

  1. Choose Save Intent.
  2. Choose Build.
  3. After the bot building process is complete, you can test the intent by choosing Test.

After the bot building process is complete, you can test the intent by choosing Test.

You can also use the Conversation flow section to view the current state of your conversation flow and links to help you quickly get to that specific utterance, slot, or prompt.

You can also use the Conversation flow section to view the current state of your conversation

You learn how to create an intent with prompts and closing responses in the fourth intent, TransferFunds.

Intent 3: FollowupBalance

Next, we create a FollowupBalance intent, where the user might ask what the balance is for a different account. With this intent, you want to use the context management feature and utilize the context that you set up earlier with the CheckBalance intent.

  1. On the Intent editor page, under Intents, choose Add.
  2. Choose Add empty intent.

Choose Add empty intent.

  1. For Intent name¸ enter FollowupBalance.
  2. Choose Add.

Choose Add.

  1. For Description, enter:
    Intent to provide detail of expenses made for an account over a period of time.

For Description, enter Intent to provide detail of expenses made for an account over a period of time.

  1. In the Contexts section, for Input contexts, choose the context you just created in the CheckBalance intent.

In the Contexts section, for Input contexts, choose the context you just created in the CheckBalance intent.

  1. Under Sample utterances, on the Plain text tab, enter the following sample utterances:
    How about my {accountType} account
    What about {accountType}
    And in {accountType}?

  2. In the Slots section, choose Add slot.
  3. For Name, enter accountType.
  4. For Slot type, choose accountType.
  5. For Prompts, enter:
    You’d like the balance for which account?

  6. Choose Add.

Next, you create a second slot.

  1. Choose Add slot.
  2. For Name, enter dateofBirth.
  3. For Slot type, choose AMAZON.Date.
  4. For Prompts, enter:
    For verification purposes. What is your date of birth?

  5. Choose Add.
  6. In the Slots section, open the dateofBirth slot and choose Advanced options.
  7. Under Default values, enter the context and slot value for the CheckBalance intent
    (contextCheckBalance.dateofBirth).
  8. Choose Add default value.
  9. Choose Save.

Choose Save.

  1. In the Code hooks section, select Use a Lambda function for fulfillment.

In the Code hooks section, select Use a Lambda function for fulfillment.

  1. Choose Save intent.
  2. Choose Build.
  3. When your BankingBot is built, choose Test and try the FollowupBalance intent and can see if the dateofBirth slot from the CheckBalance intent is used.

Choose Test and try the FollowupBalance intent and can see if the dateofBirth slot from the CheckBalance intent is used.

Intent 4: TransferFunds

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

  1. On the Intent editor page, under Intents, choose Add.
  2. Choose Add empty intent.
  3. For Name, enter TransferFunds.
  4. Choose Add.
  5. For the intent description, enter:
    Help user transfer funds between bank accounts

  6. Under Sample Utterances, on the Plain Text tab, enter the following:
    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
    

Next, we create the transferAmount slot.

  1. Choose Add slot.
  2. For Name, enter transferAmount.
  3. For Slot type, choose AMAZON.Number.
  4. For Prompts, enter:
    How much would you like to transfer?

  5. Choose Add.

Next, create the sourceAccountType slot.

  1. Choose Add slot.
  2. For Name, enter sourceAccountType.
  3. For Slot type¸ choose accountType.
  4. For Prompts¸ enter:
    Which account would you like to transfer from?

  5. Choose Add.

Next, create the targetAccountType slot.

  1. Choose Add slot.
  2. For Name, enter targetAccountType.
  3. For Slot type¸ choose accountType.
  4. For Prompts¸ enter:
    Which account are we transferring to?

  5. Choose Add.
  6. Under Prompts, for Confirmation prompts, enter:
    Got it. So we are transferring {transferAmount} from {sourceAccountType} to {targetAccountType}. Can I go ahead with the transfer?

  7. For Decline responses, enter:
    The transfer has been cancelled.

For Decline responses, enter The transfer has been cancelled.

  1. Under Closing responses, for Message, enter:
    The transfer is complete. {transferAmount} should now be available in your {targetAccountType} account.

  2. Choose Save intent.
  3. Choose Build.
  4. Choose Test.

Intent 5: FallbackIntent

Your last intent is the fallback intent, which is used when the bot can’t understand or identify a specific intent. It serves as a catchall intent and can also be used to route the conversation to a human agent for more assistance.

  1. On the Intents list, choose FallbackIntent.
  2. Under Closing responses¸ for Message, enter:
    Sorry I am having trouble understanding. Can you describe what you'd like to do in a few words? I can help you find your account balance, transfer funds and make a payment.

Sorry I am having trouble understanding. Can you describe what you'd like to do in a few words? I can help you find your account balance, transfer funds and make a payment.

  1. Choose Save intent.
  2. Choose Build.

Configuring the bot for Spanish

Amazon Lex V2 Console also allows you add multiple languages to a bot. Each language has an independent set of intents and slot types. Each intent follows the same structure as its English counterpart.

Intent 1: Welcome (Spanish)

To create the Welcome intent in Spanish, complete the following steps:

  1. In the navigation pane, under Spanish (US), choose Intents.
  2. Choose NewIntent.

Choose NewIntent

  1. For Intent name, enter Welcome.
  2. Choose Add.

Choose Add.

  1. Under Sample utterances, on the Plain text tab, enter the following:
    Hola
    Necesito ayuda
    Me podría ayudar?
    

Under Sample utterances, on the Plain text tab, enter the following:

  1. Under Closing responses, for Message, enter:
    Bienvenido! Puedo ayudarle con tareas como chequear balance o realizar un pago. Cómo puedo ayudarle hoy?

Bienvenido! Puedo ayudarle con tareas como chequear balance o realizar un pago. Cómo puedo ayudarle hoy?

  1. Choose Save intent.
  2. Choose Build.

Intent 2: CheckBalance (Spanish)

To create the CheckBalance intent, you first need to create the accountType custom slot type as you did for the English bot.

  1. Under Spanish (US), choose Slot types.
  2. On the Add slot type menu, choose Add a blank slot type.

On the Add slot type menu, choose Add a blank slot type.

  1. For Slot type name, enter accountType.
  2. Choose Add.
  3. In the Slot value resolution section, select Restrict to slot values.
  4. Add the Spanish slot values Cheques (Checking), Ahorro (Savings), and Crédito (Credit).

Add the Spanish slot values Cheques (Checking), Ahorro (Savings), and Crédito (Credit).

  1. Choose Save slot type.

You have now created the accountType custom slot.

  1. In the navigation pane, under Spanish (US), choose Intents.
  2. On the Add intent menu, choose Add empty intent.

On the Add intent menu, choose Add empty intent.

  1. For Intent name, enter CheckBalance.
  2. Choose Add.
  3. For Description, enter:
    Intent to check balance in the specified account

  4. Under Sample utterances, on the Plain text tab, enter the following:
    Cuál es el balance en mi cuenta?
    Verificar balance en mi cuenta
    Cuál es el balance en la cuenta {accountType}
    Cuál es el balance en {accountType}
    Cuánto hay en {accountType}
    Quiero verificar el balance
    Me podría ayudar con el balance de mi cuenta?
    Balance en {accountType}
    

Under Sample utterances, on the Plain text tab, enter the following:

  1. Choose Add slot.
  2. For Name, enter accountType.
  3. For Slot type, choose accountType.
  4. For Prompts, enter:
    Por supuesto. De qué cuenta le gustaría conocer el balance?

  5. Choose Add slot.
  6. For Name, enter dateofBirth.
  7. For Slot type, choose AMAZON.Date.
  8. For Prompts, enter:
    Por supuesto. Por motivos de verificación. Podría por favor compartir su fecha de nacimiento?

  9. Choose Add.
  10. Under Code hooks, select Use a Lambda function for fulfillment. For the Spanish version of your bot, you will need a new Lambda function for Spanish. To create a Lambda function, please follow the instructions in Appendix B below.
  11. Choose Save intent.
  12. Choose Build.

Intent 3: TransferFunds (Spanish)

Like the English version, the TransferFunds intent offers the functionality of moving funds from one account to another. This intent allows you to work with two slots of the same type and configure confirmations and prompts.

  1. Create a new intent and name it TransferFunds.
  2. For the intent description, enter:
    Intent to transfer funds between checking and savings accounts.

  3. Under Sample utterances, on the Plain Text tab, enter the following:
    Quisiera transferir fondos
    Puedo realizar una transferencia?
    Necesito hacer una transferencia.
    Quisiera transferir {transferAmount} desde {sourceAccountType} hacia {targetAccountType}
    Puedo transferir {transferAmount} hacia {targetAccountType} ?
    Can I transfer {transferAmount} to my {targetAccountType}
    Necesito ayuda con una transferencia.
    Me ayudaría a realizar una transferencia?
    Necesito realizar una transferencia.
    

Next, create the transferAmount slot.

  1. Choose Add slot.
  2. For Name, enter transferAmount.
  3. For Slot Type, choose AMAZON.Number.
  4. For Prompts,
    Qué monto desea transferir?

  5. Choose Add.

Next, create the sourceAccountType slot.

  1. Choose Add slot.
  2. For Name, enter sourceAccountType.
  3. For Slot type, choose accountType.
  4. For Prompts, enter
    Desde qué cuenta desea iniciar la transferencia?

  5. Choose Add.

Next, create the targetAccountType slot.

  1. Choose Add slot.
  2. For Name, enter targetAccountType.
  3. For Slot type, choose accountType.
  4. For Prompts, enter
    Hacia qué cuenta desea realizar la transferencia?

  5. Choose Add.
  6. Under Prompts, for Confirmation prompts, enter:
    Usted desea transferir {transferAmount} dólares desde la cuenta {sourceAccountType} hacia la cuenta {targetAccountType}. Puedo realizar la transferencia?

  7. For Decline responses, enter:
    No hay problema. La transferencia ha sido cancelada.

  8. Under Closing responses, for Message, enter:
    La transferencia ha sido realizada. {transferAmount} deberían estar disponibles en su cuenta {targetAccountType}.

  9. Choose Save intent.
  10. Choose Build.

Conclusion

Congratulations! You have successfully built a BankingBot that can check balances, transfer funds, and properly greet a customer. You also seen how easy it is to add and manage new languages. Additionally, the Conversation flow section lets you view and jump to different parameters of the conversation as you build and refine the dialogue for each of your intents.

To learn more about Amazon Lex V2 Console and APIs, check out the following resources:

Also, you could give your bot the ability to reply to natural language questions by integrating it with Amazon Kendra. For more information, see Integrate Amazon Kendra and Amazon Lex using a search intent.

Appendix A: Bot configuration

This example bot contains five intents that allow a user to interact with the financial institution and perform the following tasks:

  • Welcome – Intent to greet users
  • CheckBalance – Intent to check balance in the specified account
  • FollowupBalance – Intent to provide detail of expenses made for an account over a period of time
  • TransferFunds – Intent to transfer funds between checking and savings accounts
  • FallbackIntent – Default intent to respond when no other intent matches user input

Intents details: English

  1. Welcome configuration
    1. Description: Intent to greet users
    2. Sample utterances:
      • Hi
      • Hello
      • I need help
      • Can you help me?
    3. Closing response: Hi! I’m BB, the BankingBot. How can I help you today?
  1. CheckBalance configuration
    1. Description: Intent to check balance in the specified account
    2. Sample utterances:
      • 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}
    3. Slots:
      • accountType:
        • Custom slot type: accountType
        • Prompt: For which account would you like to check the balance?
      • dateofBirth:
        • Built-in slot type: AMAZON.Date
        • Prompt: For verification purposes, what is your date of birth?
    4. Context tag:
      • contextCheckBalance
        • Output contexts
    5. Closing response: Response comes from the fulfillment by the Lambda function.
  1. FollowupBalance configuration
    1. Description: Intent to provide detail of expenses made for an account over a period of time.
    2. Sample utterances:
      • How about my {accountType} account
      • What about {accountType}
      • And in {accountType}?
      • how about {accountType}
    3. Slots:
      • dateofBirth:
        • Built-in slot type: AMAZON.Date (default: #CheckBalance.dateOfBirth)
        • Prompt: For verification purposes. What is your date of birth?
      • accountType:
        • Custom slot type: accountType
        • Prompt: Which account do you need the balance details for? (default: #contextCheckBalance.dateofBirth)
    4. Closing response: Response comes from the fulfillment Lambda function.
  1. TransferFunds configuration
    1. Description: Intent to transfer funds between checking and savings accounts.
    2. Sample utterances:
      • 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
    3. Slots:
      • sourceAccountType:
        • Custom slot type: accountType
        • Prompt: Which account would you like to transfer from?
      • targetAccountType:
        • Custom slot type: accountType
        • Prompt: Which account are we transferring to?
      • transferAmount:
        • Built-in slot type: AMAZON.Number
        • Prompt: What amount are we transferring today?
    4. Confirmation prompt: Got it. So we are transferring {transferAmount} dollars from {sourceAccountType} to {targetAccountType}. Can I go ahead with the transfer?
    5. Decline response: Sure. The transfer has been cancelled.
    6. Closing response: The transfer is complete. {transferAmount} should now be available in your {targetAccountType} account.
  1. FallbackIntent configuration
    1. Description: Default intent to respond when no other intent matches user input.
    2. Closing response: Sorry I am having trouble understanding. Can you describe what you’d like to do in a few words? I can help you with account balance, transfer funds and payments.

Intent details: Spanish

  1. AccountBalance configuration
    1. Description: Intent to check balance in the specified account.
    2. Sample utterances:
      • Cuál es el balance en mi cuenta?
      • Verificar balance en mi cuenta
      • Cuál es el balance en la cuenta {accountType}
      • Cuál es el balance en {accountType}
      • Cuánto hay en {accountType}
      • Quiero verificar el balance
      • Me podría ayudar con el balance de mi cuenta?
      • Balance en {accountType}
    3. Slots:
      • accountType:
        • Custom slot type: Restrict values to Cheques, Ahorros, and Crédito
        • Prompt: Por supuesto. De qué cuenta le gustaría conocer el balance?
      • dateofBirth:
        • Built-in slot type: AMAZON.Date (default: #CheckBalance.dateOfBirth)
        • Prompt: Por supuesto. Por motivos de verificación. Podría por favor compartir su fecha de nacimiento?
    4. Closing response: Response comes from the fulfillment Lambda function.
  1. TransferFunds configuration
    1. Description: Intent to transfer funds between checking and savings accounts.
    2. Sample utterances:
      • Quisiera transferir fondos
      • Puedo realizar una transferencia?
      • Necesito hacer una transferencia.
      • Quisiera transferir {transferAmount} desde {sourceAccountType} hacia {targetAccountType}
      • Puedo transferir {transferAmount} hacia {targetAccountType} ?
      • Necesito ayuda con una transferencia.
      • Me ayudaría a realizar una transferencia?
      • Necesito realizar una transferencia.
    3. Slots:
      • sourceAccountType:
        • Custom slot type: Restrict Values to Checking, Savings, and Credit
        • Prompt: Desde qué cuenta desea iniciar la transferencia?
      • targetAccountType:
        • Custom slot type: Restrict Values to Checking, Savings, and Credit
        • Prompt: Hacia qué cuenta desea realizar la transferencia?
      • transferAmount:
        • Built-in slot type: AMAZON.Number
        • Prompt: Qué monto desea transferir?
    4. Confirmation prompt: Entendido. Usted desea transferir {transferAmount} dólares desde la cuenta {sourceAccountType} hacia la cuenta {targetAccountType}. Puedo realizar la transferencia?
    5. Decline response: No hay problema. La transferencia ha sido cancelada.
    6. Closing response: La transferencia ha sido realizada. {transferAmount} deberían estar disponibles en su cuenta {targetAccountType}
  1. FallbackIntent configuration
    1. Description: Default intent to respond when no other intent matches user input
    2. Closing response: Lo siento, no he entendido. En pocas palabras, podría describer que necesita hacer? Puedo ayudarlo con balance de cuenta, transferir fondos y pagos.

Appendix B: Creating a Lambda function

In Amazon Lex V2 Console, you use a single Lambda function as a fulfillment mechanism for all of your intents. This function is defined in the Alias language support page. You will need to create a separate Lambda function for each language you have specified for your bot. For this example bot, you will need to create a unique Lambda function for the English US and Spanish US language in your bot.

  1. In the top left corner, click on the Services drop down menu and select Lambda in the Compute section.In the top left corner, click on the Services drop down menu and select Lambda in the Compute section.
  2. On the Lambda console, choose Functions.
  3. Choose Create function.

Choose Create function.

  1. Select Author from scratch.

Select Author from scratch.

  1. For Function name, enter a name. For the English version, enter BankingBotEnglish for the Function name. For the Spanish version, enter BankingBotSpanish.
  2. For Runtime, choose Python 3.8.

For Runtime, choose Python 3.8.

  1. Choose Create function.
  2. In the Function code section, choose lambda_function.py.
  3. Download the Lambda BankingBotEnglish or BankingBotSpanish code for the specific language and open it in a text editor.
  4. Copy the code and replace the current function code with the Lambda BankingBotEnglish code or BankingBotSpanish code for the respective language.
  5. Choose Deploy.

Adding the Lambda function to your language

Now you have set up your Lambda function. In Amazon Lex V2 Console, Lambda functions are defined at the bot alias level. Follow these steps to set up your bot to use a Lambda function:

  1. On the Amazon Lex V2 Console, in the navigation pane, under your bot, choose Aliases.

On the Amazon Lex V2 console, in the navigation pane, under your bot, choose Aliases.

  1. Choose TestBotAlias.

Choose TestBotAlias.

  1. For Languages, select English (US) or Spanish (US) depending on which fulfillment Lambda function you are creating.

For Languages, select English (US).

  1. For Source, choose BankingBotEnglish or BankingBotSpanish as your source depending on which language you are configuring.
  2. For Lambda function version or alias, choose your function.
  3. Choose Save.

Choose Save.

Now your Lambda function is ready to work with your BankingBot intents.


About the Author

Juan Pablo Bustos is an AI Services Specialist Solutions Architect at Amazon Web Services, based in Dallas, TX. Outside of work, he loves spending time writing and playing music as well as trying random restaurants with his family.

 

 

 

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

 

 

 

Esther Lee is a Product Manager for AWS Language AI Services. She is passionate about the intersection of technology and education. Out of the office, Esther enjoys long walks along the beach, dinners with friends and friendly rounds of Mahjong.

Read More