StartConversation - Amazon Lex API Reference


Starts an HTTP/2 bidirectional event stream that enables you to send audio, text, or DTMF input in real time. After your application starts a conversation, users send input to Amazon Lex V2 as a stream of events. Amazon Lex V2 processes the incoming events and responds with streaming text or audio events.

Audio input must be in the following format: audio/lpcm sample-rate=8000 sample-size-bits=16 channel-count=1; is-big-endian=false.

If the optional post-fulfillment response is specified, the messages are returned as follows. For more information, see PostFulfillmentStatusSpecification.

  • Success message - Returned if the Lambda function completes successfully and the intent state is fulfilled or ready fulfillment if the message is present.

  • Failed message - The failed message is returned if the Lambda function throws an exception or if the Lambda function returns a failed intent state without a message.

  • Timeout message - If you don't configure a timeout message and a timeout, and the Lambda function doesn't return within 30 seconds, the timeout message is returned. If you configure a timeout, the timeout message is returned when the period times out.

For more information, see Completion message.

If the optional update message is configured, it is played at the specified frequency while the Lambda function is running and the update message state is active. If the fulfillment update message is not active, the Lambda function runs with a 30 second timeout.

For more information, see Update message

The StartConversation operation is supported only in the following SDKs:

Request Syntax

POST /bots/botId/botAliases/botAliasId/botLocales/localeId/sessions/sessionId/conversation HTTP/1.1 x-amz-lex-conversation-mode: conversationMode Content-type: application/json { "AudioInputEvent": { "audioChunk": blob, "clientTimestampMillis": number, "contentType": "string", "eventId": "string" }, "ConfigurationEvent": { "clientTimestampMillis": number, "disablePlayback": boolean, "eventId": "string", "requestAttributes": { "string" : "string" }, "responseContentType": "string", "sessionState": { "activeContexts": [ { "contextAttributes": { "string" : "string" }, "name": "string", "timeToLive": { "timeToLiveInSeconds": number, "turnsToLive": number } } ], "dialogAction": { "slotElicitationStyle": "string", "slotToElicit": "string", "subSlotToElicit": { "name": "string", "subSlotToElicit": "ElicitSubSlot" }, "type": "string" }, "intent": { "confirmationState": "string", "name": "string", "slots": { "string" : { "shape": "string", "subSlots": { "string" : "Slot" }, "value": { "interpretedValue": "string", "originalValue": "string", "resolvedValues": [ "string" ] }, "values": [ "Slot" ] } }, "state": "string" }, "originatingRequestId": "string", "runtimeHints": { "slotHints": { "string" : { "string" : { "runtimeHintValues": [ { "phrase": "string" } ], "subSlotHints": { "string" : "RuntimeHintDetails" } } } } }, "sessionAttributes": { "string" : "string" } }, "welcomeMessages": [ { "content": "string", "contentType": "string", "imageResponseCard": { "buttons": [ { "text": "string", "value": "string" } ], "imageUrl": "string", "subtitle": "string", "title": "string" } } ] }, "DisconnectionEvent": { "clientTimestampMillis": number, "eventId": "string" }, "DTMFInputEvent": { "clientTimestampMillis": number, "eventId": "string", "inputCharacter": "string" }, "PlaybackCompletionEvent": { "clientTimestampMillis": number, "eventId": "string" }, "TextInputEvent": { "clientTimestampMillis": number, "eventId": "string", "text": "string" } }

URI Request Parameters

The request uses the following URI parameters.


The alias identifier in use for the bot that processes the request.

Required: Yes


The identifier of the bot to process the request.

Length Constraints: Fixed length of 10.

Pattern: ^[0-9a-zA-Z]+$

Required: Yes


The conversation type that you are using the Amazon Lex V2. If the conversation mode is AUDIO you can send both audio and DTMF information. If the mode is TEXT you can only send text.

Valid Values: AUDIO | TEXT


The locale where the session is in use.

Length Constraints: Minimum length of 1.

Required: Yes


The identifier of the user session that is having the conversation.

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.


Speech audio sent from your client application to Amazon Lex V2. Audio starts accumulating when Amazon Lex V2 identifies a voice and continues until a natural pause in the speech is found before processing.

Type: AudioInputEvent object

Required: No


Configuration information sent from your client application to Amazon Lex V2

Type: ConfigurationEvent object

Required: No


Event sent from the client application to indicate to Amazon Lex V2 that the conversation is over.

Type: DisconnectionEvent object

Required: No


DTMF information sent to Amazon Lex V2 by your application. Amazon Lex V2 accumulates the DMTF information from when the user sends the first character and ends

  • when there's a pause longer that the value configured for the end timeout.

  • when there's a digit that is the configured end character.

  • when Amazon Lex V2 accumulates characters equal to the maximum DTMF character configuration.

Type: DTMFInputEvent object

Required: No


Event sent from the client application to Amazon Lex V2 to indicate that it has finished playing audio and that Amazon Lex V2 should start listening for user input.

