2. Create Lex Lambda Function

Here we will create a Lambda function that has some Python code to detect the intent name (GetAccountDetail, GetLoanDetail and GetLoanProducts) and to return static values based on the AccountType (checking, saving) or LoanType (car, home) included in the intent.

In a real world example we would need to first authenticate the user using account linking and would write codes to do database queries for individual’s account balances. In this lab, as we only focus on the development of Alexa skill instead of a fulfilled backend application, we will simply hard code account balances and leave the database combination part to your own exploration. We will also cover the account linking part in lab2.

  1. Go to AWS Lambda Console

  2. Click on the orange Create function button, If you have not created any Lambda function before, you may see the Get Started page

  3. Select Author from scratch option

  4. Let’s give our function the name of bot-personal-assistant. Feel free to choose a different name.

  5. Choose Python 2.7 as the Runtime

  6. Under Permission*, select Create new role from AWS policy templates.

  7. Enter bot-personal-assistant-lambda-role for role name and leave the policy template empty.

  8. Click Create Function button

  9. Scroll down to the integrated Cloud9 editor on the Lambda console.

  10. Download the lambda function code lex-lambda-personal-banker.py. Copy and paste the code into the inline editor (while making sure to overwrite/delete any template code that is already in the code box). Take a few minutes to review the code. Please note if you named your intents differently, you will have to update the dispatch method accordingly.

  11. We are not going to configure any trigger now, so click ‘Save’ on the top right hand corner of the page. You should see a message like this.

If lambda alerts any errors, please check the python codes’s indents.