Skip to content

Lex Runtime V2  >  Operations  >  start_conversation

start_conversation

Operation

start_conversation async

start_conversation(input: StartConversationInput, plugins: list[Plugin] | None = None) -> DuplexEventStream[StartConversationRequestEventStream, StartConversationResponseEventStream, StartConversationOutput]

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:

Parameters:

Name Type Description Default
input StartConversationInput

An instance of StartConversationInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
DuplexEventStream[StartConversationRequestEventStream, StartConversationResponseEventStream, StartConversationOutput]

A DuplexEventStream for bidirectional streaming.

Input

StartConversationInput dataclass

Dataclass for StartConversationInput structure.

Attributes

bot_alias_id class-attribute instance-attribute
bot_alias_id: str | None = None

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

bot_id class-attribute instance-attribute
bot_id: str | None = None

The identifier of the bot to process the request.

conversation_mode class-attribute instance-attribute
conversation_mode: ConversationMode | None = None

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.

locale_id class-attribute instance-attribute
locale_id: str | None = None

The locale where the session is in use.

session_id class-attribute instance-attribute
session_id: str | None = None

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

Output

This operation returns a DuplexEventStream for bidirectional streaming.

Event Stream Structure

Input Event Type

StartConversationRequestEventStream

Output Event Type

StartConversationResponseEventStream

Initial Response Structure

StartConversationOutput dataclass

Dataclass for StartConversationOutput structure.