Type: PlaybackCompletionEvent object

Required: No


Text sent from your client application to Amazon Lex V2. Each TextInputEvent is processed individually.

Type: TextInputEvent object

Required: No

Response Syntax

HTTP/1.1 200 Content-type: application/json { "AccessDeniedException": { }, "AudioResponseEvent": { "audioChunk": blob, "contentType": "string", "eventId": "string" }, "BadGatewayException": { }, "ConflictException": { }, "DependencyFailedException": { }, "HeartbeatEvent": { "eventId": "string" }, "IntentResultEvent": { "eventId": "string", "inputMode": "string", "interpretations": [ { "intent": { "confirmationState": "string", "name": "string", "slots": { "string" : { "shape": "string", "subSlots": { "string" : "Slot" }, "value": { "interpretedValue": "string", "originalValue": "string", "resolvedValues": [ "string" ] }, "values": [ "Slot" ] } }, "state": "string" }, "interpretationSource": "string", "nluConfidence": { "score": number }, "sentimentResponse": { "sentiment": "string", "sentimentScore": { "mixed": number, "negative": number, "neutral": number, "positive": number } } } ], "recognizedBotMember": { "botId": "string", "botName": "string" }, "requestAttributes": { "string" : "string" }, "sessionId": "string", "sessionState": { "activeContexts": [ { "contextAttributes": { "string" : "string" }, "name": "string", "timeToLive": { "timeToLiveInSeconds": number, "turnsToLive": number } } ], "dialogAction": { "slotElicitationStyle": "string", "slotToElicit": "string", "subSlotToElicit": { "name": "string", "subSlotToElicit": "ElicitSubSlot" }, "type": "string" }, "intent": { "confirmationState": "string", "name": "string", "slots": { "string" : { "shape": "string", "subSlots": { "string" : "Slot" }, "value": { "interpretedValue": "string", "originalValue": "string", "resolvedValues": [ "string" ] }, "values": [ "Slot" ] } }, "state": "string" }, "originatingRequestId": "string", "runtimeHints": { "slotHints": { "string" : { "string" : { "runtimeHintValues": [ { "phrase": "string" } ], "subSlotHints": { "string" : "RuntimeHintDetails" } } } } }, "sessionAttributes": { "string" : "string" } } }, "InternalServerException": { }, "PlaybackInterruptionEvent": { "causedByEventId": "string", "eventId": "string", "eventReason": "string" }, "ResourceNotFoundException": { }, "TextResponseEvent": { "eventId": "string", "messages": [ { "content": "string", "contentType": "string", "imageResponseCard": { "buttons": [ { "text": "string", "value": "string" } ], "imageUrl": "string", "subtitle": "string", "title": "string" } } ] }, "ThrottlingException": { }, "TranscriptEvent": { "eventId": "string", "transcript": "string" }, "ValidationException": { } }

Response Elements

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

The following data is returned in JSON format by the service.


Exception thrown when the credentials passed with the request are invalid or expired. Also thrown when the credentials in the request do not have permission to access the StartConversation operation.

Type: Exception

HTTP Status Code: 403

An event sent from Amazon Lex V2 to your client application containing audio to play to the user.

Type: AudioResponseEvent object


Type: Exception

HTTP Status Code: 502

Exception thrown when two clients are using the same AWS account, Amazon Lex V2 bot, and session ID.

Type: Exception

HTTP Status Code: 409

Type: Exception

HTTP Status Code: 424

Event that Amazon Lex V2 sends to indicate that the stream is still open between the client application and Amazon Lex V2

Type: HeartbeatEvent object


Event sent from Amazon Lex V2 to the client application containing the current state of the conversation between the user and Amazon Lex V2.

Type: IntentResultEvent object


An error occurred with Amazon Lex V2.

Type: Exception

HTTP Status Code: 500

Event sent from Amazon Lex V2 to indicate to the client application should stop playback of audio. For example, if the client is playing a prompt that asks for the user's telephone number, the user might start to say the phone number before the prompt is complete. Amazon Lex V2 sends this event to the client application to indicate that the user is responding and that Amazon Lex V2 is processing their input.

Type: PlaybackInterruptionEvent object


Exception thrown if one of the input parameters points to a resource that does not exist. For example, if the bot ID specified does not exist.

Type: Exception

HTTP Status Code: 404

The event sent from Amazon Lex V2 to your application with text to present to the user.

Type: TextResponseEvent object


Exception thrown when your application exceeds the maximum number of concurrent requests.

Type: Exception

HTTP Status Code: 429

Event sent from Amazon Lex V2 to your client application that contains a transcript of voice audio.

Type: TranscriptEvent object


Exception thrown when one or more parameters could not be validated. The message contains the name of the field that isn't valid.

Type: Exception

HTTP Status Code: 400


For information about the errors that are common to all actions, see Common Errors.


HTTP Status Code: 403


HTTP Status Code: 500


HTTP Status Code: 429


HTTP Status Code: 400

See Also

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