Amazon Lex Runtime Service

2019/08/09 - Amazon Lex Runtime Service - 3 new api methods

Changes  Manage Amazon Lex session state using APIs on the client

PutSession (new) Link ¶

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.

See also: AWS API Documentation

Request Syntax

client.put_session(
    botName='string',
    botAlias='string',
    userId='string',
    sessionAttributes={
        'string': 'string'
    },
    dialogAction={
        'type': 'ElicitIntent'|'ConfirmIntent'|'ElicitSlot'|'Close'|'Delegate',
        'intentName': 'string',
        'slots': {
            'string': 'string'
        },
        'slotToElicit': 'string',
        'fulfillmentState': 'Fulfilled'|'Failed'|'ReadyForFulfillment',
        'message': 'string',
        'messageFormat': 'PlainText'|'CustomPayload'|'SSML'|'Composite'
    },
    accept='string'
)
type botName

string

param botName

[REQUIRED]

The name of the bot that contains the session data.

type botAlias

string

param botAlias

[REQUIRED]

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

type userId

string

param userId

[REQUIRED]

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

type sessionAttributes

dict

param sessionAttributes

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

  • (string) --

    • (string) --

type dialogAction

dict

param dialogAction

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

  • type (string) -- [REQUIRED]

    The next action that the bot should take in its interaction with the user. The possible values are:

    • ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"

    • Close - Indicates that the there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.

    • Delegate - The next action is determined by Amazon Lex.

    • ElicitIntent - The next action is to determine the intent that the user wants to fulfill.

    • ElicitSlot - The next action is to elicit a slot value from the user.

  • intentName (string) --

    The name of the intent.

  • slots (dict) --

    Map of the slots that have been gathered and their values.

    • (string) --

      • (string) --

  • slotToElicit (string) --

    The name of the slot that should be elicited from the user.

  • fulfillmentState (string) --

    The fulfillment state of the intent. The possible values are:

    • Failed - The Lambda function associated with the intent failed to fulfill the intent.

    • Fulfilled - The intent has fulfilled by the Lambda function associated with the intent.

    • ReadyForFulfillment - All of the information necessary for the intent is present and the intent ready to be fulfilled by the client application.

  • message (string) --

    The message that should be shown to the user. If you don't specify a message, Amazon Lex will use the message configured for the intent.

  • messageFormat (string) --

    • 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. For more information, see Message Groups.

type accept

string

param accept

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

rtype

dict

returns

Response Syntax

{
    'contentType': 'string',
    'intentName': 'string',
    'slots': {...}|[...]|123|123.4|'string'|True|None,
    'sessionAttributes': {...}|[...]|123|123.4|'string'|True|None,
    'message': 'string',
    'messageFormat': 'PlainText'|'CustomPayload'|'SSML'|'Composite',
    'dialogState': 'ElicitIntent'|'ConfirmIntent'|'ElicitSlot'|'Fulfilled'|'ReadyForFulfillment'|'Failed',
    'slotToElicit': 'string',
    'audioStream': StreamingBody(),
    'sessionId': 'string'
}

Response Structure

  • (dict) --

    • contentType (string) --

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

    • intentName (string) --

      The name of the current intent.

    • slots (JSON serializable) --

      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 .

    • sessionAttributes (JSON serializable) --

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

    • message (string) --

      The next message that should be presented to the user.

    • messageFormat (string) --

      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.

    • dialogState (string) --

      • 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.

    • slotToElicit (string) --

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

    • audioStream (:class:`.StreamingBody`) --

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

    • sessionId (string) --

      A unique identifier for the session.

GetSession (new) Link ¶

Returns session information for a specified bot, alias, and user ID.

See also: AWS API Documentation

Request Syntax

client.get_session(
    botName='string',
    botAlias='string',
    userId='string'
)
type botName

string

param botName

[REQUIRED]

The name of the bot that contains the session data.

type botAlias

string

param botAlias

[REQUIRED]

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

type userId

string

param userId

[REQUIRED]

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

rtype

dict

returns

Response Syntax

{
    'recentIntentSummaryView': [
        {
            'intentName': 'string',
            'slots': {
                'string': 'string'
            },
            'confirmationStatus': 'None'|'Confirmed'|'Denied',
            'dialogActionType': 'ElicitIntent'|'ConfirmIntent'|'ElicitSlot'|'Close'|'Delegate',
            'fulfillmentState': 'Fulfilled'|'Failed'|'ReadyForFulfillment',
            'slotToElicit': 'string'
        },
    ],
    'sessionAttributes': {
        'string': 'string'
    },
    'sessionId': 'string',
    'dialogAction': {
        'type': 'ElicitIntent'|'ConfirmIntent'|'ElicitSlot'|'Close'|'Delegate',
        'intentName': 'string',
        'slots': {
            'string': 'string'
        },
        'slotToElicit': 'string',
        'fulfillmentState': 'Fulfilled'|'Failed'|'ReadyForFulfillment',
        'message': 'string',
        'messageFormat': 'PlainText'|'CustomPayload'|'SSML'|'Composite'
    }
}

