rusoto_lex_runtime/
generated.rs

1// =================================================================
2//
3//                           * WARNING *
4//
5//                    This file is generated!
6//
7//  Changes made to this file will be overwritten. If changes are
8//  required to the generated code, the service_crategen project
9//  must be updated to generate the changes.
10//
11// =================================================================
12
13use std::error::Error;
14use std::fmt;
15
16use async_trait::async_trait;
17use rusoto_core::credential::ProvideAwsCredentials;
18use rusoto_core::region;
19use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
20use rusoto_core::{Client, RusotoError};
21
22use rusoto_core::param::{Params, ServiceParams};
23use rusoto_core::proto;
24use rusoto_core::signature::SignedRequest;
25#[allow(unused_imports)]
26use serde::{Deserialize, Serialize};
27use serde_json;
28/// <p>A context is a variable that contains information about the current state of the conversation between a user and Amazon Lex. Context can be set automatically by Amazon Lex when an intent is fulfilled, or it can be set at runtime using the <code>PutContent</code>, <code>PutText</code>, or <code>PutSession</code> operation.</p>
29#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
30pub struct ActiveContext {
31    /// <p>The name of the context.</p>
32    #[serde(rename = "name")]
33    pub name: String,
34    /// <p>State variables for the current context. You can use these values as default values for slots in subsequent events.</p>
35    #[serde(rename = "parameters")]
36    pub parameters: ::std::collections::HashMap<String, String>,
37    /// <p>The length of time or number of turns that a context remains active.</p>
38    #[serde(rename = "timeToLive")]
39    pub time_to_live: ActiveContextTimeToLive,
40}
41
42/// <p>The length of time or number of turns that a context remains active.</p>
43#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
44pub struct ActiveContextTimeToLive {
45    /// <p>The number of seconds that the context should be active after it is first sent in a <code>PostContent</code> or <code>PostText</code> response. You can set the value between 5 and 86,400 seconds (24 hours).</p>
46    #[serde(rename = "timeToLiveInSeconds")]
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub time_to_live_in_seconds: Option<i64>,
49    /// <p>The number of conversation turns that the context should be active. A conversation turn is one <code>PostContent</code> or <code>PostText</code> request and the corresponding response from Amazon Lex.</p>
50    #[serde(rename = "turnsToLive")]
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub turns_to_live: Option<i64>,
53}
54
55/// <p>Represents an option to be shown on the client platform (Facebook, Slack, etc.)</p>
56#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
57#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
58pub struct Button {
59    /// <p>Text that is visible to the user on the button.</p>
60    #[serde(rename = "text")]
61    pub text: String,
62    /// <p>The value sent to Amazon Lex when a user chooses the button. For example, consider button text "NYC." When the user chooses the button, the value sent can be "New York City."</p>
63    #[serde(rename = "value")]
64    pub value: String,
65}
66
67#[derive(Clone, Debug, Default, PartialEq, Serialize)]
68#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
69pub struct DeleteSessionRequest {
70    /// <p>The alias in use for the bot that contains the session data.</p>
71    #[serde(rename = "botAlias")]
72    pub bot_alias: String,
73    /// <p>The name of the bot that contains the session data.</p>
74    #[serde(rename = "botName")]
75    pub bot_name: String,
76    /// <p>The identifier of the user associated with the session data.</p>
77    #[serde(rename = "userId")]
78    pub user_id: String,
79}
80
81#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
82#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
83pub struct DeleteSessionResponse {
84    /// <p>The alias in use for the bot associated with the session data.</p>
85    #[serde(rename = "botAlias")]
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub bot_alias: Option<String>,
88    /// <p>The name of the bot associated with the session data.</p>
89    #[serde(rename = "botName")]
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub bot_name: Option<String>,
92    /// <p>The unique identifier for the session.</p>
93    #[serde(rename = "sessionId")]
94    #[serde(skip_serializing_if = "Option::is_none")]
95    pub session_id: Option<String>,
96    /// <p>The ID of the client application user.</p>
97    #[serde(rename = "userId")]
98    #[serde(skip_serializing_if = "Option::is_none")]
99    pub user_id: Option<String>,
100}
101
102/// <p>Describes the next action that the bot should take in its interaction with the user and provides information about the context in which the action takes place. Use the <code>DialogAction</code> data type to set the interaction to a specific state, or to return the interaction to a previous state.</p>
103#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
104pub struct DialogAction {
105    /// <p><p>The fulfillment state of the intent. The possible values are:</p> <ul> <li> <p> <code>Failed</code> - The Lambda function associated with the intent failed to fulfill the intent.</p> </li> <li> <p> <code>Fulfilled</code> - The intent has fulfilled by the Lambda function associated with the intent. </p> </li> <li> <p> <code>ReadyForFulfillment</code> - All of the information necessary for the intent is present and the intent ready to be fulfilled by the client application.</p> </li> </ul></p>
106    #[serde(rename = "fulfillmentState")]
107    #[serde(skip_serializing_if = "Option::is_none")]
108    pub fulfillment_state: Option<String>,
109    /// <p>The name of the intent.</p>
110    #[serde(rename = "intentName")]
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub intent_name: Option<String>,
113    /// <p>The message that should be shown to the user. If you don't specify a message, Amazon Lex will use the message configured for the intent.</p>
114    #[serde(rename = "message")]
115    #[serde(skip_serializing_if = "Option::is_none")]
116    pub message: Option<String>,
117    /// <ul> <li> <p> <code>PlainText</code> - The message contains plain UTF-8 text.</p> </li> <li> <p> <code>CustomPayload</code> - The message is a custom format for the client.</p> </li> <li> <p> <code>SSML</code> - The message contains text formatted for voice output.</p> </li> <li> <p> <code>Composite</code> - The message contains an escaped JSON object containing one or more messages. For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/howitworks-manage-prompts.html">Message Groups</a>. </p> </li> </ul>
118    #[serde(rename = "messageFormat")]
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub message_format: Option<String>,
121    /// <p>The name of the slot that should be elicited from the user.</p>
122    #[serde(rename = "slotToElicit")]
123    #[serde(skip_serializing_if = "Option::is_none")]
124    pub slot_to_elicit: Option<String>,
125    /// <p>Map of the slots that have been gathered and their values. </p>
126    #[serde(rename = "slots")]
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub slots: Option<::std::collections::HashMap<String, String>>,
129    /// <p><p>The next action that the bot should take in its interaction with the user. The possible values are:</p> <ul> <li> <p> <code>ConfirmIntent</code> - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as &quot;Place the order?&quot;</p> </li> <li> <p> <code>Close</code> - Indicates that the there will not be a response from the user. For example, the statement &quot;Your order has been placed&quot; does not require a response.</p> </li> <li> <p> <code>Delegate</code> - The next action is determined by Amazon Lex.</p> </li> <li> <p> <code>ElicitIntent</code> - The next action is to determine the intent that the user wants to fulfill.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action is to elicit a slot value from the user.</p> </li> </ul></p>
130    #[serde(rename = "type")]
131    pub type_: String,
132}
133
134/// <p>Represents an option rendered to the user when a prompt is shown. It could be an image, a button, a link, or text. </p>
135#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
136#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
137pub struct GenericAttachment {
138    /// <p>The URL of an attachment to the response card.</p>
139    #[serde(rename = "attachmentLinkUrl")]
140    #[serde(skip_serializing_if = "Option::is_none")]
141    pub attachment_link_url: Option<String>,
142    /// <p>The list of options to show to the user.</p>
143    #[serde(rename = "buttons")]
144    #[serde(skip_serializing_if = "Option::is_none")]
145    pub buttons: Option<Vec<Button>>,
146    /// <p>The URL of an image that is displayed to the user.</p>
147    #[serde(rename = "imageUrl")]
148    #[serde(skip_serializing_if = "Option::is_none")]
149    pub image_url: Option<String>,
150    /// <p>The subtitle shown below the title.</p>
151    #[serde(rename = "subTitle")]
152    #[serde(skip_serializing_if = "Option::is_none")]
153    pub sub_title: Option<String>,
154    /// <p>The title of the option.</p>
155    #[serde(rename = "title")]
156    #[serde(skip_serializing_if = "Option::is_none")]
157    pub title: Option<String>,
158}
159
160#[derive(Clone, Debug, Default, PartialEq, Serialize)]
161#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
162pub struct GetSessionRequest {
163    /// <p>The alias in use for the bot that contains the session data.</p>
164    #[serde(rename = "botAlias")]
165    pub bot_alias: String,
166    /// <p>The name of the bot that contains the session data.</p>
167    #[serde(rename = "botName")]
168    pub bot_name: String,
169    /// <p>A string used to filter the intents returned in the <code>recentIntentSummaryView</code> structure. </p> <p>When you specify a filter, only intents with their <code>checkpointLabel</code> field set to that string are returned.</p>
170    #[serde(rename = "checkpointLabelFilter")]
171    #[serde(skip_serializing_if = "Option::is_none")]
172    pub checkpoint_label_filter: Option<String>,
173    /// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. </p>
174    #[serde(rename = "userId")]
175    pub user_id: String,
176}
177
178#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
179#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
180pub struct GetSessionResponse {
181    /// <p>A list of active contexts for the session. A context can be set when an intent is fulfilled or by calling the <code>PostContent</code>, <code>PostText</code>, or <code>PutSession</code> operation.</p> <p>You can use a context to control the intents that can follow up an intent, or to modify the operation of your application.</p>
182    #[serde(rename = "activeContexts")]
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub active_contexts: Option<Vec<ActiveContext>>,
185    /// <p>Describes the current state of the bot.</p>
186    #[serde(rename = "dialogAction")]
187    #[serde(skip_serializing_if = "Option::is_none")]
188    pub dialog_action: Option<DialogAction>,
189    /// <p>An array of information about the intents used in the session. The array can contain a maximum of three summaries. If more than three intents are used in the session, the <code>recentIntentSummaryView</code> operation contains information about the last three intents used.</p> <p>If you set the <code>checkpointLabelFilter</code> parameter in the request, the array contains only the intents with the specified label.</p>
190    #[serde(rename = "recentIntentSummaryView")]
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub recent_intent_summary_view: Option<Vec<IntentSummary>>,
193    /// <p>Map of key/value pairs representing the session-specific context information. It contains application information passed between Amazon Lex and a client application.</p>
194    #[serde(rename = "sessionAttributes")]
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub session_attributes: Option<::std::collections::HashMap<String, String>>,
197    /// <p>A unique identifier for the session.</p>
198    #[serde(rename = "sessionId")]
199    #[serde(skip_serializing_if = "Option::is_none")]
200    pub session_id: Option<String>,
201}
202
203/// <p>Provides a score that indicates the confidence that Amazon Lex has that an intent is the one that satisfies the user's intent.</p>
204#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
205#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
206pub struct IntentConfidence {
207    /// <p>A score that indicates how confident Amazon Lex is that an intent satisfies the user's intent. Ranges between 0.00 and 1.00. Higher scores indicate higher confidence.</p>
208    #[serde(rename = "score")]
209    #[serde(skip_serializing_if = "Option::is_none")]
210    pub score: Option<f64>,
211}
212
213/// <p>Provides information about the state of an intent. You can use this information to get the current state of an intent so that you can process the intent, or so that you can return the intent to its previous state.</p>
214#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
215pub struct IntentSummary {
216    /// <p>A user-defined label that identifies a particular intent. You can use this label to return to a previous intent. </p> <p>Use the <code>checkpointLabelFilter</code> parameter of the <code>GetSessionRequest</code> operation to filter the intents returned by the operation to those with only the specified label.</p>
217    #[serde(rename = "checkpointLabel")]
218    #[serde(skip_serializing_if = "Option::is_none")]
219    pub checkpoint_label: Option<String>,
220    /// <p><p>The status of the intent after the user responds to the confirmation prompt. If the user confirms the intent, Amazon Lex sets this field to <code>Confirmed</code>. If the user denies the intent, Amazon Lex sets this value to <code>Denied</code>. The possible values are:</p> <ul> <li> <p> <code>Confirmed</code> - The user has responded &quot;Yes&quot; to the confirmation prompt, confirming that the intent is complete and that it is ready to be fulfilled.</p> </li> <li> <p> <code>Denied</code> - The user has responded &quot;No&quot; to the confirmation prompt.</p> </li> <li> <p> <code>None</code> - The user has never been prompted for confirmation; or, the user was prompted but did not confirm or deny the prompt.</p> </li> </ul></p>
221    #[serde(rename = "confirmationStatus")]
222    #[serde(skip_serializing_if = "Option::is_none")]
223    pub confirmation_status: Option<String>,
224    /// <p><p>The next action that the bot should take in its interaction with the user. The possible values are:</p> <ul> <li> <p> <code>ConfirmIntent</code> - The next action is asking the user if the intent is complete and ready to be fulfilled. This is a yes/no question such as &quot;Place the order?&quot;</p> </li> <li> <p> <code>Close</code> - Indicates that the there will not be a response from the user. For example, the statement &quot;Your order has been placed&quot; does not require a response.</p> </li> <li> <p> <code>ElicitIntent</code> - The next action is to determine the intent that the user wants to fulfill.</p> </li> <li> <p> <code>ElicitSlot</code> - The next action is to elicit a slot value from the user.</p> </li> </ul></p>
225    #[serde(rename = "dialogActionType")]
226    pub dialog_action_type: String,
227    /// <p><p>The fulfillment state of the intent. The possible values are:</p> <ul> <li> <p> <code>Failed</code> - The Lambda function associated with the intent failed to fulfill the intent.</p> </li> <li> <p> <code>Fulfilled</code> - The intent has fulfilled by the Lambda function associated with the intent. </p> </li> <li> <p> <code>ReadyForFulfillment</code> - All of the information necessary for the intent is present and the intent ready to be fulfilled by the client application.</p> </li> </ul></p>
228    #[serde(rename = "fulfillmentState")]
229    #[serde(skip_serializing_if = "Option::is_none")]
230    pub fulfillment_state: Option<String>,
231    /// <p>The name of the intent.</p>
232    #[serde(rename = "intentName")]
233    #[serde(skip_serializing_if = "Option::is_none")]
234    pub intent_name: Option<String>,
235    /// <p>The next slot to elicit from the user. If there is not slot to elicit, the field is blank.</p>
236    #[serde(rename = "slotToElicit")]
237    #[serde(skip_serializing_if = "Option::is_none")]
238    pub slot_to_elicit: Option<String>,
239    /// <p>Map of the slots that have been gathered and their values. </p>
240    #[serde(rename = "slots")]
241    #[serde(skip_serializing_if = "Option::is_none")]
242    pub slots: Option<::std::collections::HashMap<String, String>>,
243}
244
245#[derive(Clone, Debug, Default, PartialEq, Serialize)]
246#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
247pub struct PostContentRequest {
248    /// <p><p> You pass this value as the <code>Accept</code> HTTP header. </p> <p> The message Amazon Lex returns in the response can be either text or speech based on the <code>Accept</code> HTTP header value in the request. </p> <ul> <li> <p> If the value is <code>text/plain; charset=utf-8</code>, Amazon Lex returns text in the response. </p> </li> <li> <p> If the value begins with <code>audio/</code>, Amazon Lex returns speech in the response. Amazon Lex uses Amazon Polly to generate the speech (using the configuration you specified in the <code>Accept</code> header). For example, if you specify <code>audio/mpeg</code> as the value, Amazon Lex returns speech in the MPEG format.</p> </li> <li> <p>If the value is <code>audio/pcm</code>, the speech returned is <code>audio/pcm</code> in 16-bit, little endian format. </p> </li> <li> <p>The following are the accepted values:</p> <ul> <li> <p>audio/mpeg</p> </li> <li> <p>audio/ogg</p> </li> <li> <p>audio/pcm</p> </li> <li> <p>text/plain; charset=utf-8</p> </li> <li> <p>audio/* (defaults to mpeg)</p> </li> </ul> </li> </ul></p>
249    #[serde(rename = "accept")]
250    #[serde(skip_serializing_if = "Option::is_none")]
251    pub accept: Option<String>,
252    /// <p>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,</p> <p>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.</p>
253    #[serde(rename = "activeContexts")]
254    #[serde(skip_serializing_if = "Option::is_none")]
255    pub active_contexts: Option<String>,
256    /// <p>Alias of the Amazon Lex bot.</p>
257    #[serde(rename = "botAlias")]
258    pub bot_alias: String,
259    /// <p>Name of the Amazon Lex bot.</p>
260    #[serde(rename = "botName")]
261    pub bot_name: String,
262    /// <p><p> You pass this value as the <code>Content-Type</code> HTTP header. </p> <p> Indicates the audio format or text. The header value must start with one of the following prefixes: </p> <ul> <li> <p>PCM format, audio data must be in little-endian byte order.</p> <ul> <li> <p>audio/l16; rate=16000; channels=1</p> </li> <li> <p>audio/x-l16; sample-rate=16000; channel-count=1</p> </li> <li> <p>audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false </p> </li> </ul> </li> <li> <p>Opus format</p> <ul> <li> <p>audio/x-cbr-opus-with-preamble; preamble-size=0; bit-rate=256000; frame-size-milliseconds=4</p> </li> </ul> </li> <li> <p>Text format</p> <ul> <li> <p>text/plain; charset=utf-8</p> </li> </ul> </li> </ul></p>
263    #[serde(rename = "contentType")]
264    pub content_type: String,
265    /// <p> User input in PCM or Opus audio format or text format as described in the <code>Content-Type</code> HTTP header. </p> <p>You can stream audio data to Amazon Lex or you can create a local buffer that captures all of the audio data before sending. In general, you get better performance if you stream audio data rather than buffering the data locally.</p>
266    #[serde(rename = "inputStream")]
267    #[serde(
268        deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
269        serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
270        default
271    )]
272    pub input_stream: bytes::Bytes,
273    /// <p>You pass this value as the <code>x-amz-lex-request-attributes</code> HTTP header.</p> <p>Request-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the <code>requestAttributes</code> and <code>sessionAttributes</code> headers is limited to 12 KB.</p> <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
274    #[serde(rename = "requestAttributes")]
275    #[serde(skip_serializing_if = "Option::is_none")]
276    pub request_attributes: Option<String>,
277    /// <p>You pass this value as the <code>x-amz-lex-session-attributes</code> HTTP header.</p> <p>Application-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the <code>sessionAttributes</code> and <code>requestAttributes</code> headers is limited to 12 KB.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
278    #[serde(rename = "sessionAttributes")]
279    #[serde(skip_serializing_if = "Option::is_none")]
280    pub session_attributes: Option<String>,
281    /// <p><p>The ID of the client application user. Amazon Lex uses this to identify a user&#39;s conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p> <p>To decide the user ID to use for your application, consider the following factors.</p> <ul> <li> <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p> </li> <li> <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p> </li> <li> <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p> </li> <li> <p>A user can&#39;t have two independent conversations with two different versions of the same bot. For example, a user can&#39;t have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p> </li> </ul></p>
282    #[serde(rename = "userId")]
283    pub user_id: String,
284}
285
286#[derive(Clone, Debug, Default, PartialEq)]
287pub struct PostContentResponse {
288    /// <p>A list of active contexts for the session. A context can be set when an intent is fulfilled or by calling the <code>PostContent</code>, <code>PostText</code>, or <code>PutSession</code> operation.</p> <p>You can use a context to control the intents that can follow up an intent, or to modify the operation of your application.</p>
289    pub active_contexts: Option<String>,
290    /// <p>One to four alternative intents that may be applicable to the user's intent.</p> <p>Each alternative includes a score that indicates how confident Amazon Lex is that the intent matches the user's intent. The intents are sorted by the confidence score.</p>
291    pub alternative_intents: Option<String>,
292    /// <p>The prompt (or statement) to convey to the user. This is based on the bot configuration and context. For example, if Amazon Lex did not understand the user intent, it sends the <code>clarificationPrompt</code> configured for the bot. If the intent requires confirmation before taking the fulfillment action, it sends the <code>confirmationPrompt</code>. Another example: Suppose that the Lambda function successfully fulfilled the intent, and sent a message to convey to the user. Then Amazon Lex sends that message in the response. </p>
293    pub audio_stream: Option<bytes::Bytes>,
294    /// <p>The version of the bot that responded to the conversation. You can use this information to help determine if one version of a bot is performing better than another version.</p>
295    pub bot_version: Option<String>,
296    /// <p>Content type as specified in the <code>Accept</code> HTTP header in the request.</p>
297    pub content_type: Option<String>,
298    /// <p><p>Identifies the current state of the user interaction. Amazon Lex returns one of the following values as <code>dialogState</code>. The client can optionally use this information to customize the user interface. </p> <ul> <li> <p> <code>ElicitIntent</code> - Amazon Lex wants to elicit the user&#39;s intent. Consider the following examples: </p> <p> For example, a user might utter an intent (&quot;I want to order a pizza&quot;). If Amazon Lex cannot infer the user intent from this utterance, it will return this dialog state. </p> </li> <li> <p> <code>ConfirmIntent</code> - Amazon Lex is expecting a &quot;yes&quot; or &quot;no&quot; response. </p> <p>For example, Amazon Lex wants user confirmation before fulfilling an intent. Instead of a simple &quot;yes&quot; or &quot;no&quot; response, a user might respond with additional information. For example, &quot;yes, but make it a thick crust pizza&quot; or &quot;no, I want to order a drink.&quot; Amazon Lex can process such additional information (in these examples, update the crust type slot or change the intent from OrderPizza to OrderDrink). </p> </li> <li> <p> <code>ElicitSlot</code> - Amazon Lex is expecting the value of a slot for the current intent. </p> <p> For example, suppose that in the response Amazon Lex sends this message: &quot;What size pizza would you like?&quot;. A user might reply with the slot value (e.g., &quot;medium&quot;). The user might also provide additional information in the response (e.g., &quot;medium thick crust pizza&quot;). Amazon Lex can process such additional information appropriately. </p> </li> <li> <p> <code>Fulfilled</code> - Conveys that the Lambda function has successfully fulfilled the intent. </p> </li> <li> <p> <code>ReadyForFulfillment</code> - Conveys that the client has to fulfill the request. </p> </li> <li> <p> <code>Failed</code> - Conveys that the conversation with the user failed. </p> <p> This can happen for various reasons, including that the user does not provide an appropriate response to prompts from the service (you can configure how many times Amazon Lex can prompt a user for specific information), or if the Lambda function fails to fulfill the intent. </p> </li> </ul></p>
299    pub dialog_state: Option<String>,
300    /// <p>The text used to process the request.</p> <p>If the input was an audio stream, the <code>encodedInputTranscript</code> field 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 is correctly processing the audio that you send.</p> <p>The <code>encodedInputTranscript</code> field is base-64 encoded. You must decode the field before you can use the value.</p>
301    pub encoded_input_transcript: Option<String>,
302    /// <p>The message to convey to the user. The message can come from the bot's configuration or from a Lambda function.</p> <p>If the intent is not configured with a Lambda function, or if the Lambda function returned <code>Delegate</code> as the <code>dialogAction.type</code> in its response, Amazon Lex decides on the next course of action and selects an appropriate message from the bot's configuration based on the current interaction context. For example, if Amazon Lex isn't able to understand user input, it uses a clarification prompt message.</p> <p>When you create an intent you can assign messages to groups. When messages are assigned to groups Amazon Lex returns one message from each group in the response. The message field is an escaped JSON string containing the messages. For more information about the structure of the JSON string returned, see <a>msg-prompts-formats</a>.</p> <p>If the Lambda function returns a message, Amazon Lex passes it to the client in its response.</p> <p>The <code>encodedMessage</code> field is base-64 encoded. You must decode the field before you can use the value.</p>
303    pub encoded_message: Option<String>,
304    /// <p>Current user intent that Amazon Lex is aware of.</p>
305    pub intent_name: Option<String>,
306    /// <p><p>The format of the response message. One of the following values:</p> <ul> <li> <p> <code>PlainText</code> - The message contains plain UTF-8 text.</p> </li> <li> <p> <code>CustomPayload</code> - The message is a custom format for the client.</p> </li> <li> <p> <code>SSML</code> - The message contains text formatted for voice output.</p> </li> <li> <p> <code>Composite</code> - The message contains an escaped JSON object containing one or more messages from the groups that messages were assigned to when the intent was created.</p> </li> </ul></p>
307    pub message_format: Option<String>,
308    /// <p>Provides a score that indicates how confident Amazon Lex is that the returned intent is the one that matches the user's intent. The score is between 0.0 and 1.0.</p> <p>The score is a relative score, not an absolute score. The score may change based on improvements to Amazon Lex. </p>
309    pub nlu_intent_confidence: Option<String>,
310    /// <p>The sentiment expressed in an utterance.</p> <p>When the bot is configured to send utterances to Amazon Comprehend for sentiment analysis, this field contains the result of the analysis.</p>
311    pub sentiment_response: Option<String>,
312    /// <p> Map of key/value pairs representing the session-specific context information. </p>
313    pub session_attributes: Option<String>,
314    /// <p>The unique identifier for the session.</p>
315    pub session_id: Option<String>,
316    /// <p> If the <code>dialogState</code> value is <code>ElicitSlot</code>, returns the name of the slot for which Amazon Lex is eliciting a value. </p>
317    pub slot_to_elicit: Option<String>,
318    /// <p>Map of zero or more intent slots (name/value pairs) Amazon Lex detected from the user input during the conversation. The field is base-64 encoded.</p> <p>Amazon Lex creates a resolution list containing likely values for a slot. The value that it returns is determined by the <code>valueSelectionStrategy</code> selected when the slot type was created or updated. If <code>valueSelectionStrategy</code> is set to <code>ORIGINAL_VALUE</code>, the value provided by the user is returned, if the user value is similar to the slot values. If <code>valueSelectionStrategy</code> is set to <code>TOP_RESOLUTION</code> Amazon Lex returns the first value in the resolution list or, if there is no resolution list, null. If you don't specify a <code>valueSelectionStrategy</code>, the default is <code>ORIGINAL_VALUE</code>.</p>
319    pub slots: Option<String>,
320}
321
322#[derive(Clone, Debug, Default, PartialEq, Serialize)]
323#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
324pub struct PostTextRequest {
325    /// <p>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,</p> <p>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.</p>
326    #[serde(rename = "activeContexts")]
327    #[serde(skip_serializing_if = "Option::is_none")]
328    pub active_contexts: Option<Vec<ActiveContext>>,
329    /// <p>The alias of the Amazon Lex bot.</p>
330    #[serde(rename = "botAlias")]
331    pub bot_alias: String,
332    /// <p>The name of the Amazon Lex bot.</p>
333    #[serde(rename = "botName")]
334    pub bot_name: String,
335    /// <p>The text that the user entered (Amazon Lex interprets this text).</p>
336    #[serde(rename = "inputText")]
337    pub input_text: String,
338    /// <p>Request-specific information passed between Amazon Lex and a client application.</p> <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
339    #[serde(rename = "requestAttributes")]
340    #[serde(skip_serializing_if = "Option::is_none")]
341    pub request_attributes: Option<::std::collections::HashMap<String, String>>,
342    /// <p>Application-specific information passed between Amazon Lex and a client application.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
343    #[serde(rename = "sessionAttributes")]
344    #[serde(skip_serializing_if = "Option::is_none")]
345    pub session_attributes: Option<::std::collections::HashMap<String, String>>,
346    /// <p><p>The ID of the client application user. Amazon Lex uses this to identify a user&#39;s conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p> <p>To decide the user ID to use for your application, consider the following factors.</p> <ul> <li> <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p> </li> <li> <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p> </li> <li> <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p> </li> <li> <p>A user can&#39;t have two independent conversations with two different versions of the same bot. For example, a user can&#39;t have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p> </li> </ul></p>
347    #[serde(rename = "userId")]
348    pub user_id: String,
349}
350
351#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
352#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
353pub struct PostTextResponse {
354    /// <p>A list of active contexts for the session. A context can be set when an intent is fulfilled or by calling the <code>PostContent</code>, <code>PostText</code>, or <code>PutSession</code> operation.</p> <p>You can use a context to control the intents that can follow up an intent, or to modify the operation of your application.</p>
355    #[serde(rename = "activeContexts")]
356    #[serde(skip_serializing_if = "Option::is_none")]
357    pub active_contexts: Option<Vec<ActiveContext>>,
358    /// <p>One to four alternative intents that may be applicable to the user's intent.</p> <p>Each alternative includes a score that indicates how confident Amazon Lex is that the intent matches the user's intent. The intents are sorted by the confidence score.</p>
359    #[serde(rename = "alternativeIntents")]
360    #[serde(skip_serializing_if = "Option::is_none")]
361    pub alternative_intents: Option<Vec<PredictedIntent>>,
362    /// <p>The version of the bot that responded to the conversation. You can use this information to help determine if one version of a bot is performing better than another version.</p>
363    #[serde(rename = "botVersion")]
364    #[serde(skip_serializing_if = "Option::is_none")]
365    pub bot_version: Option<String>,
366    /// <p><p> Identifies the current state of the user interaction. Amazon Lex returns one of the following values as <code>dialogState</code>. The client can optionally use this information to customize the user interface. </p> <ul> <li> <p> <code>ElicitIntent</code> - Amazon Lex wants to elicit user intent. </p> <p>For example, a user might utter an intent (&quot;I want to order a pizza&quot;). If Amazon Lex cannot infer the user intent from this utterance, it will return this dialogState.</p> </li> <li> <p> <code>ConfirmIntent</code> - Amazon Lex is expecting a &quot;yes&quot; or &quot;no&quot; response. </p> <p> For example, Amazon Lex wants user confirmation before fulfilling an intent. </p> <p>Instead of a simple &quot;yes&quot; or &quot;no,&quot; a user might respond with additional information. For example, &quot;yes, but make it thick crust pizza&quot; or &quot;no, I want to order a drink&quot;. Amazon Lex can process such additional information (in these examples, update the crust type slot value, or change intent from OrderPizza to OrderDrink).</p> </li> <li> <p> <code>ElicitSlot</code> - Amazon Lex is expecting a slot value for the current intent. </p> <p>For example, suppose that in the response Amazon Lex sends this message: &quot;What size pizza would you like?&quot;. A user might reply with the slot value (e.g., &quot;medium&quot;). The user might also provide additional information in the response (e.g., &quot;medium thick crust pizza&quot;). Amazon Lex can process such additional information appropriately. </p> </li> <li> <p> <code>Fulfilled</code> - Conveys that the Lambda function configured for the intent has successfully fulfilled the intent. </p> </li> <li> <p> <code>ReadyForFulfillment</code> - Conveys that the client has to fulfill the intent. </p> </li> <li> <p> <code>Failed</code> - Conveys that the conversation with the user failed. </p> <p> This can happen for various reasons including that the user did not provide an appropriate response to prompts from the service (you can configure how many times Amazon Lex can prompt a user for specific information), or the Lambda function failed to fulfill the intent. </p> </li> </ul></p>
367    #[serde(rename = "dialogState")]
368    #[serde(skip_serializing_if = "Option::is_none")]
369    pub dialog_state: Option<String>,
370    /// <p>The current user intent that Amazon Lex is aware of.</p>
371    #[serde(rename = "intentName")]
372    #[serde(skip_serializing_if = "Option::is_none")]
373    pub intent_name: Option<String>,
374    /// <p>The message to convey to the user. The message can come from the bot's configuration or from a Lambda function.</p> <p>If the intent is not configured with a Lambda function, or if the Lambda function returned <code>Delegate</code> as the <code>dialogAction.type</code> its response, Amazon Lex decides on the next course of action and selects an appropriate message from the bot's configuration based on the current interaction context. For example, if Amazon Lex isn't able to understand user input, it uses a clarification prompt message.</p> <p>When you create an intent you can assign messages to groups. When messages are assigned to groups Amazon Lex returns one message from each group in the response. The message field is an escaped JSON string containing the messages. For more information about the structure of the JSON string returned, see <a>msg-prompts-formats</a>.</p> <p>If the Lambda function returns a message, Amazon Lex passes it to the client in its response.</p>
375    #[serde(rename = "message")]
376    #[serde(skip_serializing_if = "Option::is_none")]
377    pub message: Option<String>,
378    /// <p><p>The format of the response message. One of the following values:</p> <ul> <li> <p> <code>PlainText</code> - The message contains plain UTF-8 text.</p> </li> <li> <p> <code>CustomPayload</code> - The message is a custom format defined by the Lambda function.</p> </li> <li> <p> <code>SSML</code> - The message contains text formatted for voice output.</p> </li> <li> <p> <code>Composite</code> - The message contains an escaped JSON object containing one or more messages from the groups that messages were assigned to when the intent was created.</p> </li> </ul></p>
379    #[serde(rename = "messageFormat")]
380    #[serde(skip_serializing_if = "Option::is_none")]
381    pub message_format: Option<String>,
382    /// <p>Provides a score that indicates how confident Amazon Lex is that the returned intent is the one that matches the user's intent. The score is between 0.0 and 1.0. For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/confidence-scores.html">Confidence Scores</a>.</p> <p>The score is a relative score, not an absolute score. The score may change based on improvements to Amazon Lex.</p>
383    #[serde(rename = "nluIntentConfidence")]
384    #[serde(skip_serializing_if = "Option::is_none")]
385    pub nlu_intent_confidence: Option<IntentConfidence>,
386    /// <p>Represents the options that the user has to respond to the current prompt. Response Card can come from the bot configuration (in the Amazon Lex console, choose the settings button next to a slot) or from a code hook (Lambda function). </p>
387    #[serde(rename = "responseCard")]
388    #[serde(skip_serializing_if = "Option::is_none")]
389    pub response_card: Option<ResponseCard>,
390    /// <p>The sentiment expressed in and utterance.</p> <p>When the bot is configured to send utterances to Amazon Comprehend for sentiment analysis, this field contains the result of the analysis.</p>
391    #[serde(rename = "sentimentResponse")]
392    #[serde(skip_serializing_if = "Option::is_none")]
393    pub sentiment_response: Option<SentimentResponse>,
394    /// <p>A map of key-value pairs representing the session-specific context information.</p>
395    #[serde(rename = "sessionAttributes")]
396    #[serde(skip_serializing_if = "Option::is_none")]
397    pub session_attributes: Option<::std::collections::HashMap<String, String>>,
398    /// <p>A unique identifier for the session.</p>
399    #[serde(rename = "sessionId")]
400    #[serde(skip_serializing_if = "Option::is_none")]
401    pub session_id: Option<String>,
402    /// <p>If the <code>dialogState</code> value is <code>ElicitSlot</code>, returns the name of the slot for which Amazon Lex is eliciting a value. </p>
403    #[serde(rename = "slotToElicit")]
404    #[serde(skip_serializing_if = "Option::is_none")]
405    pub slot_to_elicit: Option<String>,
406    /// <p> The intent slots that Amazon Lex detected from the user input in the conversation. </p> <p>Amazon Lex creates a resolution list containing likely values for a slot. The value that it returns is determined by the <code>valueSelectionStrategy</code> selected when the slot type was created or updated. If <code>valueSelectionStrategy</code> is set to <code>ORIGINAL_VALUE</code>, the value provided by the user is returned, if the user value is similar to the slot values. If <code>valueSelectionStrategy</code> is set to <code>TOP_RESOLUTION</code> Amazon Lex returns the first value in the resolution list or, if there is no resolution list, null. If you don't specify a <code>valueSelectionStrategy</code>, the default is <code>ORIGINAL_VALUE</code>.</p>
407    #[serde(rename = "slots")]
408    #[serde(skip_serializing_if = "Option::is_none")]
409    pub slots: Option<::std::collections::HashMap<String, Option<String>>>,
410}
411
412/// <p>An intent that Amazon Lex suggests satisfies the user's intent. Includes the name of the intent, the confidence that Amazon Lex has that the user's intent is satisfied, and the slots defined for the intent.</p>
413#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
414#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
415pub struct PredictedIntent {
416    /// <p>The name of the intent that Amazon Lex suggests satisfies the user's intent.</p>
417    #[serde(rename = "intentName")]
418    #[serde(skip_serializing_if = "Option::is_none")]
419    pub intent_name: Option<String>,
420    /// <p>Indicates how confident Amazon Lex is that an intent satisfies the user's intent.</p>
421    #[serde(rename = "nluIntentConfidence")]
422    #[serde(skip_serializing_if = "Option::is_none")]
423    pub nlu_intent_confidence: Option<IntentConfidence>,
424    /// <p>The slot and slot values associated with the predicted intent.</p>
425    #[serde(rename = "slots")]
426    #[serde(skip_serializing_if = "Option::is_none")]
427    pub slots: Option<::std::collections::HashMap<String, String>>,
428}
429
430#[derive(Clone, Debug, Default, PartialEq, Serialize)]
431#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
432pub struct PutSessionRequest {
433    /// <p><p>The message that Amazon Lex returns in the response can be either text or speech based depending on the value of this field.</p> <ul> <li> <p>If the value is <code>text/plain; charset=utf-8</code>, Amazon Lex returns text in the response.</p> </li> <li> <p>If the value begins with <code>audio/</code>, 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 specify <code>audio/mpeg</code> as the value, Amazon Lex returns speech in the MPEG format.</p> </li> <li> <p>If the value is <code>audio/pcm</code>, the speech is returned as <code>audio/pcm</code> in 16-bit, little endian format.</p> </li> <li> <p>The following are the accepted values:</p> <ul> <li> <p> <code>audio/mpeg</code> </p> </li> <li> <p> <code>audio/ogg</code> </p> </li> <li> <p> <code>audio/pcm</code> </p> </li> <li> <p> <code>audio/*</code> (defaults to mpeg)</p> </li> <li> <p> <code>text/plain; charset=utf-8</code> </p> </li> </ul> </li> </ul></p>
434    #[serde(rename = "accept")]
435    #[serde(skip_serializing_if = "Option::is_none")]
436    pub accept: Option<String>,
437    /// <p>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,</p> <p>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.</p>
438    #[serde(rename = "activeContexts")]
439    #[serde(skip_serializing_if = "Option::is_none")]
440    pub active_contexts: Option<Vec<ActiveContext>>,
441    /// <p>The alias in use for the bot that contains the session data.</p>
442    #[serde(rename = "botAlias")]
443    pub bot_alias: String,
444    /// <p>The name of the bot that contains the session data.</p>
445    #[serde(rename = "botName")]
446    pub bot_name: String,
447    /// <p>Sets the next action that the bot should take to fulfill the conversation.</p>
448    #[serde(rename = "dialogAction")]
449    #[serde(skip_serializing_if = "Option::is_none")]
450    pub dialog_action: Option<DialogAction>,
451    /// <p>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.</p> <p>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:</p> <ul> <li> <p> <code>intentName</code> </p> </li> <li> <p>slot names</p> </li> <li> <p> <code>slotToElict</code> </p> </li> </ul> <p>If you send the <code>recentIntentSummaryView</code> parameter in a <code>PutSession</code> request, the contents of the new summary view replaces the old summary view. For example, if a <code>GetSession</code> request returns three intents in the summary view and you call <code>PutSession</code> with one intent in the summary view, the next call to <code>GetSession</code> will only return one intent.</p>
452    #[serde(rename = "recentIntentSummaryView")]
453    #[serde(skip_serializing_if = "Option::is_none")]
454    pub recent_intent_summary_view: Option<Vec<IntentSummary>>,
455    /// <p>Map of key/value pairs representing the session-specific context information. It contains application information passed between Amazon Lex and a client application.</p>
456    #[serde(rename = "sessionAttributes")]
457    #[serde(skip_serializing_if = "Option::is_none")]
458    pub session_attributes: Option<::std::collections::HashMap<String, String>>,
459    /// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. </p>
460    #[serde(rename = "userId")]
461    pub user_id: String,
462}
463
464#[derive(Clone, Debug, Default, PartialEq)]
465pub struct PutSessionResponse {
466    /// <p>A list of active contexts for the session.</p>
467    pub active_contexts: Option<String>,
468    /// <p>The audio version of the message to convey to the user.</p>
469    pub audio_stream: Option<bytes::Bytes>,
470    /// <p>Content type as specified in the <code>Accept</code> HTTP header in the request.</p>
471    pub content_type: Option<String>,
472    /// <p><p/> <ul> <li> <p> <code>ConfirmIntent</code> - Amazon Lex is expecting a &quot;yes&quot; or &quot;no&quot; response to confirm the intent before fulfilling an intent.</p> </li> <li> <p> <code>ElicitIntent</code> - Amazon Lex wants to elicit the user&#39;s intent.</p> </li> <li> <p> <code>ElicitSlot</code> - Amazon Lex is expecting the value of a slot for the current intent.</p> </li> <li> <p> <code>Failed</code> - Conveys that the conversation with the user has failed. This can happen for various reasons, including the user does not provide an appropriate response to prompts from the service, or if the Lambda function fails to fulfill the intent.</p> </li> <li> <p> <code>Fulfilled</code> - Conveys that the Lambda function has sucessfully fulfilled the intent.</p> </li> <li> <p> <code>ReadyForFulfillment</code> - Conveys that the client has to fulfill the intent.</p> </li> </ul></p>
473    pub dialog_state: Option<String>,
474    /// <p>The next message that should be presented to the user.</p> <p>The <code>encodedMessage</code> field is base-64 encoded. You must decode the field before you can use the value.</p>
475    pub encoded_message: Option<String>,
476    /// <p>The name of the current intent.</p>
477    pub intent_name: Option<String>,
478    /// <p><p>The format of the response message. One of the following values:</p> <ul> <li> <p> <code>PlainText</code> - The message contains plain UTF-8 text.</p> </li> <li> <p> <code>CustomPayload</code> - The message is a custom format for the client.</p> </li> <li> <p> <code>SSML</code> - The message contains text formatted for voice output.</p> </li> <li> <p> <code>Composite</code> - The message contains an escaped JSON object containing one or more messages from the groups that messages were assigned to when the intent was created.</p> </li> </ul></p>
479    pub message_format: Option<String>,
480    /// <p>Map of key/value pairs representing session-specific context information.</p>
481    pub session_attributes: Option<String>,
482    /// <p>A unique identifier for the session.</p>
483    pub session_id: Option<String>,
484    /// <p>If the <code>dialogState</code> is <code>ElicitSlot</code>, returns the name of the slot for which Amazon Lex is eliciting a value.</p>
485    pub slot_to_elicit: Option<String>,
486    /// <p>Map of zero or more intent slots Amazon Lex detected from the user input during the conversation.</p> <p>Amazon Lex creates a resolution list containing likely values for a slot. The value that it returns is determined by the <code>valueSelectionStrategy</code> selected when the slot type was created or updated. If <code>valueSelectionStrategy</code> is set to <code>ORIGINAL_VALUE</code>, the value provided by the user is returned, if the user value is similar to the slot values. If <code>valueSelectionStrategy</code> is set to <code>TOP_RESOLUTION</code> Amazon Lex returns the first value in the resolution list or, if there is no resolution list, null. If you don't specify a <code>valueSelectionStrategy</code> the default is <code>ORIGINAL_VALUE</code>. </p>
487    pub slots: Option<String>,
488}
489
490/// <p>If you configure a response card when creating your bots, Amazon Lex substitutes the session attributes and slot values that are available, and then returns it. The response card can also come from a Lambda function ( <code>dialogCodeHook</code> and <code>fulfillmentActivity</code> on an intent).</p>
491#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
492#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
493pub struct ResponseCard {
494    /// <p>The content type of the response.</p>
495    #[serde(rename = "contentType")]
496    #[serde(skip_serializing_if = "Option::is_none")]
497    pub content_type: Option<String>,
498    /// <p>An array of attachment objects representing options.</p>
499    #[serde(rename = "genericAttachments")]
500    #[serde(skip_serializing_if = "Option::is_none")]
501    pub generic_attachments: Option<Vec<GenericAttachment>>,
502    /// <p>The version of the response card format.</p>
503    #[serde(rename = "version")]
504    #[serde(skip_serializing_if = "Option::is_none")]
505    pub version: Option<String>,
506}
507
508/// <p>The sentiment expressed in an utterance.</p> <p>When the bot is configured to send utterances to Amazon Comprehend for sentiment analysis, this field structure contains the result of the analysis.</p>
509#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
510#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
511pub struct SentimentResponse {
512    /// <p>The inferred sentiment that Amazon Comprehend has the highest confidence in.</p>
513    #[serde(rename = "sentimentLabel")]
514    #[serde(skip_serializing_if = "Option::is_none")]
515    pub sentiment_label: Option<String>,
516    /// <p>The likelihood that the sentiment was correctly inferred.</p>
517    #[serde(rename = "sentimentScore")]
518    #[serde(skip_serializing_if = "Option::is_none")]
519    pub sentiment_score: Option<String>,
520}
521
522/// Errors returned by DeleteSession
523#[derive(Debug, PartialEq)]
524pub enum DeleteSessionError {
525    /// <p> Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes. </p>
526    BadRequest(String),
527    /// <p> Two clients are using the same AWS account, Amazon Lex bot, and user ID. </p>
528    Conflict(String),
529    /// <p>Internal service error. Retry the call.</p>
530    InternalFailure(String),
531    /// <p>Exceeded a limit.</p>
532    LimitExceeded(String),
533    /// <p>The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.</p>
534    NotFound(String),
535}
536
537impl DeleteSessionError {
538    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteSessionError> {
539        if let Some(err) = proto::json::Error::parse_rest(&res) {
540            match err.typ.as_str() {
541                "BadRequestException" => {
542                    return RusotoError::Service(DeleteSessionError::BadRequest(err.msg))
543                }
544                "ConflictException" => {
545                    return RusotoError::Service(DeleteSessionError::Conflict(err.msg))
546                }
547                "InternalFailureException" => {
548                    return RusotoError::Service(DeleteSessionError::InternalFailure(err.msg))
549                }
550                "LimitExceededException" => {
551                    return RusotoError::Service(DeleteSessionError::LimitExceeded(err.msg))
552                }
553                "NotFoundException" => {
554                    return RusotoError::Service(DeleteSessionError::NotFound(err.msg))
555                }
556                "ValidationException" => return RusotoError::Validation(err.msg),
557                _ => {}
558            }
559        }
560        RusotoError::Unknown(res)
561    }
562}
563impl fmt::Display for DeleteSessionError {
564    #[allow(unused_variables)]
565    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
566        match *self {
567            DeleteSessionError::BadRequest(ref cause) => write!(f, "{}", cause),
568            DeleteSessionError::Conflict(ref cause) => write!(f, "{}", cause),
569            DeleteSessionError::InternalFailure(ref cause) => write!(f, "{}", cause),
570            DeleteSessionError::LimitExceeded(ref cause) => write!(f, "{}", cause),
571            DeleteSessionError::NotFound(ref cause) => write!(f, "{}", cause),
572        }
573    }
574}
575impl Error for DeleteSessionError {}
576/// Errors returned by GetSession
577#[derive(Debug, PartialEq)]
578pub enum GetSessionError {
579    /// <p> Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes. </p>
580    BadRequest(String),
581    /// <p>Internal service error. Retry the call.</p>
582    InternalFailure(String),
583    /// <p>Exceeded a limit.</p>
584    LimitExceeded(String),
585    /// <p>The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.</p>
586    NotFound(String),
587}
588
589impl GetSessionError {
590    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetSessionError> {
591        if let Some(err) = proto::json::Error::parse_rest(&res) {
592            match err.typ.as_str() {
593                "BadRequestException" => {
594                    return RusotoError::Service(GetSessionError::BadRequest(err.msg))
595                }
596                "InternalFailureException" => {
597                    return RusotoError::Service(GetSessionError::InternalFailure(err.msg))
598                }
599                "LimitExceededException" => {
600                    return RusotoError::Service(GetSessionError::LimitExceeded(err.msg))
601                }
602                "NotFoundException" => {
603                    return RusotoError::Service(GetSessionError::NotFound(err.msg))
604                }
605                "ValidationException" => return RusotoError::Validation(err.msg),
606                _ => {}
607            }
608        }
609        RusotoError::Unknown(res)
610    }
611}
612impl fmt::Display for GetSessionError {
613    #[allow(unused_variables)]
614    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
615        match *self {
616            GetSessionError::BadRequest(ref cause) => write!(f, "{}", cause),
617            GetSessionError::InternalFailure(ref cause) => write!(f, "{}", cause),
618            GetSessionError::LimitExceeded(ref cause) => write!(f, "{}", cause),
619            GetSessionError::NotFound(ref cause) => write!(f, "{}", cause),
620        }
621    }
622}
623impl Error for GetSessionError {}
624/// Errors returned by PostContent
625#[derive(Debug, PartialEq)]
626pub enum PostContentError {
627    /// <p>Either the Amazon Lex bot is still building, or one of the dependent services (Amazon Polly, AWS Lambda) failed with an internal service error.</p>
628    BadGateway(String),
629    /// <p> Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes. </p>
630    BadRequest(String),
631    /// <p> Two clients are using the same AWS account, Amazon Lex bot, and user ID. </p>
632    Conflict(String),
633    /// <p><p> One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example, </p> <ul> <li> <p>If Amazon Lex does not have sufficient permissions to call a Lambda function.</p> </li> <li> <p>If a Lambda function takes longer than 30 seconds to execute.</p> </li> <li> <p>If a fulfillment Lambda function returns a <code>Delegate</code> dialog action without removing any slot values.</p> </li> </ul></p>
634    DependencyFailed(String),
635    /// <p>Internal service error. Retry the call.</p>
636    InternalFailure(String),
637    /// <p>Exceeded a limit.</p>
638    LimitExceeded(String),
639    /// <p>This exception is not used.</p>
640    LoopDetected(String),
641    /// <p>The accept header in the request does not have a valid value.</p>
642    NotAcceptable(String),
643    /// <p>The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.</p>
644    NotFound(String),
645    /// <p>The input speech is too long.</p>
646    RequestTimeout(String),
647    /// <p>The Content-Type header (<code>PostContent</code> API) has an invalid value. </p>
648    UnsupportedMediaType(String),
649}
650
651impl PostContentError {
652    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PostContentError> {
653        if let Some(err) = proto::json::Error::parse_rest(&res) {
654            match err.typ.as_str() {
655                "BadGatewayException" => {
656                    return RusotoError::Service(PostContentError::BadGateway(err.msg))
657                }
658                "BadRequestException" => {
659                    return RusotoError::Service(PostContentError::BadRequest(err.msg))
660                }
661                "ConflictException" => {
662                    return RusotoError::Service(PostContentError::Conflict(err.msg))
663                }
664                "DependencyFailedException" => {
665                    return RusotoError::Service(PostContentError::DependencyFailed(err.msg))
666                }
667                "InternalFailureException" => {
668                    return RusotoError::Service(PostContentError::InternalFailure(err.msg))
669                }
670                "LimitExceededException" => {
671                    return RusotoError::Service(PostContentError::LimitExceeded(err.msg))
672                }
673                "LoopDetectedException" => {
674                    return RusotoError::Service(PostContentError::LoopDetected(err.msg))
675                }
676                "NotAcceptableException" => {
677                    return RusotoError::Service(PostContentError::NotAcceptable(err.msg))
678                }
679                "NotFoundException" => {
680                    return RusotoError::Service(PostContentError::NotFound(err.msg))
681                }
682                "RequestTimeoutException" => {
683                    return RusotoError::Service(PostContentError::RequestTimeout(err.msg))
684                }
685                "UnsupportedMediaTypeException" => {
686                    return RusotoError::Service(PostContentError::UnsupportedMediaType(err.msg))
687                }
688                "ValidationException" => return RusotoError::Validation(err.msg),
689                _ => {}
690            }
691        }
692        RusotoError::Unknown(res)
693    }
694}
695impl fmt::Display for PostContentError {
696    #[allow(unused_variables)]
697    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
698        match *self {
699            PostContentError::BadGateway(ref cause) => write!(f, "{}", cause),
700            PostContentError::BadRequest(ref cause) => write!(f, "{}", cause),
701            PostContentError::Conflict(ref cause) => write!(f, "{}", cause),
702            PostContentError::DependencyFailed(ref cause) => write!(f, "{}", cause),
703            PostContentError::InternalFailure(ref cause) => write!(f, "{}", cause),
704            PostContentError::LimitExceeded(ref cause) => write!(f, "{}", cause),
705            PostContentError::LoopDetected(ref cause) => write!(f, "{}", cause),
706            PostContentError::NotAcceptable(ref cause) => write!(f, "{}", cause),
707            PostContentError::NotFound(ref cause) => write!(f, "{}", cause),
708            PostContentError::RequestTimeout(ref cause) => write!(f, "{}", cause),
709            PostContentError::UnsupportedMediaType(ref cause) => write!(f, "{}", cause),
710        }
711    }
712}
713impl Error for PostContentError {}
714/// Errors returned by PostText
715#[derive(Debug, PartialEq)]
716pub enum PostTextError {
717    /// <p>Either the Amazon Lex bot is still building, or one of the dependent services (Amazon Polly, AWS Lambda) failed with an internal service error.</p>
718    BadGateway(String),
719    /// <p> Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes. </p>
720    BadRequest(String),
721    /// <p> Two clients are using the same AWS account, Amazon Lex bot, and user ID. </p>
722    Conflict(String),
723    /// <p><p> One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example, </p> <ul> <li> <p>If Amazon Lex does not have sufficient permissions to call a Lambda function.</p> </li> <li> <p>If a Lambda function takes longer than 30 seconds to execute.</p> </li> <li> <p>If a fulfillment Lambda function returns a <code>Delegate</code> dialog action without removing any slot values.</p> </li> </ul></p>
724    DependencyFailed(String),
725    /// <p>Internal service error. Retry the call.</p>
726    InternalFailure(String),
727    /// <p>Exceeded a limit.</p>
728    LimitExceeded(String),
729    /// <p>This exception is not used.</p>
730    LoopDetected(String),
731    /// <p>The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.</p>
732    NotFound(String),
733}
734
735impl PostTextError {
736    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PostTextError> {
737        if let Some(err) = proto::json::Error::parse_rest(&res) {
738            match err.typ.as_str() {
739                "BadGatewayException" => {
740                    return RusotoError::Service(PostTextError::BadGateway(err.msg))
741                }
742                "BadRequestException" => {
743                    return RusotoError::Service(PostTextError::BadRequest(err.msg))
744                }
745                "ConflictException" => {
746                    return RusotoError::Service(PostTextError::Conflict(err.msg))
747                }
748                "DependencyFailedException" => {
749                    return RusotoError::Service(PostTextError::DependencyFailed(err.msg))
750                }
751                "InternalFailureException" => {
752                    return RusotoError::Service(PostTextError::InternalFailure(err.msg))
753                }
754                "LimitExceededException" => {
755                    return RusotoError::Service(PostTextError::LimitExceeded(err.msg))
756                }
757                "LoopDetectedException" => {
758                    return RusotoError::Service(PostTextError::LoopDetected(err.msg))
759                }
760                "NotFoundException" => {
761                    return RusotoError::Service(PostTextError::NotFound(err.msg))
762                }
763                "ValidationException" => return RusotoError::Validation(err.msg),
764                _ => {}
765            }
766        }
767        RusotoError::Unknown(res)
768    }
769}
770impl fmt::Display for PostTextError {
771    #[allow(unused_variables)]
772    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
773        match *self {
774            PostTextError::BadGateway(ref cause) => write!(f, "{}", cause),
775            PostTextError::BadRequest(ref cause) => write!(f, "{}", cause),
776            PostTextError::Conflict(ref cause) => write!(f, "{}", cause),
777            PostTextError::DependencyFailed(ref cause) => write!(f, "{}", cause),
778            PostTextError::InternalFailure(ref cause) => write!(f, "{}", cause),
779            PostTextError::LimitExceeded(ref cause) => write!(f, "{}", cause),
780            PostTextError::LoopDetected(ref cause) => write!(f, "{}", cause),
781            PostTextError::NotFound(ref cause) => write!(f, "{}", cause),
782        }
783    }
784}
785impl Error for PostTextError {}
786/// Errors returned by PutSession
787#[derive(Debug, PartialEq)]
788pub enum PutSessionError {
789    /// <p>Either the Amazon Lex bot is still building, or one of the dependent services (Amazon Polly, AWS Lambda) failed with an internal service error.</p>
790    BadGateway(String),
791    /// <p> Request validation failed, there is no usable message in the context, or the bot build failed, is still in progress, or contains unbuilt changes. </p>
792    BadRequest(String),
793    /// <p> Two clients are using the same AWS account, Amazon Lex bot, and user ID. </p>
794    Conflict(String),
795    /// <p><p> One of the dependencies, such as AWS Lambda or Amazon Polly, threw an exception. For example, </p> <ul> <li> <p>If Amazon Lex does not have sufficient permissions to call a Lambda function.</p> </li> <li> <p>If a Lambda function takes longer than 30 seconds to execute.</p> </li> <li> <p>If a fulfillment Lambda function returns a <code>Delegate</code> dialog action without removing any slot values.</p> </li> </ul></p>
796    DependencyFailed(String),
797    /// <p>Internal service error. Retry the call.</p>
798    InternalFailure(String),
799    /// <p>Exceeded a limit.</p>
800    LimitExceeded(String),
801    /// <p>The accept header in the request does not have a valid value.</p>
802    NotAcceptable(String),
803    /// <p>The resource (such as the Amazon Lex bot or an alias) that is referred to is not found.</p>
804    NotFound(String),
805}
806
807impl PutSessionError {
808    pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutSessionError> {
809        if let Some(err) = proto::json::Error::parse_rest(&res) {
810            match err.typ.as_str() {
811                "BadGatewayException" => {
812                    return RusotoError::Service(PutSessionError::BadGateway(err.msg))
813                }
814                "BadRequestException" => {
815                    return RusotoError::Service(PutSessionError::BadRequest(err.msg))
816                }
817                "ConflictException" => {
818                    return RusotoError::Service(PutSessionError::Conflict(err.msg))
819                }
820                "DependencyFailedException" => {
821                    return RusotoError::Service(PutSessionError::DependencyFailed(err.msg))
822                }
823                "InternalFailureException" => {
824                    return RusotoError::Service(PutSessionError::InternalFailure(err.msg))
825                }
826                "LimitExceededException" => {
827                    return RusotoError::Service(PutSessionError::LimitExceeded(err.msg))
828                }
829                "NotAcceptableException" => {
830                    return RusotoError::Service(PutSessionError::NotAcceptable(err.msg))
831                }
832                "NotFoundException" => {
833                    return RusotoError::Service(PutSessionError::NotFound(err.msg))
834                }
835                "ValidationException" => return RusotoError::Validation(err.msg),
836                _ => {}
837            }
838        }
839        RusotoError::Unknown(res)
840    }
841}
842impl fmt::Display for PutSessionError {
843    #[allow(unused_variables)]
844    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
845        match *self {
846            PutSessionError::BadGateway(ref cause) => write!(f, "{}", cause),
847            PutSessionError::BadRequest(ref cause) => write!(f, "{}", cause),
848            PutSessionError::Conflict(ref cause) => write!(f, "{}", cause),
849            PutSessionError::DependencyFailed(ref cause) => write!(f, "{}", cause),
850            PutSessionError::InternalFailure(ref cause) => write!(f, "{}", cause),
851            PutSessionError::LimitExceeded(ref cause) => write!(f, "{}", cause),
852            PutSessionError::NotAcceptable(ref cause) => write!(f, "{}", cause),
853            PutSessionError::NotFound(ref cause) => write!(f, "{}", cause),
854        }
855    }
856}
857impl Error for PutSessionError {}
858/// Trait representing the capabilities of the Amazon Lex Runtime Service API. Amazon Lex Runtime Service clients implement this trait.
859#[async_trait]
860pub trait LexRuntime {
861    /// <p>Removes session information for a specified bot, alias, and user ID. </p>
862    async fn delete_session(
863        &self,
864        input: DeleteSessionRequest,
865    ) -> Result<DeleteSessionResponse, RusotoError<DeleteSessionError>>;
866
867    /// <p>Returns session information for a specified bot, alias, and user ID.</p>
868    async fn get_session(
869        &self,
870        input: GetSessionRequest,
871    ) -> Result<GetSessionResponse, RusotoError<GetSessionError>>;
872
873    /// <p> Sends user input (text or speech) to Amazon Lex. Clients use this API to send text and audio requests to Amazon Lex at runtime. Amazon Lex interprets the user input using the machine learning model that it built for the bot. </p> <p>The <code>PostContent</code> operation supports audio input at 8kHz and 16kHz. You can use 8kHz audio to achieve higher speech recognition accuracy in telephone audio applications. </p> <p> In response, Amazon Lex returns the next message to convey to the user. Consider the following example messages: </p> <ul> <li> <p> For a user input "I would like a pizza," Amazon Lex might return a response with a message eliciting slot data (for example, <code>PizzaSize</code>): "What size pizza would you like?". </p> </li> <li> <p> After the user provides all of the pizza order information, Amazon Lex might return a response with a message to get user confirmation: "Order the pizza?". </p> </li> <li> <p> After the user replies "Yes" to the confirmation prompt, Amazon Lex might return a conclusion statement: "Thank you, your cheese pizza has been ordered.". </p> </li> </ul> <p> Not all Amazon Lex messages require a response from the user. For example, conclusion statements do not require a response. Some messages require only a yes or no response. In addition to the <code>message</code>, Amazon Lex provides additional context about the message in the response that you can use to enhance client behavior, such as displaying the appropriate client user interface. Consider the following examples: </p> <ul> <li> <p> If the message is to elicit slot data, Amazon Lex returns the following context information: </p> <ul> <li> <p> <code>x-amz-lex-dialog-state</code> header set to <code>ElicitSlot</code> </p> </li> <li> <p> <code>x-amz-lex-intent-name</code> header set to the intent name in the current context </p> </li> <li> <p> <code>x-amz-lex-slot-to-elicit</code> header set to the slot name for which the <code>message</code> is eliciting information </p> </li> <li> <p> <code>x-amz-lex-slots</code> header set to a map of slots configured for the intent with their current values </p> </li> </ul> </li> <li> <p> If the message is a confirmation prompt, the <code>x-amz-lex-dialog-state</code> header is set to <code>Confirmation</code> and the <code>x-amz-lex-slot-to-elicit</code> header is omitted. </p> </li> <li> <p> If the message is a clarification prompt configured for the intent, indicating that the user intent is not understood, the <code>x-amz-dialog-state</code> header is set to <code>ElicitIntent</code> and the <code>x-amz-slot-to-elicit</code> header is omitted. </p> </li> </ul> <p> In addition, Amazon Lex also returns your application-specific <code>sessionAttributes</code>. For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html">Managing Conversation Context</a>. </p>
874    async fn post_content(
875        &self,
876        input: PostContentRequest,
877    ) -> Result<PostContentResponse, RusotoError<PostContentError>>;
878
879    /// <p>Sends user input to Amazon Lex. Client applications can use this API to send requests to Amazon Lex at runtime. Amazon Lex then interprets the user input using the machine learning model it built for the bot. </p> <p> In response, Amazon Lex returns the next <code>message</code> to convey to the user an optional <code>responseCard</code> to display. Consider the following example messages: </p> <ul> <li> <p> For a user input "I would like a pizza", Amazon Lex might return a response with a message eliciting slot data (for example, PizzaSize): "What size pizza would you like?" </p> </li> <li> <p> After the user provides all of the pizza order information, Amazon Lex might return a response with a message to obtain user confirmation "Proceed with the pizza order?". </p> </li> <li> <p> After the user replies to a confirmation prompt with a "yes", Amazon Lex might return a conclusion statement: "Thank you, your cheese pizza has been ordered.". </p> </li> </ul> <p> Not all Amazon Lex messages require a user response. For example, a conclusion statement does not require a response. Some messages require only a "yes" or "no" user response. In addition to the <code>message</code>, Amazon Lex provides additional context about the message in the response that you might use to enhance client behavior, for example, to display the appropriate client user interface. These are the <code>slotToElicit</code>, <code>dialogState</code>, <code>intentName</code>, and <code>slots</code> fields in the response. Consider the following examples: </p> <ul> <li> <p>If the message is to elicit slot data, Amazon Lex returns the following context information:</p> <ul> <li> <p> <code>dialogState</code> set to ElicitSlot </p> </li> <li> <p> <code>intentName</code> set to the intent name in the current context </p> </li> <li> <p> <code>slotToElicit</code> set to the slot name for which the <code>message</code> is eliciting information </p> </li> <li> <p> <code>slots</code> set to a map of slots, configured for the intent, with currently known values </p> </li> </ul> </li> <li> <p> If the message is a confirmation prompt, the <code>dialogState</code> is set to ConfirmIntent and <code>SlotToElicit</code> is set to null. </p> </li> <li> <p>If the message is a clarification prompt (configured for the intent) that indicates that user intent is not understood, the <code>dialogState</code> is set to ElicitIntent and <code>slotToElicit</code> is set to null. </p> </li> </ul> <p> In addition, Amazon Lex also returns your application-specific <code>sessionAttributes</code>. For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html">Managing Conversation Context</a>. </p>
880    async fn post_text(
881        &self,
882        input: PostTextRequest,
883    ) -> Result<PostTextResponse, RusotoError<PostTextError>>;
884
885    /// <p>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.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/how-session-api.html">Managing Sessions</a>.</p>
886    async fn put_session(
887        &self,
888        input: PutSessionRequest,
889    ) -> Result<PutSessionResponse, RusotoError<PutSessionError>>;
890}
891/// A client for the Amazon Lex Runtime Service API.
892#[derive(Clone)]
893pub struct LexRuntimeClient {
894    client: Client,
895    region: region::Region,
896}
897
898impl LexRuntimeClient {
899    /// Creates a client backed by the default tokio event loop.
900    ///
901    /// The client will use the default credentials provider and tls client.
902    pub fn new(region: region::Region) -> LexRuntimeClient {
903        LexRuntimeClient {
904            client: Client::shared(),
905            region,
906        }
907    }
908
909    pub fn new_with<P, D>(
910        request_dispatcher: D,
911        credentials_provider: P,
912        region: region::Region,
913    ) -> LexRuntimeClient
914    where
915        P: ProvideAwsCredentials + Send + Sync + 'static,
916        D: DispatchSignedRequest + Send + Sync + 'static,
917    {
918        LexRuntimeClient {
919            client: Client::new_with(credentials_provider, request_dispatcher),
920            region,
921        }
922    }
923
924    pub fn new_with_client(client: Client, region: region::Region) -> LexRuntimeClient {
925        LexRuntimeClient { client, region }
926    }
927}
928
929#[async_trait]
930impl LexRuntime for LexRuntimeClient {
931    /// <p>Removes session information for a specified bot, alias, and user ID. </p>
932    #[allow(unused_mut)]
933    async fn delete_session(
934        &self,
935        input: DeleteSessionRequest,
936    ) -> Result<DeleteSessionResponse, RusotoError<DeleteSessionError>> {
937        let request_uri = format!(
938            "/bot/{bot_name}/alias/{bot_alias}/user/{user_id}/session",
939            bot_alias = input.bot_alias,
940            bot_name = input.bot_name,
941            user_id = input.user_id
942        );
943
944        let mut request = SignedRequest::new("DELETE", "lex", &self.region, &request_uri);
945        request.set_content_type("application/x-amz-json-1.1".to_owned());
946
947        request.set_endpoint_prefix("runtime.lex".to_string());
948
949        let mut response = self
950            .client
951            .sign_and_dispatch(request)
952            .await
953            .map_err(RusotoError::from)?;
954        if response.status.is_success() {
955            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
956            let result = proto::json::ResponsePayload::new(&response)
957                .deserialize::<DeleteSessionResponse, _>()?;
958
959            Ok(result)
960        } else {
961            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
962            Err(DeleteSessionError::from_response(response))
963        }
964    }
965
966    /// <p>Returns session information for a specified bot, alias, and user ID.</p>
967    #[allow(unused_mut)]
968    async fn get_session(
969        &self,
970        input: GetSessionRequest,
971    ) -> Result<GetSessionResponse, RusotoError<GetSessionError>> {
972        let request_uri = format!(
973            "/bot/{bot_name}/alias/{bot_alias}/user/{user_id}/session/",
974            bot_alias = input.bot_alias,
975            bot_name = input.bot_name,
976            user_id = input.user_id
977        );
978
979        let mut request = SignedRequest::new("GET", "lex", &self.region, &request_uri);
980        request.set_content_type("application/x-amz-json-1.1".to_owned());
981
982        request.set_endpoint_prefix("runtime.lex".to_string());
983
984        let mut params = Params::new();
985        if let Some(ref x) = input.checkpoint_label_filter {
986            params.put("checkpointLabelFilter", x);
987        }
988        request.set_params(params);
989
990        let mut response = self
991            .client
992            .sign_and_dispatch(request)
993            .await
994            .map_err(RusotoError::from)?;
995        if response.status.is_success() {
996            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
997            let result = proto::json::ResponsePayload::new(&response)
998                .deserialize::<GetSessionResponse, _>()?;
999
1000            Ok(result)
1001        } else {
1002            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
1003            Err(GetSessionError::from_response(response))
1004        }
1005    }
1006
1007    /// <p> Sends user input (text or speech) to Amazon Lex. Clients use this API to send text and audio requests to Amazon Lex at runtime. Amazon Lex interprets the user input using the machine learning model that it built for the bot. </p> <p>The <code>PostContent</code> operation supports audio input at 8kHz and 16kHz. You can use 8kHz audio to achieve higher speech recognition accuracy in telephone audio applications. </p> <p> In response, Amazon Lex returns the next message to convey to the user. Consider the following example messages: </p> <ul> <li> <p> For a user input "I would like a pizza," Amazon Lex might return a response with a message eliciting slot data (for example, <code>PizzaSize</code>): "What size pizza would you like?". </p> </li> <li> <p> After the user provides all of the pizza order information, Amazon Lex might return a response with a message to get user confirmation: "Order the pizza?". </p> </li> <li> <p> After the user replies "Yes" to the confirmation prompt, Amazon Lex might return a conclusion statement: "Thank you, your cheese pizza has been ordered.". </p> </li> </ul> <p> Not all Amazon Lex messages require a response from the user. For example, conclusion statements do not require a response. Some messages require only a yes or no response. In addition to the <code>message</code>, Amazon Lex provides additional context about the message in the response that you can use to enhance client behavior, such as displaying the appropriate client user interface. Consider the following examples: </p> <ul> <li> <p> If the message is to elicit slot data, Amazon Lex returns the following context information: </p> <ul> <li> <p> <code>x-amz-lex-dialog-state</code> header set to <code>ElicitSlot</code> </p> </li> <li> <p> <code>x-amz-lex-intent-name</code> header set to the intent name in the current context </p> </li> <li> <p> <code>x-amz-lex-slot-to-elicit</code> header set to the slot name for which the <code>message</code> is eliciting information </p> </li> <li> <p> <code>x-amz-lex-slots</code> header set to a map of slots configured for the intent with their current values </p> </li> </ul> </li> <li> <p> If the message is a confirmation prompt, the <code>x-amz-lex-dialog-state</code> header is set to <code>Confirmation</code> and the <code>x-amz-lex-slot-to-elicit</code> header is omitted. </p> </li> <li> <p> If the message is a clarification prompt configured for the intent, indicating that the user intent is not understood, the <code>x-amz-dialog-state</code> header is set to <code>ElicitIntent</code> and the <code>x-amz-slot-to-elicit</code> header is omitted. </p> </li> </ul> <p> In addition, Amazon Lex also returns your application-specific <code>sessionAttributes</code>. For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html">Managing Conversation Context</a>. </p>
1008    #[allow(unused_mut)]
1009    async fn post_content(
1010        &self,
1011        input: PostContentRequest,
1012    ) -> Result<PostContentResponse, RusotoError<PostContentError>> {
1013        let request_uri = format!(
1014            "/bot/{bot_name}/alias/{bot_alias}/user/{user_id}/content",
1015            bot_alias = input.bot_alias,
1016            bot_name = input.bot_name,
1017            user_id = input.user_id
1018        );
1019
1020        let mut request = SignedRequest::new("POST", "lex", &self.region, &request_uri);
1021        request.set_content_type("application/x-amz-json-1.1".to_owned());
1022
1023        request.set_endpoint_prefix("runtime.lex".to_string());
1024        let encoded = Some(input.input_stream.to_owned());
1025        request.set_payload(encoded);
1026        request.add_optional_header("Accept", input.accept.as_ref());
1027        request.add_optional_header("x-amz-lex-active-contexts", input.active_contexts.as_ref());
1028        request.add_header("Content-Type", &input.content_type.to_string());
1029        request.add_optional_header(
1030            "x-amz-lex-request-attributes",
1031            input.request_attributes.as_ref(),
1032        );
1033        request.add_optional_header(
1034            "x-amz-lex-session-attributes",
1035            input.session_attributes.as_ref(),
1036        );
1037
1038        let mut response = self
1039            .client
1040            .sign_and_dispatch(request)
1041            .await
1042            .map_err(RusotoError::from)?;
1043        if response.status.is_success() {
1044            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
1045
1046            let mut result = PostContentResponse::default();
1047            result.audio_stream = Some(response.body);
1048
1049            result.active_contexts = response.headers.remove("x-amz-lex-active-contexts");
1050            result.alternative_intents = response.headers.remove("x-amz-lex-alternative-intents");
1051            result.bot_version = response.headers.remove("x-amz-lex-bot-version");
1052            result.content_type = response.headers.remove("Content-Type");
1053            result.dialog_state = response.headers.remove("x-amz-lex-dialog-state");
1054            result.encoded_input_transcript = response
1055                .headers
1056                .remove("x-amz-lex-encoded-input-transcript");
1057            result.encoded_message = response.headers.remove("x-amz-lex-encoded-message");
1058            result.intent_name = response.headers.remove("x-amz-lex-intent-name");
1059            result.message_format = response.headers.remove("x-amz-lex-message-format");
1060            result.nlu_intent_confidence =
1061                response.headers.remove("x-amz-lex-nlu-intent-confidence");
1062            result.sentiment_response = response.headers.remove("x-amz-lex-sentiment");
1063            result.session_attributes = response.headers.remove("x-amz-lex-session-attributes");
1064            result.session_id = response.headers.remove("x-amz-lex-session-id");
1065            result.slot_to_elicit = response.headers.remove("x-amz-lex-slot-to-elicit");
1066            result.slots = response.headers.remove("x-amz-lex-slots");
1067
1068            Ok(result)
1069        } else {
1070            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
1071            Err(PostContentError::from_response(response))
1072        }
1073    }
1074
1075    /// <p>Sends user input to Amazon Lex. Client applications can use this API to send requests to Amazon Lex at runtime. Amazon Lex then interprets the user input using the machine learning model it built for the bot. </p> <p> In response, Amazon Lex returns the next <code>message</code> to convey to the user an optional <code>responseCard</code> to display. Consider the following example messages: </p> <ul> <li> <p> For a user input "I would like a pizza", Amazon Lex might return a response with a message eliciting slot data (for example, PizzaSize): "What size pizza would you like?" </p> </li> <li> <p> After the user provides all of the pizza order information, Amazon Lex might return a response with a message to obtain user confirmation "Proceed with the pizza order?". </p> </li> <li> <p> After the user replies to a confirmation prompt with a "yes", Amazon Lex might return a conclusion statement: "Thank you, your cheese pizza has been ordered.". </p> </li> </ul> <p> Not all Amazon Lex messages require a user response. For example, a conclusion statement does not require a response. Some messages require only a "yes" or "no" user response. In addition to the <code>message</code>, Amazon Lex provides additional context about the message in the response that you might use to enhance client behavior, for example, to display the appropriate client user interface. These are the <code>slotToElicit</code>, <code>dialogState</code>, <code>intentName</code>, and <code>slots</code> fields in the response. Consider the following examples: </p> <ul> <li> <p>If the message is to elicit slot data, Amazon Lex returns the following context information:</p> <ul> <li> <p> <code>dialogState</code> set to ElicitSlot </p> </li> <li> <p> <code>intentName</code> set to the intent name in the current context </p> </li> <li> <p> <code>slotToElicit</code> set to the slot name for which the <code>message</code> is eliciting information </p> </li> <li> <p> <code>slots</code> set to a map of slots, configured for the intent, with currently known values </p> </li> </ul> </li> <li> <p> If the message is a confirmation prompt, the <code>dialogState</code> is set to ConfirmIntent and <code>SlotToElicit</code> is set to null. </p> </li> <li> <p>If the message is a clarification prompt (configured for the intent) that indicates that user intent is not understood, the <code>dialogState</code> is set to ElicitIntent and <code>slotToElicit</code> is set to null. </p> </li> </ul> <p> In addition, Amazon Lex also returns your application-specific <code>sessionAttributes</code>. For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html">Managing Conversation Context</a>. </p>
1076    #[allow(unused_mut)]
1077    async fn post_text(
1078        &self,
1079        input: PostTextRequest,
1080    ) -> Result<PostTextResponse, RusotoError<PostTextError>> {
1081        let request_uri = format!(
1082            "/bot/{bot_name}/alias/{bot_alias}/user/{user_id}/text",
1083            bot_alias = input.bot_alias,
1084            bot_name = input.bot_name,
1085            user_id = input.user_id
1086        );
1087
1088        let mut request = SignedRequest::new("POST", "lex", &self.region, &request_uri);
1089        request.set_content_type("application/x-amz-json-1.1".to_owned());
1090
1091        request.set_endpoint_prefix("runtime.lex".to_string());
1092        let encoded = Some(serde_json::to_vec(&input).unwrap());
1093        request.set_payload(encoded);
1094
1095        let mut response = self
1096            .client
1097            .sign_and_dispatch(request)
1098            .await
1099            .map_err(RusotoError::from)?;
1100        if response.status.is_success() {
1101            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
1102            let result = proto::json::ResponsePayload::new(&response)
1103                .deserialize::<PostTextResponse, _>()?;
1104
1105            Ok(result)
1106        } else {
1107            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
1108            Err(PostTextError::from_response(response))
1109        }
1110    }
1111
1112    /// <p>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.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/how-session-api.html">Managing Sessions</a>.</p>
1113    #[allow(unused_mut)]
1114    async fn put_session(
1115        &self,
1116        input: PutSessionRequest,
1117    ) -> Result<PutSessionResponse, RusotoError<PutSessionError>> {
1118        let request_uri = format!(
1119            "/bot/{bot_name}/alias/{bot_alias}/user/{user_id}/session",
1120            bot_alias = input.bot_alias,
1121            bot_name = input.bot_name,
1122            user_id = input.user_id
1123        );
1124
1125        let mut request = SignedRequest::new("POST", "lex", &self.region, &request_uri);
1126        request.set_content_type("application/x-amz-json-1.1".to_owned());
1127
1128        request.set_endpoint_prefix("runtime.lex".to_string());
1129        let encoded = Some(serde_json::to_vec(&input).unwrap());
1130        request.set_payload(encoded);
1131        request.add_optional_header("Accept", input.accept.as_ref());
1132
1133        let mut response = self
1134            .client
1135            .sign_and_dispatch(request)
1136            .await
1137            .map_err(RusotoError::from)?;
1138        if response.status.is_success() {
1139            let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
1140
1141            let mut result = PutSessionResponse::default();
1142            result.audio_stream = Some(response.body);
1143
1144            result.active_contexts = response.headers.remove("x-amz-lex-active-contexts");
1145            result.content_type = response.headers.remove("Content-Type");
1146            result.dialog_state = response.headers.remove("x-amz-lex-dialog-state");
1147            result.encoded_message = response.headers.remove("x-amz-lex-encoded-message");
1148            result.intent_name = response.headers.remove("x-amz-lex-intent-name");
1149            result.message_format = response.headers.remove("x-amz-lex-message-format");
1150            result.session_attributes = response.headers.remove("x-amz-lex-session-attributes");
1151            result.session_id = response.headers.remove("x-amz-lex-session-id");
1152            result.slot_to_elicit = response.headers.remove("x-amz-lex-slot-to-elicit");
1153            result.slots = response.headers.remove("x-amz-lex-slots");
1154
1155            Ok(result)
1156        } else {
1157            let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
1158            Err(PutSessionError::from_response(response))
1159        }
1160    }
1161}