Struct aws_sdk_lexruntimev2::client::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.
Examples
Constructing a client and invoking an operation
// create a shared configuration. This can be used & shared between multiple service clients.
let shared_config = aws_config::load_from_env().await;
let client = aws_sdk_lexruntimev2::Client::new(&shared_config);
// invoke an operation
/* let rsp = client
.<operation_name>().
.<param>("some value")
.send().await; */Constructing a client with custom configuration
use aws_config::retry::RetryConfig;
let shared_config = aws_config::load_from_env().await;
let config = aws_sdk_lexruntimev2::config::Builder::from(&shared_config)
.retry_config(RetryConfig::disabled())
.build();
let client = aws_sdk_lexruntimev2::Client::from_conf(config);Implementations§
source§impl Client
impl Client
sourcepub fn with_config(
client: Client<DynConnector, DynMiddleware<DynConnector>>,
conf: Config
) -> Self
pub fn with_config(
client: Client<DynConnector, DynMiddleware<DynConnector>>,
conf: Config
) -> Self
Creates a client with the given service configuration.
source§impl Client
impl Client
sourcepub fn delete_session(&self) -> DeleteSession
pub fn delete_session(&self) -> DeleteSession
Constructs a fluent builder for the DeleteSession operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):The identifier of the bot that contains the session data.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):The alias identifier in use for the bot that contains the session data.
locale_id(impl Into<String>)/set_locale_id(Option<String>):The locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):The 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>
sourcepub fn get_session(&self) -> GetSession
pub fn get_session(&self) -> GetSession
Constructs a fluent builder for the GetSession operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):The identifier of the bot that contains the session data.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):The alias identifier in use for the bot that contains the session data.
locale_id(impl Into<String>)/set_locale_id(Option<String>):The locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):The 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>
sourcepub fn put_session(&self) -> PutSession
pub fn put_session(&self) -> PutSession
Constructs a fluent builder for the PutSession operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):The identifier of the bot that receives the session data.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):The alias identifier of the bot that receives the session data.
locale_id(impl Into<String>)/set_locale_id(Option<String>):The locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):The identifier of the session that receives the session data.
messages(Vec<Message>)/set_messages(Option<Vec<Message>>):A 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>):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.
request_attributes(HashMap<String, String>)/set_request_attributes(Option<HashMap<String, String>>):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 prefixx-amz-lex:.response_content_type(impl Into<String>)/set_response_content_type(Option<String>):The 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>):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>):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>
sourcepub fn recognize_text(&self) -> RecognizeText
pub fn recognize_text(&self) -> RecognizeText
Constructs a fluent builder for the RecognizeText operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):The identifier of the bot that processes the request.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):The alias identifier in use for the bot that processes the request.
locale_id(impl Into<String>)/set_locale_id(Option<String>):The locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):The identifier of the user session that is having the conversation.
text(impl Into<String>)/set_text(Option<String>):The text that the user entered. Amazon Lex V2 interprets this text.
session_state(SessionState)/set_session_state(Option<SessionState>):The current state of the dialog between the user and the bot.
request_attributes(HashMap<String, String>)/set_request_attributes(Option<HashMap<String, String>>):Request-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.
- On failure, responds with
SdkError<RecognizeTextError>
sourcepub fn recognize_utterance(&self) -> RecognizeUtterance
pub fn recognize_utterance(&self) -> RecognizeUtterance
Constructs a fluent builder for the RecognizeUtterance operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)/set_bot_id(Option<String>):The identifier of the bot that should receive the request.
bot_alias_id(impl Into<String>)/set_bot_alias_id(Option<String>):The alias identifier in use for the bot that should receive the request.
locale_id(impl Into<String>)/set_locale_id(Option<String>):The locale where the session is in use.
session_id(impl Into<String>)/set_session_id(Option<String>):The identifier of the session in use.
session_state(impl Into<String>)/set_session_state(Option<String>):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
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>):Request-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>):Indicates 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>):The 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 therequestContentTypeparameter. 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):User 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 or speech.
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.
- On failure, responds with
SdkError<RecognizeUtteranceError>
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.
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 if the
confis 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
confis missing an HTTP connector. If you experience this panic, set thehttp_connectoron the Config passed into this function to fix it.