Response Structure

  • (dict) --

    • recentIntentSummaryView (list) --

      An array of information about the intents used in the session. The array can contain a maximum of three summaries. If more than three intents are used in the session, the recentIntentSummaryView operation contains information about the last three intents used.

      • (dict) --

        Provides information about the state of an intent. You can use this information to get the current state of an intent so that you can process the intent, or so that you can return the intent to its previous state.

        • intentName (string) --

          The name of the intent.

        • slots (dict) --

          Map of the slots that have been gathered and their values.

          • (string) --

            • (string) --

        • confirmationStatus (string) --

          The status of the intent after the user responds to the confirmation prompt. If the user confirms the intent, Amazon Lex sets this field to Confirmed . If the user denies the intent, Amazon Lex sets this value to Denied . The possible values are:

          • Confirmed - The user has responded "Yes" to the confirmation prompt, confirming that the intent is complete and that it is ready to be fulfilled.

          • Denied - The user has responded "No" to the confirmation prompt.

          • None - The user has never been prompted for confirmation; or, the user was prompted but did not confirm or deny the prompt.

        • dialogActionType (string) --

          The next action that the bot should take in its interaction with the user. The possible values are:

          • ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"

          • Close - Indicates that the there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.

          • ElicitIntent - The next action is to determine the intent that the user wants to fulfill.

          • ElicitSlot - The next action is to elicit a slot value from the user.

        • fulfillmentState (string) --

          The fulfillment state of the intent. The possible values are:

          • Failed - The Lambda function associated with the intent failed to fulfill the intent.

          • Fulfilled - The intent has fulfilled by the Lambda function associated with the intent.

          • ReadyForFulfillment - All of the information necessary for the intent is present and the intent ready to be fulfilled by the client application.

        • slotToElicit (string) --

          The next slot to elicit from the user. If there is not slot to elicit, the field is blank.

    • sessionAttributes (dict) --

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

      • (string) --

        • (string) --

    • sessionId (string) --

      A unique identifier for the session.

    • dialogAction (dict) --

      Describes the current state of the bot.

      • type (string) --

        The next action that the bot should take in its interaction with the user. The possible values are:

        • ConfirmIntent - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as "Place the order?"

        • Close - Indicates that the there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.

        • Delegate - The next action is determined by Amazon Lex.

        • ElicitIntent - The next action is to determine the intent that the user wants to fulfill.

        • ElicitSlot - The next action is to elicit a slot value from the user.

      • intentName (string) --

        The name of the intent.

      • slots (dict) --

        Map of the slots that have been gathered and their values.

        • (string) --

          • (string) --

      • slotToElicit (string) --

        The name of the slot that should be elicited from the user.

      • fulfillmentState (string) --

        The fulfillment state of the intent. The possible values are:

        • Failed - The Lambda function associated with the intent failed to fulfill the intent.

        • Fulfilled - The intent has fulfilled by the Lambda function associated with the intent.

        • ReadyForFulfillment - All of the information necessary for the intent is present and the intent ready to be fulfilled by the client application.

      • message (string) --

        The message that should be shown to the user. If you don't specify a message, Amazon Lex will use the message configured for the intent.

      • messageFormat (string) --

        • 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. For more information, see Message Groups.

DeleteSession (new) Link ¶

Removes session information for a specified bot, alias, and user ID.

See also: AWS API Documentation

Request Syntax

client.delete_session(
    botName='string',
    botAlias='string',
    userId='string'
)
type botName

string

param botName

[REQUIRED]

The name of the bot that contains the session data.

type botAlias

string

param botAlias

[REQUIRED]

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

type userId

string

param userId

[REQUIRED]

The identifier of the user associated with the session data.

rtype

dict

returns

Response Syntax

{
    'botName': 'string',
    'botAlias': 'string',
    'userId': 'string',
    'sessionId': 'string'
}

Response Structure

  • (dict) --

    • botName (string) --

      The name of the bot associated with the session data.

    • botAlias (string) --

      The alias in use for the bot associated with the session data.

    • userId (string) --

      The ID of the client application user.

    • sessionId (string) --

      The unique identifier for the session.