--- title: "2. Create Lex Lambda Function" date: 2019-09-05T23:06:51+08:00 draft: false chapter: false weight: 153 --- 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](https://console.aws.amazon.com/lambda/home?region=us-east-1#/functions) 1. Click on the orange **Create function** button, If you have not created any Lambda function before, you may see the Get Started page 1. Select **Author from scratch** option ![](/images/ask/create-lambda-function.png) 1. Let’s give our function the name of `bot-personal-assistant`. Feel free to choose a different name. 1. Choose **Python 2.7** as the Runtime 1. Under **Permission***, select **Create new role from AWS policy templates**. 1. Enter `bot-personal-assistant-lambda-role` for role name and leave the policy template empty. ![](/images/ask/author-from-scratch.png) 1. Click **Create Function** button 1. Scroll down to the integrated Cloud9 editor on the Lambda console. ![](/images/ask/function-code.png) 1. Download the lambda function code [lex-lambda-personal-banker.py](https://github.com/aws-samples/aws-alexa-workshop-ask/blob/master/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. 1. 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. ![](/images/ask/congratulations.png) {{% notice warning %}} If lambda alerts any errors, please check the python codes's indents. {{% /notice %}}