Projects on AWS

Bots Just Got Better

with .NET and the AWS Toolkit for Visual Studio

Module 2: AWS Lambda Code Hook Creation

In this module you will create and configure the Lambda function as the code hook used with the Lex Bot.


In this module, you will create and configure the Lambda function as the code hook used with the Lex Bot to perform initialization, validation, and/or fulfillment in the Lex intent configuration. You have four (4) options available to choose from in order to create the .NET Lambda function.

 Time to Complete

20 minutes

 Services Used

AWS Lambda

Implementation Instructions

Follow the step-by-step instructions below to create the Lambda function for Lex. To expand the section, click on each step number.

  • For our chatbot, we will need to create and upload the Lambda function inside Visual Studio using the AWS toolkit.

    a. Inside Visual Studio, Click File > New > Project.
    b. On the next screen, choose the AWS Lambda Project (.NET Core) project template under Other Languages > Visual C# > AWS Lambda. See the first screenshot below.
    c. On the next page, choose the Order Flowers blueprint. See the second screenshot below.
    d. Once the project has been created, right click on the project the Solution Explore and click Publish to AWS Lambda
    e. Enter a function name and click Next.
    f. On the next page, choose an existing role or choose AWS LambdaFullAccess under New Role Based on AWS Managed Policy.
    g. Then click Upload and sign into the console to open your uploaded function for testing

    choose the AWS Lambda Project template

    Choose the AWS Lambda Project template

    lext bot blueprint

    Choose the Order Flowers blueprint

  • a. Click the Test button in the right-hand corner to test the function.
    b. It will open the Configure Test Event module that looks like this:
    c. Choose the Test Order Flowers template if it is not already selected by default.
    d. Create a name for your test event.
    e. Click Create.
    f. Click Test and see if your Lambda executes successfully.

    configure test event
  • a. In the AWS Management Console choose Serivces and use the search bar to type in "Amazon Lex".
    b. Once you are inside Amazon Lex, click on the name of your bot. Once on the bot page, make sure to click Edit at the top. Then, under Lambda Initialization and Validation, select the checkbox Initialization and Validation Code Hook. Then from the drop down, select the Lambda you created in this Module.
    c. Under Fulfillment, select AWS Lambda Function and again select the Lambda you created in this Module from the drop down.
    d. Now make sure to build your bot and publish it (buttons at the top). Then you can run the code locally and see if your bot works!

Next, make the app receive a set of credentials.