If you are using Amazon Lex V2, refer to the Amazon Lex V2 guide instead.
If you are using Amazon Lex V1, we recommend upgrading your bots to Amazon Lex V2. We are no longer adding new features to V1 and strongly recommend using V2 for all new bots.
Step 3: Create a Lambda function
In this section you create a Lambda function using a blueprint (lex-book-trip-python) provided in the AWS Lambda console. You also test the Lambda function by invoking it using sample event data provided by the console.
This Lambda function is written in Python.
-
Sign in to the AWS Management Console and open the AWS Lambda console at https://console.aws.amazon.com/lambda/
. -
Choose Create function.
-
Choose Use a blueprint. Type
lex
to find the blueprint, choose thelex-book-trip-python
blueprint. -
Choose Configure the Lambda function as follows.
-
Type a Lambda function name (
BookTripCodeHook
). -
For the role, choose Create a new role from template(s) and then type a role name.
-
Leave the other default values.
-
-
Choose Create function.
-
If you are using a locale other than English (US) (en-US), update the intent names as described in Updating a Blueprint for a Specific Locale.
-
Test the Lambda function. You invoke the Lambda function twice, using sample data for both booking a car and booking a hotel.
-
Choose Configure test event from the Select a test event drop down.
-
Choose Amazon Lex Book Hotel from the Sample event template list.
This sample event matches the Amazon Lex request/response model. For more information, see Using Lambda Functions.
-
Choose Save and test.
-
Verify that the Lambda function ran successfully. The response in this case matches the Amazon Lex response model.
-
Repeat the step. This time you choose the Amazon Lex Book Car from the Sample event template list. The Lambda function processes the car reservation.
-
Next Step
Step 4: Add the Lambda Function as a Code Hook