Skip to content

delete_session

delete_session(
    bot_id: BotIdentifier,
    bot_alias_id: BotAliasIdentifier,
    locale_id: LocaleId,
    session_id: SessionId,
    *,
    config_overrides: Optional[LexRuntimeV2ClientConfig] = None,
) -> DeleteSessionResponse

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

You can use this operation to restart a conversation with a bot. When you remove a session, the entire history of the session is removed so that you can start again.

You don't need to delete a session. Sessions have a time limit and will expire. Set the session time limit when you create the bot. The default is 5 minutes, but you can specify anything between 1 minute and 24 hours.

If you specify a bot or alias ID that doesn't exist, you receive a BadRequestException.

If the locale doesn't exist in the bot, or if the locale hasn't been enables for the alias, you receive a BadRequestException.

Parameters:

  • bot_id (BotIdentifier) –

    The identifier of the bot that contains the session data.

  • bot_alias_id (BotAliasIdentifier) –

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

  • locale_id (LocaleId) –

    The locale where the session is in use.

  • session_id (SessionId) –

    The identifier of the session to delete.

Raises:

Source code in docs_src/capo_lex_runtime_v2/_services/lex_runtime_v2.py
def delete_session(
    self,
    bot_id: "capo_lex_runtime_v2.types.bot_identifier.BotIdentifier",
    bot_alias_id: "capo_lex_runtime_v2.types.bot_alias_identifier.BotAliasIdentifier",
    locale_id: "capo_lex_runtime_v2.types.locale_id.LocaleId",
    session_id: "capo_lex_runtime_v2.types.session_id.SessionId",
    *,
    config_overrides: Optional[LexRuntimeV2ClientConfig] = None,
) -> "capo_lex_runtime_v2.types.delete_session_response.DeleteSessionResponse":
    """<p>Removes session information for a specified bot, alias, and user ID. </p> <p>You can use this operation to restart a conversation with a bot. When you remove a session, the entire history of the session is removed so that you can start again.</p> <p>You don't need to delete a session. Sessions have a time limit and will expire. Set the session time limit when you create the bot. The default is 5 minutes, but you can specify anything between 1 minute and 24 hours.</p> <p>If you specify a bot or alias ID that doesn't exist, you receive a <code>BadRequestException.</code> </p> <p>If the locale doesn't exist in the bot, or if the locale hasn't been enables for the alias, you receive a <code>BadRequestException</code>.</p>

    Args:
        bot_id: <p>The identifier of the bot that contains the session data.</p>
        bot_alias_id: <p>The alias identifier in use for the bot that contains the session data.</p>
        locale_id: <p>The locale where the session is in use.</p>
        session_id: <p>The identifier of the session to delete.</p>

    Raises:
        capo_lex_runtime_v2.errors.access_denied_exception.AccessDeniedException: <p></p>
        capo_lex_runtime_v2.errors.conflict_exception.ConflictException: <p></p>
        capo_lex_runtime_v2.errors.internal_server_exception.InternalServerException: <p></p>
        capo_lex_runtime_v2.errors.resource_not_found_exception.ResourceNotFoundException: <p></p>
        capo_lex_runtime_v2.errors.throttling_exception.ThrottlingException: <p></p>
        capo_lex_runtime_v2.errors.validation_exception.ValidationException: <p></p>
        capo_lex_runtime_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lex_runtime_v2.types.delete_session_request.DeleteSessionRequest]",
    ) -> OperationResponse[
        "capo_lex_runtime_v2.types.delete_session_response.DeleteSessionResponse"
    ]:
        import capo_lex_runtime_v2._operations.aws_deep_sense_run_time_service_api2_0.delete_session

        output, http_response = (
            capo_lex_runtime_v2._operations.aws_deep_sense_run_time_service_api2_0.delete_session.delete_session(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteSession")
    )
    input_: capo_lex_runtime_v2.types.delete_session_request.DeleteSessionRequest = {
        "bot_id": bot_id,
        "bot_alias_id": bot_alias_id,
        "locale_id": locale_id,
        "session_id": session_id,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output