LexRuntimeV2.Client.
put_session
(**kwargs)¶Creates a new session or modifies an existing session with an Amazon Lex V2 bot. Use this operation to enable your application to set the state of the bot.
See also: AWS API Documentation
Request Syntax
response = client.put_session(
botId='string',
botAliasId='string',
localeId='string',
sessionId='string',
messages=[
{
'content': 'string',
'contentType': 'CustomPayload'|'ImageResponseCard'|'PlainText'|'SSML',
'imageResponseCard': {
'title': 'string',
'subtitle': 'string',
'imageUrl': 'string',
'buttons': [
{
'text': 'string',
'value': 'string'
},
]
}
},
],
sessionState={
'dialogAction': {
'type': 'Close'|'ConfirmIntent'|'Delegate'|'ElicitIntent'|'ElicitSlot'|'None',
'slotToElicit': 'string',
'slotElicitationStyle': 'Default'|'SpellByLetter'|'SpellByWord',
'subSlotToElicit': {
'name': 'string',
'subSlotToElicit': {'... recursive ...'}
}
},
'intent': {
'name': 'string',
'slots': {
'string': {
'value': {
'originalValue': 'string',
'interpretedValue': 'string',
'resolvedValues': [
'string',
]
},
'shape': 'Scalar'|'List'|'Composite',
'values': [
{'... recursive ...'},
],
'subSlots': {'... recursive ...'}
}
},
'state': 'Failed'|'Fulfilled'|'InProgress'|'ReadyForFulfillment'|'Waiting'|'FulfillmentInProgress',
'confirmationState': 'Confirmed'|'Denied'|'None'
},
'activeContexts': [
{
'name': 'string',
'timeToLive': {
'timeToLiveInSeconds': 123,
'turnsToLive': 123
},
'contextAttributes': {
'string': 'string'
}
},
],
'sessionAttributes': {
'string': 'string'
},
'originatingRequestId': 'string',
'runtimeHints': {
'slotHints': {
'string': {
'string': {
'runtimeHintValues': [
{
'phrase': 'string'
},
],
'subSlotHints': {'... recursive ...'}
}
}
}
}
},
requestAttributes={
'string': 'string'
},
responseContentType='string'
)
[REQUIRED]
The identifier of the bot that receives the session data.
[REQUIRED]
The alias identifier of the bot that receives the session data.
[REQUIRED]
The locale where the session is in use.
[REQUIRED]
The identifier of the session that receives the session data.
A list of messages to send to the user. Messages are sent in the order that they are defined in the list.
Container for text that is returned to the customer..
The text of the message.
Indicates the type of response.
A card that is shown to the user by a messaging platform. You define the contents of the card, the card is displayed by the platform.
When you use a response card, the response from the user is constrained to the text associated with a button on the card.
The title to display on the response card. The format of the title is determined by the platform displaying the response card.
The subtitle to display on the response card. The format of the subtitle is determined by the platform displaying the response card.
The URL of an image to display on the response card. The image URL must be publicly available so that the platform displaying the response card has access to the image.
A list of buttons that should be displayed on the response card. The arrangement of the buttons is determined by the platform that displays the button.
A button that appears on a response card show to the user.
The text that is displayed on the button.
The value returned to Amazon Lex V2 when a user chooses the button.
[REQUIRED]
Sets the state of the session with the user. You can use this to set the current intent, attributes, context, and dialog action. Use the dialog action to determine the next step that Amazon Lex V2 should use in the conversation with the user.
The next step that Amazon Lex V2 should take in the conversation with a user.
The next action that the bot should take in its interaction with the user. The possible values are:
Close
- Indicates that there will not be a response from the user. For example, the statement "Your order has been placed" does not require a response.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?"Delegate
- The next action is determined by Amazon Lex V2.ElicitIntent
- The next action is to elicit an intent from the user.ElicitSlot
- The next action is to elicit a slot value from the user.The name of the slot that should be elicited from the user.
Configures the slot to use spell-by-letter or spell-by-word style. When you use a style on a slot, users can spell out their input to make it clear to your bot.
For more information, see Using spelling to enter slot values.
The name of the constituent sub slot of the composite slot specified in slotToElicit that should be elicited from the user.
The name of the slot that should be elicited from the user.
The field is not supported.
The active intent that Amazon Lex V2 is processing.
The name of the intent.
A map of all of the slots for the intent. The name of the slot maps to the value of the slot. If a slot has not been filled, the value is null.
A value that Amazon Lex V2 uses to fulfill an intent.
The current value of the slot.
The text of the utterance from the user that was entered for the slot.
The value that Amazon Lex V2 determines for the slot. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues
list.
A list of additional values that have been recognized for the slot.
When the shape
value is List
, it indicates that the values
field contains a list of slot values. When the value is Scalar
, it indicates that the value
field contains a single value.
A list of one or more values that the user provided for the slot. For example, if a for a slot that elicits pizza toppings, the values might be "pepperoni" and "pineapple."
A value that Amazon Lex V2 uses to fulfill an intent.
The constituent sub slots of a composite slot.
Contains fulfillment information for the intent.
Contains information about whether fulfillment of the intent has been confirmed.
One or more contexts that indicate to Amazon Lex V2 the context of a request. When a context is active, Amazon Lex V2 considers intents with the matching context as a trigger as the next intent in a session.
Contains information about the contexts that a user is using in a session. You can configure Amazon Lex V2 to set a context when an intent is fulfilled, or you can set a context using the , , or operations.
Use a context to indicate to Amazon Lex V2 intents that should be used as follow-up intents. For example, if the active context is order-fulfilled
, only intents that have order-fulfilled
configured as a trigger are considered for follow up.
The name of the context.
Indicates the number of turns or seconds that the context is active. Once the time to live expires, the context is no longer returned in a response.
The number of seconds that the context is active. You can specify between 5 and 86400 seconds (24 hours).
The number of turns that the context is active. You can specify up to 20 turns. Each request and response from the bot is a turn.
A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request.
If you don't specify a list of contexts, Amazon Lex V2 will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.
Map of key/value pairs representing session-specific context information. It contains application information passed between Amazon Lex V2 and a client application.
A unique identifier for a specific request.
Hints for phrases that a customer is likely to use for a slot. Amazon Lex V2 uses the hints to help determine the correct value of a slot.
A list of the slots in the intent that should have runtime hints added, and the phrases that should be added for each slot.
The first level of the slotHints
map is the name of the intent. The second level is the name of the slot within the intent. For more information, see Using hints to improve accuracy.
The intent name and slot name must exist.
Provides an array of phrases that should be given preference when resolving values for a slot.
One or more strings that Amazon Lex V2 should look for in the input to the bot. Each phrase is given preference when deciding on slot values.
Provides the phrase that Amazon Lex V2 should look for in the user's input to the bot.
The phrase that Amazon Lex V2 should look for in the user's input to the bot.
A map of constituent sub slot names inside a composite slot in the intent and the phrases that should be added for each sub slot. Inside each composite slot hints, this structure provides a mechanism to add granular sub slot phrases. Only sub slot hints are supported for composite slots. The intent name, composite slot name and the constituent sub slot names must exist.
Request-specific information passed between Amazon Lex V2 and the client application.
The namespace x-amz-lex:
is reserved for special attributes. Don't create any request attributes with the prefix x-amz-lex:
.
The message that Amazon Lex V2 returns in the response can be either text or speech depending on the value of this parameter.
text/plain; charset=utf-8
, Amazon Lex V2 returns text in the response.dict
Response Syntax
{
'contentType': 'string',
'messages': 'string',
'sessionState': 'string',
'requestAttributes': 'string',
'sessionId': 'string',
'audioStream': StreamingBody()
}
Response Structure
(dict) --
contentType (string) --
The type of response. Same as the type specified in the responseContentType
field in the request.
messages (string) --
A list of messages that were last sent to the user. The messages are ordered based on how you return the messages from you Lambda function or the order that the messages are defined in the bot.
sessionState (string) --
Represents the current state of the dialog between the user and the bot.
Use this to determine the progress of the conversation and what the next action may be.
requestAttributes (string) --
Request-specific information passed between the client application and Amazon Lex V2. These are the same as the requestAttribute
parameter in the call to the PutSession
operation.
sessionId (string) --
The identifier of the session that received the data.
audioStream (StreamingBody
) --
If the requested content type was audio, the audio version of the message to convey to the user.
Exceptions
LexRuntimeV2.Client.exceptions.AccessDeniedException
LexRuntimeV2.Client.exceptions.ResourceNotFoundException
LexRuntimeV2.Client.exceptions.ValidationException
LexRuntimeV2.Client.exceptions.ThrottlingException
LexRuntimeV2.Client.exceptions.InternalServerException
LexRuntimeV2.Client.exceptions.ConflictException
LexRuntimeV2.Client.exceptions.DependencyFailedException
LexRuntimeV2.Client.exceptions.BadGatewayException