Amazon Lex
Developer Guide

Deploying an Amazon Lex Bot on a Messaging Platform

This section explains how to deploy Amazon Lex bots on the Facebook, Slack, and Twilio messaging platforms.


When storing your Facebook, Slack, or Twilio configurations, Amazon Lex uses AWS Key Management Service customer master keys (CMK) to encrypt the information. The first time that you create a channel to one of these messaging platforms, Amazon Lex creates a default CMK (aws/lex). Alternatively, you can create your own CMK with AWS KMS. This gives you more flexibility, including the ability to create, rotate, and disable keys. You can also define access controls and audit the encryption keys used to protect your data. For more information, see the AWS Key Management Service Developer Guide.

When a messaging platform sends a request to Amazon Lex it includes platform-specific information as a request attribute to your Lambda function. Use these attributes to customize the way that your bot behaves. For more information, see Setting Request Attributes.

All of the attributes take the namespace, x-amz-lex:, as the prefix . For example, the user-id attribute is called x-amz-lex:user-id. There are common attributes that are sent by all messaging platforms in addition to attributes that are specific to a particular platform. The following tables list the request attributes that messaging platforms send to your bot's Lambda function.

Common Request Attributes

Attribute Description
channel-id The channel endpoint identifier from Amazon Lex.
channel-name The channel name from Amazon Lex.

One of the following values:

  • Facebook

  • Kik

  • Slack

  • Twilio-SMS

webhook-endpoint-url The Amazon Lex endpoint for the channel.

Facebook Request Attributes

Attribute Description
user-id The Facebook identifier of the sender. See
facebook-page-id The Facebook page identifier of the recipient. See

Kik Request Attributes

Attribute Description
kik-chat-id The identifier for the conversation that your bot is involved in. For more information, see
kik-chat-type The type of conversation that the message originated from. For more information, see
kik-message-id A UUID the identifies the message. For more information, see
kik-message-type The type of message. For more information, see

Twilio Request Attributes

Attribute Description
user-id The sender's phone number ("From"). See
twilio-target-phone-number The phone number of the recipient ("To"). See

Slack Request Attributes

Attribute Description
user-id The Slack user identifier. See
slack-team-id The identifier of the team that sent the message. See
slack-bot-token The developer token that gives the bot access to the Slack APIs. See