/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include #include #include #include #include #include namespace Aws { namespace LexRuntimeV2 { /** *

This section contains documentation for the Amazon Lex V2 Runtime V2 API * operations.

*/ class AWS_LEXRUNTIMEV2_API LexRuntimeV2Client : public Aws::Client::AWSJsonClient, public Aws::Client::ClientWithAsyncTemplateMethods { public: typedef Aws::Client::AWSJsonClient BASECLASS; static const char* SERVICE_NAME; static const char* ALLOCATION_TAG; typedef LexRuntimeV2ClientConfiguration ClientConfigurationType; typedef LexRuntimeV2EndpointProvider EndpointProviderType; /** * Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config * is not specified, it will be initialized to default values. */ LexRuntimeV2Client(const Aws::LexRuntimeV2::LexRuntimeV2ClientConfiguration& clientConfiguration = Aws::LexRuntimeV2::LexRuntimeV2ClientConfiguration(), std::shared_ptr endpointProvider = Aws::MakeShared(ALLOCATION_TAG)); /** * Initializes client to use SimpleAWSCredentialsProvider, with default http client factory, and optional client config. If client config * is not specified, it will be initialized to default values. */ LexRuntimeV2Client(const Aws::Auth::AWSCredentials& credentials, std::shared_ptr endpointProvider = Aws::MakeShared(ALLOCATION_TAG), const Aws::LexRuntimeV2::LexRuntimeV2ClientConfiguration& clientConfiguration = Aws::LexRuntimeV2::LexRuntimeV2ClientConfiguration()); /** * Initializes client to use specified credentials provider with specified client config. If http client factory is not supplied, * the default http client factory will be used */ LexRuntimeV2Client(const std::shared_ptr& credentialsProvider, std::shared_ptr endpointProvider = Aws::MakeShared(ALLOCATION_TAG), const Aws::LexRuntimeV2::LexRuntimeV2ClientConfiguration& clientConfiguration = Aws::LexRuntimeV2::LexRuntimeV2ClientConfiguration()); /* Legacy constructors due deprecation */ /** * Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config * is not specified, it will be initialized to default values. */ LexRuntimeV2Client(const Aws::Client::ClientConfiguration& clientConfiguration); /** * Initializes client to use SimpleAWSCredentialsProvider, with default http client factory, and optional client config. If client config * is not specified, it will be initialized to default values. */ LexRuntimeV2Client(const Aws::Auth::AWSCredentials& credentials, const Aws::Client::ClientConfiguration& clientConfiguration); /** * Initializes client to use specified credentials provider with specified client config. If http client factory is not supplied, * the default http client factory will be used */ LexRuntimeV2Client(const std::shared_ptr& credentialsProvider, const Aws::Client::ClientConfiguration& clientConfiguration); /* End of legacy constructors due deprecation */ virtual ~LexRuntimeV2Client(); /** *

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.

See Also:

AWS * API Reference

*/ virtual Model::DeleteSessionOutcome DeleteSession(const Model::DeleteSessionRequest& request) const; /** * A Callable wrapper for DeleteSession that returns a future to the operation so that it can be executed in parallel to other requests. */ template Model::DeleteSessionOutcomeCallable DeleteSessionCallable(const DeleteSessionRequestT& request) const { return SubmitCallable(&LexRuntimeV2Client::DeleteSession, request); } /** * An Async wrapper for DeleteSession that queues the request into a thread executor and triggers associated callback when operation has finished. */ template void DeleteSessionAsync(const DeleteSessionRequestT& request, const DeleteSessionResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const { return SubmitAsync(&LexRuntimeV2Client::DeleteSession, request, handler, context); } /** *

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

For * example, you can use this operation to retrieve session information for a user * that has left a long-running session in use.

If the bot, alias, or * session identifier doesn't exist, Amazon Lex V2 returns a * BadRequestException. If the locale doesn't exist or is not enabled * for the alias, you receive a BadRequestException.

See * Also:

AWS * API Reference

*/ virtual Model::GetSessionOutcome GetSession(const Model::GetSessionRequest& request) const; /** * A Callable wrapper for GetSession that returns a future to the operation so that it can be executed in parallel to other requests. */ template Model::GetSessionOutcomeCallable GetSessionCallable(const GetSessionRequestT& request) const { return SubmitCallable(&LexRuntimeV2Client::GetSession, request); } /** * An Async wrapper for GetSession that queues the request into a thread executor and triggers associated callback when operation has finished. */ template void GetSessionAsync(const GetSessionRequestT& request, const GetSessionResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const { return SubmitAsync(&LexRuntimeV2Client::GetSession, request, handler, context); } /** *

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 Reference

*/ virtual Model::PutSessionOutcome PutSession(const Model::PutSessionRequest& request) const; /** * A Callable wrapper for PutSession that returns a future to the operation so that it can be executed in parallel to other requests. */ template Model::PutSessionOutcomeCallable PutSessionCallable(const PutSessionRequestT& request) const { return SubmitCallable(&LexRuntimeV2Client::PutSession, request); } /** * An Async wrapper for PutSession that queues the request into a thread executor and triggers associated callback when operation has finished. */ template void PutSessionAsync(const PutSessionRequestT& request, const PutSessionResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const { return SubmitAsync(&LexRuntimeV2Client::PutSession, request, handler, context); } /** *

Sends user input to Amazon Lex V2. Client applications use this API to send * requests to Amazon Lex V2 at runtime. Amazon Lex V2 then interprets the user * input using the machine learning model that it build for the bot.

In * response, Amazon Lex V2 returns the next message to convey to the user and an * optional response card to display.

If the optional post-fulfillment * response is specified, the messages are returned as follows. For more * information, see PostFulfillmentStatusSpecification.

*
  • Success message - Returned if the Lambda function completes * successfully and the intent state is fulfilled or ready fulfillment if the * message is present.

  • Failed message - The failed * message is returned if the Lambda function throws an exception or if the Lambda * function returns a failed intent state without a message.

  • * Timeout message - If you don't configure a timeout message and a timeout, * and the Lambda function doesn't return within 30 seconds, the timeout message is * returned. If you configure a timeout, the timeout message is returned when the * period times out.

For more information, see Completion * message.

See Also:

AWS * API Reference

*/ virtual Model::RecognizeTextOutcome RecognizeText(const Model::RecognizeTextRequest& request) const; /** * A Callable wrapper for RecognizeText that returns a future to the operation so that it can be executed in parallel to other requests. */ template Model::RecognizeTextOutcomeCallable RecognizeTextCallable(const RecognizeTextRequestT& request) const { return SubmitCallable(&LexRuntimeV2Client::RecognizeText, request); } /** * An Async wrapper for RecognizeText that queues the request into a thread executor and triggers associated callback when operation has finished. */ template void RecognizeTextAsync(const RecognizeTextRequestT& request, const RecognizeTextResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const { return SubmitAsync(&LexRuntimeV2Client::RecognizeText, request, handler, context); } /** *

Sends user input to Amazon Lex V2. You can send text or speech. Clients use * this API to send text and audio requests to Amazon Lex V2 at runtime. Amazon Lex * V2 interprets the user input using the machine learning model built for the * bot.

The following request fields must be compressed with gzip and then * base64 encoded before you send them to Amazon Lex V2.

  • *

    requestAttributes

  • sessionState

The * following response fields are compressed using gzip and then base64 encoded by * Amazon Lex V2. Before you can use these fields, you must decode and decompress * them.

  • inputTranscript

  • interpretations

    *
  • messages

  • requestAttributes

  • *

    sessionState

The example contains a Java application that * compresses and encodes a Java object to send to Amazon Lex V2, and a second that * decodes and decompresses a response from Amazon Lex V2.

If the optional * post-fulfillment response is specified, the messages are returned as follows. * For more information, see PostFulfillmentStatusSpecification.

*
  • Success message - Returned if the Lambda function completes * successfully and the intent state is fulfilled or ready fulfillment if the * message is present.

  • Failed message - The failed * message is returned if the Lambda function throws an exception or if the Lambda * function returns a failed intent state without a message.

  • * Timeout message - If you don't configure a timeout message and a timeout, * and the Lambda function doesn't return within 30 seconds, the timeout message is * returned. If you configure a timeout, the timeout message is returned when the * period times out.

For more information, see Completion * message.

See Also:

AWS * API Reference

*/ virtual Model::RecognizeUtteranceOutcome RecognizeUtterance(const Model::RecognizeUtteranceRequest& request) const; /** * A Callable wrapper for RecognizeUtterance that returns a future to the operation so that it can be executed in parallel to other requests. */ template Model::RecognizeUtteranceOutcomeCallable RecognizeUtteranceCallable(const RecognizeUtteranceRequestT& request) const { return SubmitCallable(&LexRuntimeV2Client::RecognizeUtterance, request); } /** * An Async wrapper for RecognizeUtterance that queues the request into a thread executor and triggers associated callback when operation has finished. */ template void RecognizeUtteranceAsync(const RecognizeUtteranceRequestT& request, const RecognizeUtteranceResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const { return SubmitAsync(&LexRuntimeV2Client::RecognizeUtterance, request, handler, context); } /** *

Starts an HTTP/2 bidirectional event stream that enables you to send audio, * text, or DTMF input in real time. After your application starts a conversation, * users send input to Amazon Lex V2 as a stream of events. Amazon Lex V2 processes * the incoming events and responds with streaming text or audio events.

*

Audio input must be in the following format: audio/lpcm * sample-rate=8000 sample-size-bits=16 channel-count=1; * is-big-endian=false.

If the optional post-fulfillment response is * specified, the messages are returned as follows. For more information, see PostFulfillmentStatusSpecification.

*
  • Success message - Returned if the Lambda function completes * successfully and the intent state is fulfilled or ready fulfillment if the * message is present.

  • Failed message - The failed * message is returned if the Lambda function throws an exception or if the Lambda * function returns a failed intent state without a message.

  • * Timeout message - If you don't configure a timeout message and a timeout, * and the Lambda function doesn't return within 30 seconds, the timeout message is * returned. If you configure a timeout, the timeout message is returned when the * period times out.

For more information, see Completion * message.

If the optional update message is configured, it is played * at the specified frequency while the Lambda function is running and the update * message state is active. If the fulfillment update message is not active, the * Lambda function runs with a 30 second timeout.

For more information, see * Update * message

The StartConversation operation is supported * only in the following SDKs:

See Also:

AWS * API Reference

* * Queues the request into a thread executor. * The streamReadyHandler is triggered when the stream is ready to be written to. * The handler is triggered when the request is finished. */ virtual void StartConversationAsync(Model::StartConversationRequest& request, const StartConversationStreamReadyHandler& streamReadyHandler, const StartConversationResponseReceivedHandler& handler, const std::shared_ptr& handlerContext = nullptr) const; void OverrideEndpoint(const Aws::String& endpoint); std::shared_ptr& accessEndpointProvider(); private: friend class Aws::Client::ClientWithAsyncTemplateMethods; void init(const LexRuntimeV2ClientConfiguration& clientConfiguration); LexRuntimeV2ClientConfiguration m_clientConfiguration; std::shared_ptr m_executor; std::shared_ptr m_endpointProvider; }; } // namespace LexRuntimeV2 } // namespace Aws