Streaming to an Amazon Lex V2 bot - Amazon Lex

Streaming to an Amazon Lex V2 bot

You can use the Amazon Lex V2 streaming API to start a bidirectional stream between an Amazon Lex V2 bot and your application. Starting a stream enables the bot to manage the conversation between the bot and the user. The bot responds to user input without you writing code to handle responses from the user. The bot can:

Not only does the Amazon Lex V2 bot respond to data sent from your application, but it also sends information about the state of the conversation to your application. You can use this information to change how your application responds to customers.

The Amazon Lex V2 bot also monitors the connection between the bot and your application. It can determine if the connection has timed out.

To use the API to start a stream to an Amazon Lex V2 bot, see Starting a stream to a bot.

When you start streaming to an Amazon Lex V2 bot from your application, you can configure the bot to accept either audio input or text input from the user. You can also choose whether the user receives audio or text in response to their input.

If you've configured the Amazon Lex V2 bot to accept audio input from the user, it can't take text input. If you've configured the bot to accept text input, the user can only use written text to communicate with it.

When an Amazon Lex V2 bot takes a streaming audio input, the bot determines when a user begins speaking and when they stop speaking. It handles any pauses or any interruptions from the user. It can also take both DTMF (dual-tone multi-frequency) input and speech input in the same stream. This enables the user to interact with the bot more naturally. You can present users with welcome messages and prompts. You can also enable users to interrupt those messages and prompts.

When you start a bidirectional stream, Amazon Lex V2 uses the HTTP/2 protocol. Your application and the bot exchange data in a single stream as a series of events. An event can be one of the following:

  • Text, audio, or DTMF input from the user.

  • Signals from the application to the Amazon Lex V2 bot. These include an indication that audio playback of a message has been completed, or that the user has disconnected from the session.

For more information about events, see Starting a stream to a bot. For information about how to encode events, see Event stream encoding.