aws-sdk-lex 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/aws-sdk-lex.rb +47 -0
- data/lib/aws-sdk-lex/client.rb +616 -0
- data/lib/aws-sdk-lex/client_api.rb +168 -0
- data/lib/aws-sdk-lex/customizations.rb +0 -0
- data/lib/aws-sdk-lex/errors.rb +14 -0
- data/lib/aws-sdk-lex/resource.rb +23 -0
- data/lib/aws-sdk-lex/types.rb +595 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f97141e02f988f9736fa80472724129efa8e7c30
|
4
|
+
data.tar.gz: 90c20cf062e717a5412719b32b8f86c92a5a700d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 57ef98502ad0b4fb45d2b3bc41f8c55ee2548ca3ec43f40ea5f679b011895fc362f97cabe2658fdb21f04857752dded2ec7a4b47c6c01364d462bb4a671a5d0c
|
7
|
+
data.tar.gz: 27dabf724115f92e81981ee7fb8a8072892c072ffc574384cfe9b3f84831264459301a8c94ac138d6029ef24de980a8a80fed369a704caed0462d7b0a8d51fc5
|
data/lib/aws-sdk-lex.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing guide for more information:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
require 'aws-sdk-core'
|
9
|
+
require 'aws-sigv4'
|
10
|
+
|
11
|
+
require_relative 'aws-sdk-lex/types'
|
12
|
+
require_relative 'aws-sdk-lex/client_api'
|
13
|
+
require_relative 'aws-sdk-lex/client'
|
14
|
+
require_relative 'aws-sdk-lex/errors'
|
15
|
+
require_relative 'aws-sdk-lex/resource'
|
16
|
+
require_relative 'aws-sdk-lex/customizations'
|
17
|
+
|
18
|
+
# This module provides support for Amazon Lex Runtime Service. This module is available in the
|
19
|
+
# `aws-sdk-lex` gem.
|
20
|
+
#
|
21
|
+
# # Client
|
22
|
+
#
|
23
|
+
# The {Client} class provides one method for each API operation. Operation
|
24
|
+
# methods each accept a hash of request parameters and return a response
|
25
|
+
# structure.
|
26
|
+
#
|
27
|
+
# See {Client} for more information.
|
28
|
+
#
|
29
|
+
# # Errors
|
30
|
+
#
|
31
|
+
# Errors returned from Amazon Lex Runtime Service all
|
32
|
+
# extend {Errors::ServiceError}.
|
33
|
+
#
|
34
|
+
# begin
|
35
|
+
# # do stuff
|
36
|
+
# rescue Aws::Lex::Errors::ServiceError
|
37
|
+
# # rescues all service API errors
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# See {Errors} for more information.
|
41
|
+
#
|
42
|
+
# @service
|
43
|
+
module Aws::Lex
|
44
|
+
|
45
|
+
GEM_VERSION = '1.0.0.rc1'
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,616 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing guide for more information:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
require 'seahorse/client/plugins/content_length.rb'
|
9
|
+
require 'aws-sdk-core/plugins/credentials_configuration.rb'
|
10
|
+
require 'aws-sdk-core/plugins/logging.rb'
|
11
|
+
require 'aws-sdk-core/plugins/param_converter.rb'
|
12
|
+
require 'aws-sdk-core/plugins/param_validator.rb'
|
13
|
+
require 'aws-sdk-core/plugins/user_agent.rb'
|
14
|
+
require 'aws-sdk-core/plugins/helpful_socket_errors.rb'
|
15
|
+
require 'aws-sdk-core/plugins/retry_errors.rb'
|
16
|
+
require 'aws-sdk-core/plugins/global_configuration.rb'
|
17
|
+
require 'aws-sdk-core/plugins/regional_endpoint.rb'
|
18
|
+
require 'aws-sdk-core/plugins/response_paging.rb'
|
19
|
+
require 'aws-sdk-core/plugins/stub_responses.rb'
|
20
|
+
require 'aws-sdk-core/plugins/idempotency_token.rb'
|
21
|
+
require 'aws-sdk-core/plugins/jsonvalue_converter.rb'
|
22
|
+
require 'aws-sdk-core/plugins/signature_v4.rb'
|
23
|
+
require 'aws-sdk-core/plugins/protocols/rest_json.rb'
|
24
|
+
|
25
|
+
Aws::Plugins::GlobalConfiguration.add_identifier(:lex)
|
26
|
+
|
27
|
+
module Aws::Lex
|
28
|
+
class Client < Seahorse::Client::Base
|
29
|
+
|
30
|
+
include Aws::ClientStubs
|
31
|
+
|
32
|
+
@identifier = :lex
|
33
|
+
|
34
|
+
set_api(ClientApi::API)
|
35
|
+
|
36
|
+
add_plugin(Seahorse::Client::Plugins::ContentLength)
|
37
|
+
add_plugin(Aws::Plugins::CredentialsConfiguration)
|
38
|
+
add_plugin(Aws::Plugins::Logging)
|
39
|
+
add_plugin(Aws::Plugins::ParamConverter)
|
40
|
+
add_plugin(Aws::Plugins::ParamValidator)
|
41
|
+
add_plugin(Aws::Plugins::UserAgent)
|
42
|
+
add_plugin(Aws::Plugins::HelpfulSocketErrors)
|
43
|
+
add_plugin(Aws::Plugins::RetryErrors)
|
44
|
+
add_plugin(Aws::Plugins::GlobalConfiguration)
|
45
|
+
add_plugin(Aws::Plugins::RegionalEndpoint)
|
46
|
+
add_plugin(Aws::Plugins::ResponsePaging)
|
47
|
+
add_plugin(Aws::Plugins::StubResponses)
|
48
|
+
add_plugin(Aws::Plugins::IdempotencyToken)
|
49
|
+
add_plugin(Aws::Plugins::JsonvalueConverter)
|
50
|
+
add_plugin(Aws::Plugins::SignatureV4)
|
51
|
+
add_plugin(Aws::Plugins::Protocols::RestJson)
|
52
|
+
|
53
|
+
# @option options [required, Aws::CredentialProvider] :credentials
|
54
|
+
# Your AWS credentials. This can be an instance of any one of the
|
55
|
+
# following classes:
|
56
|
+
#
|
57
|
+
# * `Aws::Credentials` - Used for configuring static, non-refreshing
|
58
|
+
# credentials.
|
59
|
+
#
|
60
|
+
# * `Aws::InstanceProfileCredentials` - Used for loading credentials
|
61
|
+
# from an EC2 IMDS on an EC2 instance.
|
62
|
+
#
|
63
|
+
# * `Aws::SharedCredentials` - Used for loading credentials from a
|
64
|
+
# shared file, such as `~/.aws/config`.
|
65
|
+
#
|
66
|
+
# * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
|
67
|
+
#
|
68
|
+
# When `:credentials` are not configured directly, the following
|
69
|
+
# locations will be searched for credentials:
|
70
|
+
#
|
71
|
+
# * `Aws.config[:credentials]`
|
72
|
+
# * The `:access_key_id`, `:secret_access_key`, and `:session_token` options.
|
73
|
+
# * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
|
74
|
+
# * `~/.aws/credentials`
|
75
|
+
# * `~/.aws/config`
|
76
|
+
# * EC2 IMDS instance profile - When used by default, the timeouts are
|
77
|
+
# very aggressive. Construct and pass an instance of
|
78
|
+
# `Aws::InstanceProfileCredentails` to enable retries and extended
|
79
|
+
# timeouts.
|
80
|
+
#
|
81
|
+
# @option options [required, String] :region
|
82
|
+
# The AWS region to connect to. The configured `:region` is
|
83
|
+
# used to determine the service `:endpoint`. When not passed,
|
84
|
+
# a default `:region` is search for in the following locations:
|
85
|
+
#
|
86
|
+
# * `Aws.config[:region]`
|
87
|
+
# * `ENV['AWS_REGION']`
|
88
|
+
# * `ENV['AMAZON_REGION']`
|
89
|
+
# * `ENV['AWS_DEFAULT_REGION']`
|
90
|
+
# * `~/.aws/credentials`
|
91
|
+
# * `~/.aws/config`
|
92
|
+
#
|
93
|
+
# @option options [String] :access_key_id
|
94
|
+
#
|
95
|
+
# @option options [Boolean] :convert_params (true)
|
96
|
+
# When `true`, an attempt is made to coerce request parameters into
|
97
|
+
# the required types.
|
98
|
+
#
|
99
|
+
# @option options [String] :endpoint
|
100
|
+
# The client endpoint is normally constructed from the `:region`
|
101
|
+
# option. You should only configure an `:endpoint` when connecting
|
102
|
+
# to test endpoints. This should be avalid HTTP(S) URI.
|
103
|
+
#
|
104
|
+
# @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
|
105
|
+
# The log formatter.
|
106
|
+
#
|
107
|
+
# @option options [Symbol] :log_level (:info)
|
108
|
+
# The log level to send messages to the `:logger` at.
|
109
|
+
#
|
110
|
+
# @option options [Logger] :logger
|
111
|
+
# The Logger instance to send log messages to. If this option
|
112
|
+
# is not set, logging will be disabled.
|
113
|
+
#
|
114
|
+
# @option options [String] :profile ("default")
|
115
|
+
# Used when loading credentials from the shared credentials file
|
116
|
+
# at HOME/.aws/credentials. When not specified, 'default' is used.
|
117
|
+
#
|
118
|
+
# @option options [Integer] :retry_limit (3)
|
119
|
+
# The maximum number of times to retry failed requests. Only
|
120
|
+
# ~ 500 level server errors and certain ~ 400 level client errors
|
121
|
+
# are retried. Generally, these are throttling errors, data
|
122
|
+
# checksum errors, networking errors, timeout errors and auth
|
123
|
+
# errors from expired credentials.
|
124
|
+
#
|
125
|
+
# @option options [String] :secret_access_key
|
126
|
+
#
|
127
|
+
# @option options [String] :session_token
|
128
|
+
#
|
129
|
+
# @option options [Boolean] :stub_responses (false)
|
130
|
+
# Causes the client to return stubbed responses. By default
|
131
|
+
# fake responses are generated and returned. You can specify
|
132
|
+
# the response data to return or errors to raise by calling
|
133
|
+
# {ClientStubs#stub_responses}. See {ClientStubs} for more information.
|
134
|
+
#
|
135
|
+
# ** Please note ** When response stubbing is enabled, no HTTP
|
136
|
+
# requests are made, and retries are disabled.
|
137
|
+
#
|
138
|
+
# @option options [Boolean] :validate_params (true)
|
139
|
+
# When `true`, request parameters are validated before
|
140
|
+
# sending the request.
|
141
|
+
#
|
142
|
+
def initialize(*args)
|
143
|
+
super
|
144
|
+
end
|
145
|
+
|
146
|
+
# @!group API Operations
|
147
|
+
|
148
|
+
# Sends user input (text or speech) to Amazon Lex. Clients use this API
|
149
|
+
# to send requests to Amazon Lex at runtime. Amazon Lex interprets the
|
150
|
+
# user input using the machine learning model that it built for the bot.
|
151
|
+
#
|
152
|
+
# In response, Amazon Lex returns the next message to convey to the
|
153
|
+
# user. Consider the following example messages:
|
154
|
+
#
|
155
|
+
# * For a user input "I would like a pizza," Amazon Lex might return a
|
156
|
+
# response with a message eliciting slot data (for example,
|
157
|
+
# `PizzaSize`): "What size pizza would you like?".
|
158
|
+
#
|
159
|
+
# * After the user provides all of the pizza order information, Amazon
|
160
|
+
# Lex might return a response with a message to get user confirmation:
|
161
|
+
# "Order the pizza?".
|
162
|
+
#
|
163
|
+
# * After the user replies "Yes" to the confirmation prompt, Amazon
|
164
|
+
# Lex might return a conclusion statement: "Thank you, your cheese
|
165
|
+
# pizza has been ordered.".
|
166
|
+
#
|
167
|
+
# Not all Amazon Lex messages require a response from the user. For
|
168
|
+
# example, conclusion statements do not require a response. Some
|
169
|
+
# messages require only a yes or no response. In addition to the
|
170
|
+
# `message`, Amazon Lex provides additional context about the message in
|
171
|
+
# the response that you can use to enhance client behavior, such as
|
172
|
+
# displaying the appropriate client user interface. Consider the
|
173
|
+
# following examples:
|
174
|
+
#
|
175
|
+
# * If the message is to elicit slot data, Amazon Lex returns the
|
176
|
+
# following context information:
|
177
|
+
#
|
178
|
+
# * `x-amz-lex-dialog-state` header set to `ElicitSlot`
|
179
|
+
#
|
180
|
+
# * `x-amz-lex-intent-name` header set to the intent name in the
|
181
|
+
# current context
|
182
|
+
#
|
183
|
+
# * `x-amz-lex-slot-to-elicit` header set to the slot name for which
|
184
|
+
# the `message` is eliciting information
|
185
|
+
#
|
186
|
+
# * `x-amz-lex-slots` header set to a map of slots configured for the
|
187
|
+
# intent with their current values
|
188
|
+
#
|
189
|
+
# * If the message is a confirmation prompt, the
|
190
|
+
# `x-amz-lex-dialog-state` header is set to `Confirmation` and the
|
191
|
+
# `x-amz-lex-slot-to-elicit` header is omitted.
|
192
|
+
#
|
193
|
+
# * If the message is a clarification prompt configured for the intent,
|
194
|
+
# indicating that the user intent is not understood, the
|
195
|
+
# `x-amz-dialog-state` header is set to `ElicitIntent` and the
|
196
|
+
# `x-amz-slot-to-elicit` header is omitted.
|
197
|
+
#
|
198
|
+
# In addition, Amazon Lex also returns your application-specific
|
199
|
+
# `sessionAttributes`. For more information, see [Managing Conversation
|
200
|
+
# Context][1].
|
201
|
+
#
|
202
|
+
#
|
203
|
+
#
|
204
|
+
# [1]: http://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html
|
205
|
+
#
|
206
|
+
# @option params [required, String] :bot_name
|
207
|
+
# Name of the Amazon Lex bot.
|
208
|
+
#
|
209
|
+
# @option params [required, String] :bot_alias
|
210
|
+
# Alias of the Amazon Lex bot.
|
211
|
+
#
|
212
|
+
# @option params [required, String] :user_id
|
213
|
+
# ID of the client application user. Typically, each of your application
|
214
|
+
# users should have a unique ID. The application developer decides the
|
215
|
+
# user IDs. At runtime, each request must include the user ID. Note the
|
216
|
+
# following considerations:
|
217
|
+
#
|
218
|
+
# * If you want a user to start conversation on one device and continue
|
219
|
+
# the conversation on another device, you might choose a user-specific
|
220
|
+
# identifier, such as the user's login, or Amazon Cognito user ID
|
221
|
+
# (assuming your application is using Amazon Cognito).
|
222
|
+
#
|
223
|
+
# * If you want the same user to be able to have two independent
|
224
|
+
# conversations on two different devices, you might choose
|
225
|
+
# device-specific identifier, such as device ID, or some globally
|
226
|
+
# unique identifier.
|
227
|
+
#
|
228
|
+
# @option params [String] :session_attributes
|
229
|
+
# You pass this value in the `x-amz-lex-session-attributes` HTTP header.
|
230
|
+
# The value must be map (keys and values must be strings) that is JSON
|
231
|
+
# serialized and then base64 encoded.
|
232
|
+
#
|
233
|
+
# A session represents dialog between a user and Amazon Lex. At runtime,
|
234
|
+
# a client application can pass contextual information, in the request
|
235
|
+
# to Amazon Lex. For example,
|
236
|
+
#
|
237
|
+
# * You might use session attributes to track the requestID of user
|
238
|
+
# requests.
|
239
|
+
#
|
240
|
+
# * In Getting Started Exercise 1, the example bot uses the price
|
241
|
+
# session attribute to maintain the price of flowers ordered (for
|
242
|
+
# example, "price":25). The code hook (Lambda function) sets this
|
243
|
+
# attribute based on the type of flowers ordered. For more
|
244
|
+
# information, see [Review the Details of Information Flow][1].
|
245
|
+
#
|
246
|
+
# * In the BookTrip bot exercise, the bot uses the `currentReservation`
|
247
|
+
# session attribute to maintains the slot data during the in-progress
|
248
|
+
# conversation to book a hotel or book a car. For more information,
|
249
|
+
# see [Details of Information Flow][2].
|
250
|
+
#
|
251
|
+
# Amazon Lex passes these session attributes to the Lambda functions
|
252
|
+
# configured for the intent In the your Lambda function, you can use the
|
253
|
+
# session attributes for initialization and customization (prompts).
|
254
|
+
# Some examples are:
|
255
|
+
#
|
256
|
+
# * Initialization - In a pizza ordering bot, if you pass user location
|
257
|
+
# (for example, `"Location : 111 Maple Street"`), then your Lambda
|
258
|
+
# function might use this information to determine the closest
|
259
|
+
# pizzeria to place the order (and perhaps set the storeAddress slot
|
260
|
+
# value as well).
|
261
|
+
#
|
262
|
+
# Personalized prompts - For example, you can configure prompts to
|
263
|
+
# refer to the user by name (for example, "Hey \[firstName\], what
|
264
|
+
# toppings would you like?"). You can pass the user's name as a
|
265
|
+
# session attribute ("firstName": "Joe") so that Amazon Lex can
|
266
|
+
# substitute the placeholder to provide a personalized prompt to the
|
267
|
+
# user ("Hey Joe, what toppings would you like?").
|
268
|
+
#
|
269
|
+
# <note markdown="1"> Amazon Lex does not persist session attributes.
|
270
|
+
#
|
271
|
+
# If you configured a code hook for the intent, Amazon Lex passes the
|
272
|
+
# incoming session attributes to the Lambda function. The Lambda
|
273
|
+
# function must return these session attributes if you want Amazon Lex
|
274
|
+
# to return them to the client.
|
275
|
+
#
|
276
|
+
# If there is no code hook configured for the intent Amazon Lex simply
|
277
|
+
# returns the session attributes to the client application.
|
278
|
+
#
|
279
|
+
# </note>
|
280
|
+
#
|
281
|
+
# **SDK automatically handles json encoding and base64 encoding for you
|
282
|
+
# when the required value (Hash, Array, etc.) is provided according to
|
283
|
+
# the description.**
|
284
|
+
#
|
285
|
+
#
|
286
|
+
#
|
287
|
+
# [1]: http://docs.aws.amazon.com/lex/latest/dg/gs-bp-details-after-lambda.html
|
288
|
+
# [2]: http://docs.aws.amazon.com/lex/latest/dg/book-trip-detail-flow.html
|
289
|
+
#
|
290
|
+
# @option params [required, String] :content_type
|
291
|
+
# You pass this values as the `Content-Type` HTTP header.
|
292
|
+
#
|
293
|
+
# Indicates the audio format or text. The header value must start with
|
294
|
+
# one of the following prefixes:
|
295
|
+
#
|
296
|
+
# * PCM format
|
297
|
+
#
|
298
|
+
# * audio/l16; rate=16000; channels=1
|
299
|
+
#
|
300
|
+
# * audio/x-l16; sample-rate=16000; channel-count=1
|
301
|
+
#
|
302
|
+
# * Opus format
|
303
|
+
#
|
304
|
+
# * audio/x-cbr-opus-with-preamble; preamble-size=0; bit-rate=1;
|
305
|
+
# frame-size-milliseconds=1.1
|
306
|
+
#
|
307
|
+
# ^
|
308
|
+
#
|
309
|
+
# * Text format
|
310
|
+
#
|
311
|
+
# * text/plain; charset=utf-8
|
312
|
+
#
|
313
|
+
# ^
|
314
|
+
#
|
315
|
+
# @option params [String] :accept
|
316
|
+
# You pass this value as the `Accept` HTTP header.
|
317
|
+
#
|
318
|
+
# The message Amazon Lex returns in the response can be either text or
|
319
|
+
# speech based on the `Accept` HTTP header value in the request.
|
320
|
+
#
|
321
|
+
# * If the value is `text/plain; charset=utf-8`, Amazon Lex returns text
|
322
|
+
# in the response.
|
323
|
+
#
|
324
|
+
# * If the value begins with `audio/`, Amazon Lex returns speech in the
|
325
|
+
# response. Amazon Lex uses Amazon Polly to generate the speech (using
|
326
|
+
# the configuration you specified in the `Accept` header). For
|
327
|
+
# example, if you specify `audio/mpeg` as the value, Amazon Lex
|
328
|
+
# returns speech in the MPEG format.
|
329
|
+
#
|
330
|
+
# The following are the accepted values:
|
331
|
+
#
|
332
|
+
# * audio/mpeg
|
333
|
+
#
|
334
|
+
# * audio/ogg
|
335
|
+
#
|
336
|
+
# * audio/pcm
|
337
|
+
#
|
338
|
+
# * text/plain; charset=utf-8
|
339
|
+
#
|
340
|
+
# * audio/* (defaults to mpeg)
|
341
|
+
#
|
342
|
+
# @option params [required, String, IO] :input_stream
|
343
|
+
# User input in PCM or Opus audio format or text format as described in
|
344
|
+
# the `Content-Type` HTTP header.
|
345
|
+
#
|
346
|
+
# @return [Types::PostContentResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
|
347
|
+
#
|
348
|
+
# * {Types::PostContentResponse#content_type #content_type} => String
|
349
|
+
# * {Types::PostContentResponse#intent_name #intent_name} => String
|
350
|
+
# * {Types::PostContentResponse#slots #slots} => String
|
351
|
+
# * {Types::PostContentResponse#session_attributes #session_attributes} => String
|
352
|
+
# * {Types::PostContentResponse#message #message} => String
|
353
|
+
# * {Types::PostContentResponse#dialog_state #dialog_state} => String
|
354
|
+
# * {Types::PostContentResponse#slot_to_elicit #slot_to_elicit} => String
|
355
|
+
# * {Types::PostContentResponse#input_transcript #input_transcript} => String
|
356
|
+
# * {Types::PostContentResponse#audio_stream #audio_stream} => IO
|
357
|
+
#
|
358
|
+
# @example Request syntax with placeholder values
|
359
|
+
#
|
360
|
+
# resp = client.post_content({
|
361
|
+
# bot_name: "BotName", # required
|
362
|
+
# bot_alias: "BotAlias", # required
|
363
|
+
# user_id: "UserId", # required
|
364
|
+
# session_attributes: "String",
|
365
|
+
# content_type: "HttpContentType", # required
|
366
|
+
# accept: "Accept",
|
367
|
+
# input_stream: "data", # required
|
368
|
+
# })
|
369
|
+
#
|
370
|
+
# @example Response structure
|
371
|
+
#
|
372
|
+
# resp.content_type #=> String
|
373
|
+
# resp.intent_name #=> String
|
374
|
+
# resp.slots #=> String
|
375
|
+
# resp.session_attributes #=> String
|
376
|
+
# resp.message #=> String
|
377
|
+
# resp.dialog_state #=> String, one of "ElicitIntent", "ConfirmIntent", "ElicitSlot", "Fulfilled", "ReadyForFulfillment", "Failed"
|
378
|
+
# resp.slot_to_elicit #=> String
|
379
|
+
# resp.input_transcript #=> String
|
380
|
+
# resp.audio_stream #=> IO
|
381
|
+
#
|
382
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostContent AWS API Documentation
|
383
|
+
#
|
384
|
+
# @overload post_content(params = {})
|
385
|
+
# @param [Hash] params ({})
|
386
|
+
def post_content(params = {}, options = {})
|
387
|
+
req = build_request(:post_content, params)
|
388
|
+
req.send_request(options)
|
389
|
+
end
|
390
|
+
|
391
|
+
# Sends user input (text-only) to Amazon Lex. Client applications can
|
392
|
+
# use this API to send requests to Amazon Lex at runtime. Amazon Lex
|
393
|
+
# then interprets the user input using the machine learning model it
|
394
|
+
# built for the bot.
|
395
|
+
#
|
396
|
+
# In response, Amazon Lex returns the next `message` to convey to the
|
397
|
+
# user an optional `responseCard` to display. Consider the following
|
398
|
+
# example messages:
|
399
|
+
#
|
400
|
+
# * For a user input "I would like a pizza", Amazon Lex might return a
|
401
|
+
# response with a message eliciting slot data (for example,
|
402
|
+
# PizzaSize): "What size pizza would you like?"
|
403
|
+
#
|
404
|
+
# * After the user provides all of the pizza order information, Amazon
|
405
|
+
# Lex might return a response with a message to obtain user
|
406
|
+
# confirmation "Proceed with the pizza order?".
|
407
|
+
#
|
408
|
+
# * After the user replies to a confirmation prompt with a "yes",
|
409
|
+
# Amazon Lex might return a conclusion statement: "Thank you, your
|
410
|
+
# cheese pizza has been ordered.".
|
411
|
+
#
|
412
|
+
# Not all Amazon Lex messages require a user response. For example, a
|
413
|
+
# conclusion statement does not require a response. Some messages
|
414
|
+
# require only a "yes" or "no" user response. In addition to the
|
415
|
+
# `message`, Amazon Lex provides additional context about the message in
|
416
|
+
# the response that you might use to enhance client behavior, for
|
417
|
+
# example, to display the appropriate client user interface. These are
|
418
|
+
# the `slotToElicit`, `dialogState`, `intentName`, and `slots` fields in
|
419
|
+
# the response. Consider the following examples:
|
420
|
+
#
|
421
|
+
# * If the message is to elicit slot data, Amazon Lex returns the
|
422
|
+
# following context information:
|
423
|
+
#
|
424
|
+
# * `dialogState` set to ElicitSlot
|
425
|
+
#
|
426
|
+
# * `intentName` set to the intent name in the current context
|
427
|
+
#
|
428
|
+
# * `slotToElicit` set to the slot name for which the `message` is
|
429
|
+
# eliciting information
|
430
|
+
#
|
431
|
+
# * `slots` set to a map of slots, configured for the intent, with
|
432
|
+
# currently known values
|
433
|
+
#
|
434
|
+
# * If the message is a confirmation prompt, the `dialogState` is set to
|
435
|
+
# ConfirmIntent and `SlotToElicit` is set to null.
|
436
|
+
#
|
437
|
+
# * If the message is a clarification prompt (configured for the intent)
|
438
|
+
# that indicates that user intent is not understood, the `dialogState`
|
439
|
+
# is set to ElicitIntent and `slotToElicit` is set to null.
|
440
|
+
#
|
441
|
+
# In addition, Amazon Lex also returns your application-specific
|
442
|
+
# `sessionAttributes`. For more information, see [Managing Conversation
|
443
|
+
# Context][1].
|
444
|
+
#
|
445
|
+
#
|
446
|
+
#
|
447
|
+
# [1]: http://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html
|
448
|
+
#
|
449
|
+
# @option params [required, String] :bot_name
|
450
|
+
# The name of the Amazon Lex bot.
|
451
|
+
#
|
452
|
+
# @option params [required, String] :bot_alias
|
453
|
+
# The alias of the Amazon Lex bot.
|
454
|
+
#
|
455
|
+
# @option params [required, String] :user_id
|
456
|
+
# The ID of the client application user. The application developer
|
457
|
+
# decides the user IDs. At runtime, each request must include the user
|
458
|
+
# ID. Typically, each of your application users should have a unique ID.
|
459
|
+
# Note the following considerations:
|
460
|
+
#
|
461
|
+
# * If you want a user to start a conversation on one device and
|
462
|
+
# continue the conversation on another device, you might choose a
|
463
|
+
# user-specific identifier, such as a login or Amazon Cognito user ID
|
464
|
+
# (assuming your application is using Amazon Cognito).
|
465
|
+
#
|
466
|
+
# * If you want the same user to be able to have two independent
|
467
|
+
# conversations on two different devices, you might choose a
|
468
|
+
# device-specific identifier, such as device ID, or some globally
|
469
|
+
# unique identifier.
|
470
|
+
#
|
471
|
+
# @option params [Hash<String,String>] :session_attributes
|
472
|
+
# By using session attributes, a client application can pass contextual
|
473
|
+
# information in the request to Amazon Lex For example,
|
474
|
+
#
|
475
|
+
# * In Getting Started Exercise 1, the example bot uses the `price`
|
476
|
+
# session attribute to maintain the price of the flowers ordered (for
|
477
|
+
# example, "Price":25). The code hook (the Lambda function) sets
|
478
|
+
# this attribute based on the type of flowers ordered. For more
|
479
|
+
# information, see [Review the Details of Information Flow][1].
|
480
|
+
#
|
481
|
+
# * In the BookTrip bot exercise, the bot uses the `currentReservation`
|
482
|
+
# session attribute to maintain slot data during the in-progress
|
483
|
+
# conversation to book a hotel or book a car. For more information,
|
484
|
+
# see [Details of Information Flow][2].
|
485
|
+
#
|
486
|
+
# * You might use the session attributes (key, value pairs) to track the
|
487
|
+
# requestID of user requests.
|
488
|
+
#
|
489
|
+
# Amazon Lex simply passes these session attributes to the Lambda
|
490
|
+
# functions configured for the intent.
|
491
|
+
#
|
492
|
+
# In your Lambda function, you can also use the session attributes for
|
493
|
+
# initialization and customization (prompts and response cards). Some
|
494
|
+
# examples are:
|
495
|
+
#
|
496
|
+
# * Initialization - In a pizza ordering bot, if you can pass the user
|
497
|
+
# location as a session attribute (for example, `"Location" : "111
|
498
|
+
# Maple street"`), then your Lambda function might use this
|
499
|
+
# information to determine the closest pizzeria to place the order
|
500
|
+
# (perhaps to set the storeAddress slot value).
|
501
|
+
#
|
502
|
+
# * Personalize prompts - For example, you can configure prompts to
|
503
|
+
# refer to the user name. (For example, "Hey \[FirstName\], what
|
504
|
+
# toppings would you like?"). You can pass the user name as a session
|
505
|
+
# attribute (`"FirstName" : "Joe"`) so that Amazon Lex can substitute
|
506
|
+
# the placeholder to provide a personalize prompt to the user ("Hey
|
507
|
+
# Joe, what toppings would you like?").
|
508
|
+
#
|
509
|
+
# <note markdown="1"> Amazon Lex does not persist session attributes.
|
510
|
+
#
|
511
|
+
# If you configure a code hook for the intent, Amazon Lex passes the
|
512
|
+
# incoming session attributes to the Lambda function. If you want Amazon
|
513
|
+
# Lex to return these session attributes back to the client, the Lambda
|
514
|
+
# function must return them.
|
515
|
+
#
|
516
|
+
# If there is no code hook configured for the intent, Amazon Lex simply
|
517
|
+
# returns the session attributes back to the client application.
|
518
|
+
#
|
519
|
+
# </note>
|
520
|
+
#
|
521
|
+
#
|
522
|
+
#
|
523
|
+
# [1]: http://docs.aws.amazon.com/lex/latest/dg/gs-bp-details-after-lambda.html
|
524
|
+
# [2]: http://docs.aws.amazon.com/lex/latest/dg/book-trip-detail-flow.html
|
525
|
+
#
|
526
|
+
# @option params [required, String] :input_text
|
527
|
+
# The text that the user entered (Amazon Lex interprets this text).
|
528
|
+
#
|
529
|
+
# @return [Types::PostTextResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
|
530
|
+
#
|
531
|
+
# * {Types::PostTextResponse#intent_name #intent_name} => String
|
532
|
+
# * {Types::PostTextResponse#slots #slots} => Hash<String,String>
|
533
|
+
# * {Types::PostTextResponse#session_attributes #session_attributes} => Hash<String,String>
|
534
|
+
# * {Types::PostTextResponse#message #message} => String
|
535
|
+
# * {Types::PostTextResponse#dialog_state #dialog_state} => String
|
536
|
+
# * {Types::PostTextResponse#slot_to_elicit #slot_to_elicit} => String
|
537
|
+
# * {Types::PostTextResponse#response_card #response_card} => Types::ResponseCard
|
538
|
+
#
|
539
|
+
# @example Request syntax with placeholder values
|
540
|
+
#
|
541
|
+
# resp = client.post_text({
|
542
|
+
# bot_name: "BotName", # required
|
543
|
+
# bot_alias: "BotAlias", # required
|
544
|
+
# user_id: "UserId", # required
|
545
|
+
# session_attributes: {
|
546
|
+
# "String" => "String",
|
547
|
+
# },
|
548
|
+
# input_text: "Text", # required
|
549
|
+
# })
|
550
|
+
#
|
551
|
+
# @example Response structure
|
552
|
+
#
|
553
|
+
# resp.intent_name #=> String
|
554
|
+
# resp.slots #=> Hash
|
555
|
+
# resp.slots["String"] #=> String
|
556
|
+
# resp.session_attributes #=> Hash
|
557
|
+
# resp.session_attributes["String"] #=> String
|
558
|
+
# resp.message #=> String
|
559
|
+
# resp.dialog_state #=> String, one of "ElicitIntent", "ConfirmIntent", "ElicitSlot", "Fulfilled", "ReadyForFulfillment", "Failed"
|
560
|
+
# resp.slot_to_elicit #=> String
|
561
|
+
# resp.response_card.version #=> String
|
562
|
+
# resp.response_card.content_type #=> String, one of "application/vnd.amazonaws.card.generic"
|
563
|
+
# resp.response_card.generic_attachments #=> Array
|
564
|
+
# resp.response_card.generic_attachments[0].title #=> String
|
565
|
+
# resp.response_card.generic_attachments[0].sub_title #=> String
|
566
|
+
# resp.response_card.generic_attachments[0].attachment_link_url #=> String
|
567
|
+
# resp.response_card.generic_attachments[0].image_url #=> String
|
568
|
+
# resp.response_card.generic_attachments[0].buttons #=> Array
|
569
|
+
# resp.response_card.generic_attachments[0].buttons[0].text #=> String
|
570
|
+
# resp.response_card.generic_attachments[0].buttons[0].value #=> String
|
571
|
+
#
|
572
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText AWS API Documentation
|
573
|
+
#
|
574
|
+
# @overload post_text(params = {})
|
575
|
+
# @param [Hash] params ({})
|
576
|
+
def post_text(params = {}, options = {})
|
577
|
+
req = build_request(:post_text, params)
|
578
|
+
req.send_request(options)
|
579
|
+
end
|
580
|
+
|
581
|
+
# @!endgroup
|
582
|
+
|
583
|
+
# @param params ({})
|
584
|
+
# @api private
|
585
|
+
def build_request(operation_name, params = {})
|
586
|
+
handlers = @handlers.for(operation_name)
|
587
|
+
context = Seahorse::Client::RequestContext.new(
|
588
|
+
operation_name: operation_name,
|
589
|
+
operation: config.api.operation(operation_name),
|
590
|
+
client: self,
|
591
|
+
params: params,
|
592
|
+
config: config)
|
593
|
+
context[:gem_name] = 'aws-sdk-lex'
|
594
|
+
context[:gem_version] = '1.0.0.rc1'
|
595
|
+
Seahorse::Client::Request.new(handlers, context)
|
596
|
+
end
|
597
|
+
|
598
|
+
# @api private
|
599
|
+
# @deprecated
|
600
|
+
def waiter_names
|
601
|
+
[]
|
602
|
+
end
|
603
|
+
|
604
|
+
class << self
|
605
|
+
|
606
|
+
# @api private
|
607
|
+
attr_reader :identifier
|
608
|
+
|
609
|
+
# @api private
|
610
|
+
def errors_module
|
611
|
+
Errors
|
612
|
+
end
|
613
|
+
|
614
|
+
end
|
615
|
+
end
|
616
|
+
end
|