Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Setting request attributes for your Lex V2 bot

Focus mode
Setting request attributes for your Lex V2 bot - Amazon Lex

Request attributes contain request-specific information and apply only to the current request. A client application sends this information to Amazon Lex. Use request attributes to pass information that doesn't need to persist for the entire session. You can create your own request attributes or you can use predefined attributes. To send request attributes, use the x-amz-lex-request-attributes header in a RecognizeUtterance or the requestAttributes field in a RecognizeText request. Because request attributes don't persist across requests like session attributes do, they are not returned in RecognizeUtterance or RecognizeText responses.

Note

To send information that persists across requests, use session attributes.

Setting user-defined request attributes for each Lex V2 bot request

A user-defined request attribute is data that you send to your bot in each request. You send the information in the amz-lex-request-attributes header of a RecognizeUtterance request or in the requestAttributes field of a RecognizeText request.

To send request attributes to Amazon Lex, you create a string-to-string map of the attributes. The following shows how to map request attributes:

{ "attributeName": "attributeValue", "attributeName": "attributeValue" }

For the PostText operation, you insert the map into the body of the request using the requestAttributes field, as follows:

"requestAttributes": { "attributeName": "attributeValue", "attributeName": "attributeValue" }

For the PostContent operation, you base64 encode the map, and then send it as the x-amz-lex-request-attributes header.

If you are sending binary or structured data in a request attribute, you must first transform the data to a simple string. For more information, see Setting complex attributes in your Lex V2 bot.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.