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 (Console)
Create a Lambda function (using the lex-order-flowers-python blueprint) and perform test invocation using sample event data in the AWS Lambda console.
You return to the Amazon Lex console and add the Lambda function as
the code hook to fulfill the OrderFlowers
intent in the
OrderFlowersBot
that you created in the preceding
section.
To create the Lambda function (console)
-
Sign in to the AWS Management Console and open the AWS Lambda console at https://console.aws.amazon.com/lambda/
. -
Choose Create function.
-
On the Create function page, choose Use a blueprint. Type
lex-
in the filter text box and then pressEnter
to find the blueprint, choose thelex-order-flowers-python
blueprint.Lambda function blueprints are provided in both Node.js and Python. For this exercise, use the Python-based blueprint.
-
On the Basic information page, do the following.
-
Type a Lambda function name (
OrderFlowersCodeHook
). -
For the execution role, choose Create a new role with basic Lambda permissions.
-
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.
-
Choose Select a test event, Configure test events.
-
Choose Amazon Lex Order Flowers from the Event template list. This sample event matches the Amazon Lex request/response model (see Using Lambda Functions). Give the test event a name (
LexOrderFlowersTest
). -
Choose Create.
-
Choose Test to test the code hook.
-
Verify that the Lambda function ran successfully. The response in this case matches the Amazon Lex response model.
-
Next Step
Step 4: Add the Lambda Function as Code Hook (Console)