Configuring fulfillment progress updates - Amazon Lex

Configuring fulfillment progress updates

When the fulfillment Lambda function for an intent is called, the bot doesn't send a response until the function completes. If the Lambda function takes more than a few seconds to complete, the user may think that the bot is unresponsive. To address this, you can configure your bot to send updates to the user while the fulfillment Lambda function is running so that the user knows that the bot is still working on their request.

When you add fulfillment updates to an intent, the bot responds at the start of fulfillment and periodically while fulfillment is in progress. When you configure the start response, you can specify a delay before the bot sends the response. With this, you can support cases where the fulfillment doesn't finish relatively quickly. When you configure an update response, you specify the frequency that you want the updates sent. You also configure a timeout to limit the time that the fulfillment function has to run.

You can also add post-fulfillment responses to a bot. This enables the bot to send a different response depending on whether fulfillment succeeds, fails, or times out.

Fulfillment updates are used only when interacting with a bot using the StartConversation operation. You can use the post-fulfillment update when interacting with the bot using the StartConversation , RecognizeText , and RecognizeUtterance operations

Fulfillment updates

Fulfillment updates are sent while your Lambda function is fulfilling an intent. When you turn on fulfillment updates, you provide a start response that is sent at the beginning of fulfillment and an update response that is sent periodically while fulfillment is in progress.

When you specify an update response, you also specify a timeout that determines how long the fulfillment function can run. You can specify a timeout length of up to 15 minutes (900 seconds).

If you turn off fulfillment updates by setting active to false in the console or using the CreateIntent or UpdateIntent operation, the timeout specified for the fulfillment updates isn't used and the default timeout of 30 seconds is used instead.

If the fulfillment function times out, Amazon Lex V2 does one of three things:

  • Post-fulfillment response is configured and active – returns the timeout response.

  • Post-fulfillment response is configured and not active – returns an exception.

  • Post-fulfillment response isn't configured – returns an exception.

Start response

Amazon Lex V2 returns the start response when the Lambda fulfillment function is called during a streaming conversation. It typically tells the user that fulfilling the intent takes some time and that they should wait. The start response isn't returned when you use the RecognizeText or RecognizeUtterance operations.

You can specify up to five response messages. Amazon Lex V2 chooses one of the messages to play to the user.

You can configure a delay between when the Lambda function is called and when the start response is returned. The start response isn't returned if the Lambda function completes its work before the delay is complete.

You can use the active toggle in the console or the FulfillmentUpdatesSpecification structure to turn the start response on and off. When active is false, the start response isn't played.

Update response

Amazon Lex returns the update response periodically during a streaming conversation while the Lambda fulfillment function is running. The update response isn't played when you use the RecognizeText or RecognizeUtterance operations. You can configure how often the update response plays. For example, you can play an update response every 30 seconds while the fulfillment function runs to let the user know that the process is running and that they should continue to wait.

You can specify up to five update messages. Amazon Lex V2 chooses a message to play to the user. Using multiple messages keeps the updates from being repetitive.

If the user provides input via voice, DTMF, or text while the fulfillment Lambda function is running, Amazon Lex V2 returns the update response to the user.

If the Lambda function completes its work before the first update period ends, the update response isn't returned.

You can use the active toggle in the console or the FulfillmentUpdatesSpecification structure to turn the update response on and off. When active is false, the update response isn't returned.

Post-fulfillment response

Amazon Lex V2 returns a post-fulfillment response when the fulfillment function ends. A post-fulfillment response can be used when fulfilling any intent, not just streaming conversations. The post-fulfillment response lets the user know that the function is complete and the result.

You can use the active toggle in the console or the PostFulfillmentStatusSpecification structure to turn the post-fulfillment response on and off. When active is false, the response is not played.

There are three types of post-fulfillment responses:

  • Success – returned when the fulfillment Lambda function completes its work successfully. If post-fulfillment responses aren't active. Amazon Lex V2 takes the next configured action.

  • Timeout – returned if the Lambda function doesn't complete its work before the configured timeout period elapses. If post-fulfillment responses aren't active, Amazon Lex V2 returns an exception.

  • Failure – returned when the Lambda function returns the status Failed in the response or when Amazon Lex V2 encounters an error while fulfilling the intent. If post-fulfillment responses aren't active, Amazon Lex V2 returns an exception.

You can specify up to five messages for each type. Amazon Lex V2 chooses one of the messages to play to the user. If the Lambda function returns a post-fulfillment message, that message is used instead of the configured messages.

Note

If the intent has a closing response, the response is returned after the post-fulfillment response.