put_session
¶
put_session(
bot_name: BotName,
bot_alias: BotAlias,
user_id: UserId,
*,
config_overrides: Optional[LexRuntimeServiceClientConfig] = None,
session_attributes: Optional[StringMap] = None,
dialog_action: Optional[DialogAction] = None,
recent_intent_summary_view: Optional[IntentSummaryList] = None,
accept: Optional[Accept] = None,
active_contexts: Optional[ActiveContextsList] = None,
) -> Generator[PutSessionResponse]
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.
Parameters:
-
bot_name(BotName) –The name of the bot that contains the session data.
-
bot_alias(BotAlias) –The alias in use for the bot that contains the session data.
-
user_id(UserId) –The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot.
-
session_attributes(Optional[StringMap], default:None) –Map of key/value pairs representing the session-specific context information. It contains application information passed between Amazon Lex and a client application.
-
dialog_action(Optional[DialogAction], default:None) –Sets the next action that the bot should take to fulfill the conversation.
-
recent_intent_summary_view(Optional[IntentSummaryList], default:None) –A summary of the recent intents for the bot. You can use the intent summary view to set a checkpoint label on an intent and modify attributes of intents. You can also use it to remove or add intent summary objects to the list.
An intent that you modify or add to the list must make sense for the bot. For example, the intent name must be valid for the bot. You must provide valid values for:
-
intentName -
slot names
-
slotToElict
If you send the
recentIntentSummaryViewparameter in aPutSessionrequest, the contents of the new summary view replaces the old summary view. For example, if aGetSessionrequest returns three intents in the summary view and you callPutSessionwith one intent in the summary view, the next call toGetSessionwill only return one intent. -
-
accept(Optional[Accept], default:None) –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 specifyaudio/mpegas the value, Amazon Lex returns speech in the MPEG format. -
If the value is
audio/pcm, the speech is returned asaudio/pcmin 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
-
-
-
active_contexts(Optional[ActiveContextsList], default:None) –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 will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.
Raises:
-
BadGatewayException–Either the Amazon Lex bot is still building, or one of the dependent services (Amazon Polly, AWS Lambda) failed with an internal service error.
-
BadRequestException–Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes.
-
ConflictException–Two clients are using the same AWS account, Amazon Lex bot, and user ID.
-
DependencyFailedException–One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example,
-
If Amazon Lex does not have sufficient permissions to call a Lambda function.
-
If a Lambda function takes longer than 30 seconds to execute.
-
If a fulfillment Lambda function returns a
Delegatedialog action without removing any slot values.
-
-
InternalFailureException–Internal service error. Retry the call.
-
LimitExceededException–Exceeded a limit.
-
NotAcceptableException–The accept header in the request does not have a valid value.
-
NotFoundException–The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_lex_runtime_service/_services/lex_runtime_service.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | |