Amazon Lex Chatbot

I created a simple chatbot with Amazon Lex modeled after one of the examples. The intent is to order a shirt, and the chatbot is looking for 3 pieces of information to successfully order the shirt:

  • Size of the shirt,
  • Color of the shirt, and
  • whether you want Long or Short sleeves

Intent - OrderShirt

An intent is the action the user wants to perform. In this case the user wants to order a shirt. Hence, I named the intent, OrderShirt.


Utterances are phrases the user expresses to convey the intent. In this case I expect the user to express they want to order or buy a shirt. I added 2 utteranes to the chatbot.

  • I would like to order a shirt
  • I would like to buy a shirt

Slot and Slot Types

Slots are pieces of information (parameters) the chatbot needs to fulfill the intent. As mentioned above, there are 3 required slots to properly order the correct shirt: size, color, and sleeve.

Amazon Lex Chatbot Slots

Color is using a built-in Amazon Slot Type, called Amazon.Color, but we need 2 custom slot types for size and color, called SizeTypes and SleeveTypes.

  • Size Types: Small, Medium, Large, XL (synonym: Extra Large)
  • Sleeve Types: Short, Long

You can restrict the types to specific values, which I did in this case. When you do this you can specify synonyms to help your chatbot determine the intended values. For example, I specified XL as a specific value for the size of the shirt, but a synonym can be Extra Large.

Confirmation Prompt

Once the chatbot has figured out the intent and received all the values for the required slots, it prompts the user to fulfill the intent given the information it received during the conversation.

The chatbot is asking a yes/no question at this point to fulfill the intent. Use the confirm option to ask the question and make sure to mention the required pieces of information.

  • Confirm - Great! Your {Color}, {Size} {Sleeve} sleeve shirt will be shipped tomorrow! Does this sound okay?
  • Cancel ( user responds ‘no’) - Okay, we’ll cancel that order. Can I help you with something else?


If the user confirms the intent, we need to fulfill the intent. Typically you would run a Lambda Function, but when learning or testing we can just set the chatbot to return the parameters.

  • AWS Lambda function
  • Return parameters to client

Sample Chat using Amazon Lex and OrderShirt Intent

> Can I order a shirt?
What size?
> large
What color?
> black
Short or long sleeves?
> short
Great! Your black, large short sleeve shirt will be shipped tomorrow! Does this sound okay?
> yes
Intent OrderShirt is ReadyForFulfillment: Color:black Size:large Sleeve:short

At this point the Lambda Function would be triggered with event details about the order.

RequestID: 347ad3ef-c55b-11e7-80ef-3945360a39ad
  "dialogState": "ReadyForFulfillment",
  "intentName": "OrderShirt",
  "message": null,
  "responseCard": null,
  "sessionAttributes": {},
  "slotToElicit": null,
  "slots": {
    "Color": "black",
    "Size": "large",
    "Sleeve": "short"