Struct aws_sdk_lexruntimev2::Client
source · pub struct Client { /* private fields */ }Expand description
Client for Amazon Lex Runtime V2
Client for invoking operations on Amazon Lex Runtime V2. Each operation on Amazon Lex Runtime V2 is a method on this
this struct. .send() MUST be invoked on the generated operations to dispatch the request to the service.
§Constructing a Client
A Config is required to construct a client. For most use cases, the aws-config
crate should be used to automatically resolve this config using
aws_config::load_from_env(), since this will resolve an SdkConfig which can be shared
across multiple different AWS SDK clients. This config resolution process can be customized
by calling aws_config::from_env() instead, which returns a ConfigLoader that uses
the builder pattern to customize the default config.
In the simplest case, creating a client looks as follows:
let config = aws_config::load_from_env().await;
let client = aws_sdk_lexruntimev2::Client::new(&config);Occasionally, SDKs may have additional service-specific values that can be set on the Config that
is absent from SdkConfig, or slightly different settings for a specific client may be desired.
The Config struct implements From<&SdkConfig>, so setting these specific settings can be
done as follows:
let sdk_config = ::aws_config::load_from_env().await;
let config = aws_sdk_lexruntimev2::config::Builder::from(&sdk_config)
.some_service_specific_setting("value")
.build();See the aws-config docs and Config for more information on customizing configuration.
Note: Client construction is expensive due to connection thread pool initialization, and should be done once at application start-up.
§Using the Client
A client has a function for every operation that can be performed by the service.
For example, the DeleteSession operation has
a Client::delete_session, function which returns a builder for that operation.
The fluent builder ultimately has a send() function that returns an async future that
returns a result, as illustrated below:
let result = client.delete_session()
.bot_id("example")
.send()
.await;The underlying HTTP requests that get made by this can be modified with the customize_operation
function on the fluent builder. See the customize module for more
information.
Implementations§
source§impl Client
impl Client
sourcepub fn delete_session(&self) -> DeleteSessionFluentBuilder
pub fn delete_session(&self) -> DeleteSessionFluentBuilder
Constructs a fluent builder for the DeleteSession operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):
required: trueThe identifier of the bot that contains the session data.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):
required: trueThe alias identifier in use for the bot that contains the session data.
locale_id(impl Into<String>)/set_locale_id(Option<String>):
required: trueThe locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe identifier of the session to delete.
- On success, responds with
DeleteSessionOutputwith field(s):bot_id(Option<String>):The identifier of the bot that contained the session data.
bot_alias_id(Option<String>):The alias identifier in use for the bot that contained the session data.
locale_id(Option<String>):The locale where the session was used.
session_id(Option<String>):The identifier of the deleted session.
- On failure, responds with
SdkError<DeleteSessionError>
source§impl Client
impl Client
sourcepub fn get_session(&self) -> GetSessionFluentBuilder
pub fn get_session(&self) -> GetSessionFluentBuilder
Constructs a fluent builder for the GetSession operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):
required: trueThe identifier of the bot that contains the session data.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):
required: trueThe alias identifier in use for the bot that contains the session data.
locale_id(impl Into<String>)/set_locale_id(Option<String>):
required: trueThe locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe identifier of the session to return.
- On success, responds with
GetSessionOutputwith field(s):session_id(Option<String>):The identifier of the returned session.
messages(Option<Vec::<Message>>):A list of messages that were last sent to the user. The messages are ordered based on the order that your returned the messages from your Lambda function or the order that messages are defined in the bot.
interpretations(Option<Vec::<Interpretation>>):A list of intents that Amazon Lex V2 determined might satisfy the user’s utterance.
Each interpretation includes the intent, a score that indicates how confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.
session_state(Option<SessionState>):Represents the current state of the dialog between the user and the bot.
You can use this to determine the progress of the conversation and what the next action might be.
- On failure, responds with
SdkError<GetSessionError>
source§impl Client
impl Client
sourcepub fn put_session(&self) -> PutSessionFluentBuilder
pub fn put_session(&self) -> PutSessionFluentBuilder
Constructs a fluent builder for the PutSession operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):
required: trueThe identifier of the bot that receives the session data.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):
required: trueThe alias identifier of the bot that receives the session data.
locale_id(impl Into<String>)/set_locale_id(Option<String>):
required: trueThe locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe identifier of the session that receives the session data.
messages(Message)/set_messages(Option<Vec::<Message>>):
required: falseA list of messages to send to the user. Messages are sent in the order that they are defined in the list.
session_state(SessionState)/set_session_state(Option<SessionState>):
required: trueSets 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.
request_attributes(impl Into<String>, impl Into<String>)/set_request_attributes(Option<HashMap::<String, String>>):
required: falseRequest-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 prefixx-amz-lex:.response_content_type(impl Into<String>)/set_response_content_type(Option<String>):
required: falseThe message that Amazon Lex V2 returns in the response can be either text or speech depending on the value of this parameter.
-
If the value is
text/plain; charset=utf-8, Amazon Lex V2 returns text in the response.
-
- On success, responds with
PutSessionOutputwith field(s):content_type(Option<String>):The type of response. Same as the type specified in the
responseContentTypefield in the request.messages(Option<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.
session_state(Option<String>):A base-64-encoded gzipped field that 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.
request_attributes(Option<String>):A base-64-encoded gzipped field that provides request-specific information passed between the client application and Amazon Lex V2. These are the same as the
requestAttributeparameter in the call to thePutSessionoperation.session_id(Option<String>):The identifier of the session that received the data.
audio_stream(ByteStream):If the requested content type was audio, the audio version of the message to convey to the user.
- On failure, responds with
SdkError<PutSessionError>
source§impl Client
impl Client
sourcepub fn recognize_text(&self) -> RecognizeTextFluentBuilder
pub fn recognize_text(&self) -> RecognizeTextFluentBuilder
Constructs a fluent builder for the RecognizeText operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):
required: trueThe identifier of the bot that processes the request.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):
required: trueThe alias identifier in use for the bot that processes the request.
locale_id(impl Into<String>)/set_locale_id(Option<String>):
required: trueThe locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe identifier of the user session that is having the conversation.
text(impl Into<String>)/set_text(Option<String>):
required: trueThe text that the user entered. Amazon Lex V2 interprets this text.
session_state(SessionState)/set_session_state(Option<SessionState>):
required: falseThe current state of the dialog between the user and the bot.
request_attributes(impl Into<String>, impl Into<String>)/set_request_attributes(Option<HashMap::<String, String>>):
required: falseRequest-specific information passed between the client application and Amazon Lex V2
The namespace
x-amz-lex:is reserved for special attributes. Don’t create any request attributes with the prefixx-amz-lex:.
- On success, responds with
RecognizeTextOutputwith field(s):messages(Option<Vec::<Message>>):A list of messages last sent to the user. The messages are ordered based on the order that you returned the messages from your Lambda function or the order that the messages are defined in the bot.
session_state(Option<SessionState>):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.
interpretations(Option<Vec::<Interpretation>>):A list of intents that Amazon Lex V2 determined might satisfy the user’s utterance.
Each interpretation includes the intent, a score that indicates now confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.
request_attributes(Option<HashMap::<String, String>>):The attributes sent in the request.
session_id(Option<String>):The identifier of the session in use.
recognized_bot_member(Option<RecognizedBotMember>):The bot member that recognized the text.
- On failure, responds with
SdkError<RecognizeTextError>
source§impl Client
impl Client
sourcepub fn recognize_utterance(&self) -> RecognizeUtteranceFluentBuilder
pub fn recognize_utterance(&self) -> RecognizeUtteranceFluentBuilder
Constructs a fluent builder for the RecognizeUtterance operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):
required: trueThe identifier of the bot that should receive the request.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):
required: trueThe alias identifier in use for the bot that should receive the request.
locale_id(impl Into<String>)/set_locale_id(Option<String>):
required: trueThe locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe identifier of the session in use.
session_state(impl Into<String>)/set_session_state(Option<String>):
required: falseSets 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
sessionStatefield must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.request_attributes(impl Into<String>)/set_request_attributes(Option<String>):
required: falseRequest-specific information passed between the client application and Amazon Lex V2
The namespace
x-amz-lex:is reserved for special attributes. Don’t create any request attributes for prefixx-amz-lex:.The
requestAttributesfield must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.request_content_type(impl Into<String>)/set_request_content_type(Option<String>):
required: trueIndicates the format for audio input or that the content is text. The header must start with one of the following prefixes:
-
PCM format, audio data must be in little-endian byte order.
-
audio/l16; rate=16000; channels=1
-
audio/x-l16; sample-rate=16000; channel-count=1
-
audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false
-
-
Opus format
-
audio/x-cbr-opus-with-preamble;preamble-size=0;bit-rate=256000;frame-size-milliseconds=4
-
-
Text format
-
text/plain; charset=utf-8
-
-
response_content_type(impl Into<String>)/set_response_content_type(Option<String>):
required: falseThe message that Amazon Lex V2 returns in the response can be either text or speech based on the
responseContentTypevalue.-
If the value is
text/plain;charset=utf-8, Amazon Lex V2 returns text in the response. -
If the value begins with
audio/, Amazon Lex V2 returns speech in the response. Amazon Lex V2 uses Amazon Polly to generate the speech using the configuration that you specified in theresponseContentTypeparameter. For example, if you specifyaudio/mpegas the value, Amazon Lex V2 returns speech in the MPEG format. -
If the value is
audio/pcm, the speech returned isaudio/pcmat 16 KHz in 16-bit, little-endian format. -
The following are the accepted values:
-
audio/mpeg
-
audio/ogg
-
audio/pcm (16 KHz)
-
audio/* (defaults to mpeg)
-
text/plain; charset=utf-8
-
-
input_stream(ByteStream)/set_input_stream(ByteStream):
required: falseUser input in PCM or Opus audio format or text format as described in the
requestContentTypeparameter.
- On success, responds with
RecognizeUtteranceOutputwith field(s):input_mode(Option<String>):Indicates whether the input mode to the operation was text, speech, or from a touch-tone keypad.
content_type(Option<String>):Content type as specified in the
responseContentTypein the request.messages(Option<String>):A list of messages that were last sent to the user. The messages are ordered based on the order that you returned the messages from your Lambda function or the order that the messages are defined in the bot.
The
messagesfield is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.interpretations(Option<String>):A list of intents that Amazon Lex V2 determined might satisfy the user’s utterance.
Each interpretation includes the intent, a score that indicates how confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.
The
interpretationsfield is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.session_state(Option<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 might be.
The
sessionStatefield is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.request_attributes(Option<String>):The attributes sent in the request.
The
requestAttributesfield is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents.session_id(Option<String>):The identifier of the session in use.
input_transcript(Option<String>):The text used to process the request.
If the input was an audio stream, the
inputTranscriptfield contains the text extracted from the audio stream. This is the text that is actually processed to recognize intents and slot values. You can use this information to determine if Amazon Lex V2 is correctly processing the audio that you send.The
inputTranscriptfield is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.audio_stream(ByteStream):The prompt or statement to send to the user. This is based on the bot configuration and context. For example, if Amazon Lex V2 did not understand the user intent, it sends the
clarificationPromptconfigured for the bot. If the intent requires confirmation before taking the fulfillment action, it sends theconfirmationPrompt. Another example: Suppose that the Lambda function successfully fulfilled the intent, and sent a message to convey to the user. Then Amazon Lex V2 sends that message in the response.recognized_bot_member(Option<String>):The bot member that recognized the utterance.
- On failure, responds with
SdkError<RecognizeUtteranceError>
source§impl Client
impl Client
sourcepub fn start_conversation(&self) -> StartConversationFluentBuilder
pub fn start_conversation(&self) -> StartConversationFluentBuilder
Constructs a fluent builder for the StartConversation operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):
required: trueThe identifier of the bot to process the request.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):
required: trueThe alias identifier in use for the bot that processes the request.
locale_id(impl Into<String>)/set_locale_id(Option<String>):
required: trueThe locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):
required: trueThe identifier of the user session that is having the conversation.
conversation_mode(ConversationMode)/set_conversation_mode(Option<ConversationMode>):
required: falseThe conversation type that you are using the Amazon Lex V2. If the conversation mode is
AUDIOyou can send both audio and DTMF information. If the mode isTEXTyou can only send text.request_event_stream(EventStreamSender<StartConversationRequestEventStream, StartConversationRequestEventStreamError>)/set_request_event_stream(EventStreamSender<StartConversationRequestEventStream, StartConversationRequestEventStreamError>):
required: trueRepresents the stream of events to Amazon Lex V2 from your application. The events are encoded as HTTP/2 data frames.
- On success, responds with
StartConversationOutputwith field(s):response_event_stream(EventReceiver<StartConversationResponseEventStream, StartConversationResponseEventStreamError>):Represents the stream of events from Amazon Lex V2 to your application. The events are encoded as HTTP/2 data frames.
- On failure, responds with
SdkError<StartConversationError>
source§impl Client
impl Client
sourcepub fn from_conf(conf: Config) -> Self
pub fn from_conf(conf: Config) -> Self
Creates a new client from the service Config.
§Panics
This method will panic in the following cases:
- Retries or timeouts are enabled without a
sleep_implconfigured. - Identity caching is enabled without a
sleep_implandtime_sourceconfigured. - No
behavior_versionis provided.
The panic message for each of these will have instructions on how to resolve them.
source§impl Client
impl Client
sourcepub fn new(sdk_config: &SdkConfig) -> Self
pub fn new(sdk_config: &SdkConfig) -> Self
Creates a new client from an SDK Config.
§Panics
- This method will panic if the
sdk_configis missing an async sleep implementation. If you experience this panic, set thesleep_implon the Config passed into this function to fix it. - This method will panic if the
sdk_configis missing an HTTP connector. If you experience this panic, set thehttp_connectoron the Config passed into this function to fix it. - This method will panic if no
BehaviorVersionis provided. If you experience this panic, setbehavior_versionon the Config or enable thebehavior-version-latestCargo feature.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more