PutSession - Amazon Lex V1

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.


Creates a new session or modifies an existing session with an Amazon Lex bot. Use this operation to enable your application to set the state of the bot.

For more information, see Managing Sessions.

Request Syntax

POST /bot/botName/alias/botAlias/user/userId/session HTTP/1.1 Accept: accept Content-type: application/json { "activeContexts": [ { "name": "string", "parameters": { "string" : "string" }, "timeToLive": { "timeToLiveInSeconds": number, "turnsToLive": number } } ], "dialogAction": { "fulfillmentState": "string", "intentName": "string", "message": "string", "messageFormat": "string", "slots": { "string" : "string" }, "slotToElicit": "string", "type": "string" }, "recentIntentSummaryView": [ { "checkpointLabel": "string", "confirmationStatus": "string", "dialogActionType": "string", "fulfillmentState": "string", "intentName": "string", "slots": { "string" : "string" }, "slotToElicit": "string" } ], "sessionAttributes": { "string" : "string" } }

URI Request Parameters

The request uses the following URI parameters.


The message that Amazon Lex returns in the response can be either text or speech based depending on the value of this field.

  • If the value is text/plain; charset=utf-8, Amazon Lex returns text in the response.

  • If the value begins with audio/, Amazon Lex returns speech in the response. Amazon Lex uses Amazon Polly to generate the speech in the configuration that you specify. For example, if you specify audio/mpeg as the value, Amazon Lex returns speech in the MPEG format.

  • If the value is audio/pcm, the speech is returned as audio/pcm in 16-bit, little endian format.

  • The following are the accepted values:

    • audio/mpeg

    • audio/ogg

    • audio/pcm

    • audio/* (defaults to mpeg)

    • text/plain; charset=utf-8


The alias in use for the bot that contains the session data.

Required: Yes


The name of the bot that contains the session data.

Required: Yes


The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot.

Length Constraints: Minimum length of 2. Maximum length of 100.

Pattern: [0-9a-zA-Z._:-]+

Required: Yes

Request Body

The request accepts the following data in JSON format.


A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,

If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.

Type: Array of ActiveContext objects

Array Members: Minimum number of 0 items. Maximum number of 20 items.

Required: No


Sets the next action that the bot should take to fulfill the conversation.

Type: DialogAction object

Required: No


A summary of the recent intents for the bot. You can use the intent summary view to set a checkpoint label on an intent and modify attributes of intents. You can also use it to remove or add intent summary objects to the list.

An intent that you modify or add to the list must make sense for the bot. For example, the intent name must be valid for the bot. You must provide valid values for:

  • intentName

  • slot names

  • slotToElict

If you send the recentIntentSummaryView parameter in a PutSession request, the contents of the new summary view replaces the old summary view. For example, if a GetSession request returns three intents in the summary view and you call PutSession with one intent in the summary view, the next call to GetSession will only return one intent.

Type: Array of IntentSummary objects

Array Members: Minimum number of 0 items. Maximum number of 3 items.

Required: No


Map of key/value pairs representing the session-specific context information. It contains application information passed between Amazon Lex and a client application.

Type: String to string map

Required: No

Response Syntax

HTTP/1.1 200 Content-Type: contentType x-amz-lex-intent-name: intentName x-amz-lex-slots: slots x-amz-lex-session-attributes: sessionAttributes x-amz-lex-message: message x-amz-lex-encoded-message: encodedMessage x-amz-lex-message-format: messageFormat x-amz-lex-dialog-state: dialogState x-amz-lex-slot-to-elicit: slotToElicit x-amz-lex-session-id: sessionId x-amz-lex-active-contexts: activeContexts audioStream

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The response returns the following HTTP headers.


A list of active contexts for the session.


Content type as specified in the Accept HTTP header in the request.


  • ConfirmIntent - Amazon Lex is expecting a "yes" or "no" response to confirm the intent before fulfilling an intent.

  • ElicitIntent - Amazon Lex wants to elicit the user's intent.

  • ElicitSlot - Amazon Lex is expecting the value of a slot for the current intent.

  • Failed - Conveys that the conversation with the user has failed. This can happen for various reasons, including the user does not provide an appropriate response to prompts from the service, or if the Lambda function fails to fulfill the intent.

  • Fulfilled - Conveys that the Lambda function has sucessfully fulfilled the intent.

  • ReadyForFulfillment - Conveys that the client has to fulfill the intent.

Valid Values: ElicitIntent | ConfirmIntent | ElicitSlot | Fulfilled | ReadyForFulfillment | Failed


The next message that should be presented to the user.

The encodedMessage field is base-64 encoded. You must decode the field before you can use the value.

Length Constraints: Minimum length of 1. Maximum length of 1366.


The name of the current intent.


This header has been deprecated.

The next message that should be presented to the user.

You can only use this field in the de-DE, en-AU, en-GB, en-US, es-419, es-ES, es-US, fr-CA, fr-FR, and it-IT locales. In all other locales, the message field is null. You should use the encodedMessage field instead.

Length Constraints: Minimum length of 1. Maximum length of 1024.


The format of the response message. One of the following values:

  • PlainText - The message contains plain UTF-8 text.

  • CustomPayload - The message is a custom format for the client.

  • SSML - The message contains text formatted for voice output.

  • Composite - The message contains an escaped JSON object containing one or more messages from the groups that messages were assigned to when the intent was created.

Valid Values: PlainText | CustomPayload | SSML | Composite


Map of key/value pairs representing session-specific context information.


A unique identifier for the session.


Map of zero or more intent slots Amazon Lex detected from the user input during the conversation.

Amazon Lex creates a resolution list containing likely values for a slot. The value that it returns is determined by the valueSelectionStrategy selected when the slot type was created or updated. If valueSelectionStrategy is set to ORIGINAL_VALUE, the value provided by the user is returned, if the user value is similar to the slot values. If valueSelectionStrategy is set to TOP_RESOLUTION Amazon Lex returns the first value in the resolution list or, if there is no resolution list, null. If you don't specify a valueSelectionStrategy the default is ORIGINAL_VALUE.


If the dialogState is ElicitSlot, returns the name of the slot for which Amazon Lex is eliciting a value.

The response returns the following as the HTTP body.


The audio version of the message to convey to the user.



Either the Amazon Lex bot is still building, or one of the dependent services (Amazon Polly, AWS Lambda) failed with an internal service error.

HTTP Status Code: 502


Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes.

HTTP Status Code: 400


Two clients are using the same AWS account, Amazon Lex bot, and user ID.

HTTP Status Code: 409


One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example,

  • If Amazon Lex does not have sufficient permissions to call a Lambda function.

  • If a Lambda function takes longer than 30 seconds to execute.

  • If a fulfillment Lambda function returns a Delegate dialog action without removing any slot values.

HTTP Status Code: 424


Internal service error. Retry the call.

HTTP Status Code: 500


Exceeded a limit.

HTTP Status Code: 429


The accept header in the request does not have a valid value.

HTTP Status Code: 406


The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: