AWS AI Services Programming Series - Part2 (Lex)

   Go back to the Task List

  « 2: Create Lambda Function    4: Configure the Development Environment »

3: Configure Chat Bot

Let’s do the interesting part of the workshop and configure the chat bot in Amazon Lex which uses the Lambda function as the backend.

  1. Goto the Amazon Lex console and click on the Get Started button.

    Lex

  2. On the next screen, click on the Custom bot button.

    Lex

  3. On the next screen, type in calculatorbot as the Bot name. Select Salli as the output voice. Type in 5 for the Session timeout. Select No option for Sentiment analysis, COPPA and Advanced options and click on the Create button.

    Lex

  4. The bot is created in no time. Click on the + Create Intent button on the next page.

    Lex

  5. On the popup window, click on the Create Intent option.

    Lex

  6. On the next popup screen, type in calculatorintent as the intent and click on the Add button.

    Lex

  7. On the next calculatorintent screen, add the following Sample utterances. Utterances are the sentences / words which are used to invoke the corresponding intent.

    calculator

    I want to calculate

    start calculator

    Lex

  8. In the Slots section, configure the slots as shown below. The slots are used to create interaction in the chat bot and capture the user input. You capture two numbers and the operation (+, -, *, /) for the calculation in the slots here. If you check the Lambda code again, you can related how the slot values are used to build business logic in the Lambda function. Please make sure all the slots are configured exactly how shown in the screen below.

    Lex

  9. In the Confirmation prompt section, check for the Confirmation prompt option. Type in do you want to add {op} {dataone} and {datatwo}? in the confirm field and Thanks for using the calculator. in the cancel field. This section is used by the bot to have confirmation with the user.

    Lex

  10. Next, in the Fulfillment section, select AWS Lambda function as the option. Select dojobotfunction as the Lambda Function and select Latest as the Version or alias. In this part, you configure to use Lambda function as the backend service.

    Lex

  11. It will ask for the Lambda access permission in the popup, click OK on the popup window.

    Lex

  12. The intent configuration is complete. Click on the Save Intent button.

    Lex

  13. The intent is saved in no time. Click on the Build button on the top. When it asks for the confirmation in popup, click on the Build button again.

    Lex

  14. The build will start and it will take a while to finish. Wait till you see a confirmation message.

    Lex

  15. The bot is almost ready. Let’s test it before you publish. Lex comes with a built-in test client. Click on the Test Chatbot in the right.

    Lex

  16. Perform test on the chat bot as shown below. You will start the chat, it will throw questions back to you based on the slots and you provide inputs. Finally it asks for the confirmation and once you say yes, it calls Lambda function and presents the return result back in the chat.

    Lex

  17. The chat bot is working as expected. Let’s publish it and we also build a client to use this chat bot. Click on the Publish button on the top.

    Lex

  18. It throws a popup asking for the alias name for the chat bot. Type in dojoalias as the alias and click on the Publish button.

    Lex

  19. It will start the chat bot publishing which will take few mins to complete. Wait for the publishing to finish. Make note of the bot name calculatorbot and alias dojoalias as we need them in the next task. Click on the Close link.

    Lex

  20. The chat bot is ready. Let’s build chat client in the next task.