1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package lexmodelbuildingservice
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/lexmodelbuildingservice/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12	"time"
13)
14
15// Creates an Amazon Lex conversational bot or replaces an existing bot. When you
16// create or update a bot you are only required to specify a name, a locale, and
17// whether the bot is directed toward children under age 13. You can use this to
18// add intents later, or to remove intents from an existing bot. When you create a
19// bot with the minimum information, the bot is created or updated but Amazon Lex
20// returns the  response FAILED. You can build the bot after you add one or more
21// intents. For more information about Amazon Lex bots, see how-it-works. If you
22// specify the name of an existing bot, the fields in the request replace the
23// existing values in the $LATEST version of the bot. Amazon Lex removes any fields
24// that you don't provide values for in the request, except for the
25// idleTTLInSeconds and privacySettings fields, which are set to their default
26// values. If you don't specify values for required fields, Amazon Lex throws an
27// exception. This operation requires permissions for the lex:PutBot action. For
28// more information, see security-iam.
29func (c *Client) PutBot(ctx context.Context, params *PutBotInput, optFns ...func(*Options)) (*PutBotOutput, error) {
30	if params == nil {
31		params = &PutBotInput{}
32	}
33
34	result, metadata, err := c.invokeOperation(ctx, "PutBot", params, optFns, addOperationPutBotMiddlewares)
35	if err != nil {
36		return nil, err
37	}
38
39	out := result.(*PutBotOutput)
40	out.ResultMetadata = metadata
41	return out, nil
42}
43
44type PutBotInput struct {
45
46	// For each Amazon Lex bot created with the Amazon Lex Model Building Service, you
47	// must specify whether your use of Amazon Lex is related to a website, program, or
48	// other application that is directed or targeted, in whole or in part, to children
49	// under age 13 and subject to the Children's Online Privacy Protection Act (COPPA)
50	// by specifying true or false in the childDirected field. By specifying true in
51	// the childDirected field, you confirm that your use of Amazon Lex is related to a
52	// website, program, or other application that is directed or targeted, in whole or
53	// in part, to children under age 13 and subject to COPPA. By specifying false in
54	// the childDirected field, you confirm that your use of Amazon Lex is not related
55	// to a website, program, or other application that is directed or targeted, in
56	// whole or in part, to children under age 13 and subject to COPPA. You may not
57	// specify a default value for the childDirected field that does not accurately
58	// reflect whether your use of Amazon Lex is related to a website, program, or
59	// other application that is directed or targeted, in whole or in part, to children
60	// under age 13 and subject to COPPA. If your use of Amazon Lex relates to a
61	// website, program, or other application that is directed in whole or in part, to
62	// children under age 13, you must obtain any required verifiable parental consent
63	// under COPPA. For information regarding the use of Amazon Lex in connection with
64	// websites, programs, or other applications that are directed or targeted, in
65	// whole or in part, to children under age 13, see the Amazon Lex FAQ.
66	// (https://aws.amazon.com/lex/faqs#data-security)
67	//
68	// This member is required.
69	ChildDirected *bool
70
71	// Specifies the target locale for the bot. Any intent used in the bot must be
72	// compatible with the locale of the bot. The default is en-US.
73	//
74	// This member is required.
75	Locale types.Locale
76
77	// The name of the bot. The name is not case sensitive.
78	//
79	// This member is required.
80	Name *string
81
82	// When Amazon Lex can't understand the user's input in context, it tries to elicit
83	// the information a few times. After that, Amazon Lex sends the message defined in
84	// abortStatement to the user, and then cancels the conversation. To set the number
85	// of retries, use the valueElicitationPrompt field for the slot type. For example,
86	// in a pizza ordering bot, Amazon Lex might ask a user "What type of crust would
87	// you like?" If the user's response is not one of the expected responses (for
88	// example, "thin crust, "deep dish," etc.), Amazon Lex tries to elicit a correct
89	// response a few more times. For example, in a pizza ordering application,
90	// OrderPizza might be one of the intents. This intent might require the CrustType
91	// slot. You specify the valueElicitationPrompt field when you create the CrustType
92	// slot. If you have defined a fallback intent the cancel statement will not be
93	// sent to the user, the fallback intent is used instead. For more information, see
94	// AMAZON.FallbackIntent
95	// (https://docs.aws.amazon.com/lex/latest/dg/built-in-intent-fallback.html).
96	AbortStatement *types.Statement
97
98	// Identifies a specific revision of the $LATEST version. When you create a new
99	// bot, leave the checksum field blank. If you specify a checksum you get a
100	// BadRequestException exception. When you want to update a bot, set the checksum
101	// field to the checksum of the most recent revision of the $LATEST version. If you
102	// don't specify the  checksum field, or if the checksum does not match the $LATEST
103	// version, you get a PreconditionFailedException exception.
104	Checksum *string
105
106	// When Amazon Lex doesn't understand the user's intent, it uses this message to
107	// get clarification. To specify how many times Amazon Lex should repeat the
108	// clarification prompt, use the maxAttempts field. If Amazon Lex still doesn't
109	// understand, it sends the message in the abortStatement field. When you create a
110	// clarification prompt, make sure that it suggests the correct response from the
111	// user. for example, for a bot that orders pizza and drinks, you might create this
112	// clarification prompt: "What would you like to do? You can say 'Order a pizza' or
113	// 'Order a drink.'" If you have defined a fallback intent, it will be invoked if
114	// the clarification prompt is repeated the number of times defined in the
115	// maxAttempts field. For more information, see  AMAZON.FallbackIntent
116	// (https://docs.aws.amazon.com/lex/latest/dg/built-in-intent-fallback.html). If
117	// you don't define a clarification prompt, at runtime Amazon Lex will return a 400
118	// Bad Request exception in three cases:
119	//
120	// * Follow-up prompt - When the user
121	// responds to a follow-up prompt but does not provide an intent. For example, in
122	// response to a follow-up prompt that says "Would you like anything else today?"
123	// the user says "Yes." Amazon Lex will return a 400 Bad Request exception because
124	// it does not have a clarification prompt to send to the user to get an intent.
125	//
126	// *
127	// Lambda function - When using a Lambda function, you return an ElicitIntent
128	// dialog type. Since Amazon Lex does not have a clarification prompt to get an
129	// intent from the user, it returns a 400 Bad Request exception.
130	//
131	// * PutSession
132	// operation - When using the PutSession operation, you send an ElicitIntent dialog
133	// type. Since Amazon Lex does not have a clarification prompt to get an intent
134	// from the user, it returns a 400 Bad Request exception.
135	ClarificationPrompt *types.Prompt
136
137	// When set to true a new numbered version of the bot is created. This is the same
138	// as calling the CreateBotVersion operation. If you don't specify createVersion,
139	// the default is false.
140	CreateVersion *bool
141
142	// A description of the bot.
143	Description *string
144
145	// When set to true user utterances are sent to Amazon Comprehend for sentiment
146	// analysis. If you don't specify detectSentiment, the default is false.
147	DetectSentiment *bool
148
149	// Set to true to enable access to natural language understanding improvements.
150	// When you set the enableModelImprovements parameter to true you can use the
151	// nluIntentConfidenceThreshold parameter to configure confidence scores. For more
152	// information, see Confidence Scores
153	// (https://docs.aws.amazon.com/lex/latest/dg/confidence-scores.html). You can only
154	// set the enableModelImprovements parameter in certain Regions. If you set the
155	// parameter to true, your bot has access to accuracy improvements. The Regions
156	// where you can set the enableModelImprovements parameter to true are:
157	//
158	// * US East
159	// (N. Virginia) (us-east-1)
160	//
161	// * US West (Oregon) (us-west-2)
162	//
163	// * Asia Pacific
164	// (Sydney) (ap-southeast-2)
165	//
166	// * EU (Ireland) (eu-west-1)
167	//
168	// In other Regions, the
169	// enableModelImprovements parameter is set to true by default. In these Regions
170	// setting the parameter to false throws a ValidationException exception.
171	EnableModelImprovements *bool
172
173	// The maximum time in seconds that Amazon Lex retains the data gathered in a
174	// conversation. A user interaction session remains active for the amount of time
175	// specified. If no conversation occurs during this time, the session expires and
176	// Amazon Lex deletes any data provided before the timeout. For example, suppose
177	// that a user chooses the OrderPizza intent, but gets sidetracked halfway through
178	// placing an order. If the user doesn't complete the order within the specified
179	// time, Amazon Lex discards the slot information that it gathered, and the user
180	// must start over. If you don't include the idleSessionTTLInSeconds element in a
181	// PutBot operation request, Amazon Lex uses the default value. This is also true
182	// if the request replaces an existing bot. The default is 300 seconds (5 minutes).
183	IdleSessionTTLInSeconds *int32
184
185	// An array of Intent objects. Each intent represents a command that a user can
186	// express. For example, a pizza ordering bot might support an OrderPizza intent.
187	// For more information, see how-it-works.
188	Intents []types.Intent
189
190	// Determines the threshold where Amazon Lex will insert the AMAZON.FallbackIntent,
191	// AMAZON.KendraSearchIntent, or both when returning alternative intents in a
192	// PostContent
193	// (https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostContent.html) or
194	// PostText (https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html)
195	// response. AMAZON.FallbackIntent and AMAZON.KendraSearchIntent are only inserted
196	// if they are configured for the bot. You must set the enableModelImprovements
197	// parameter to true to use confidence scores in the following regions.
198	//
199	// * US East
200	// (N. Virginia) (us-east-1)
201	//
202	// * US West (Oregon) (us-west-2)
203	//
204	// * Asia Pacific
205	// (Sydney) (ap-southeast-2)
206	//
207	// * EU (Ireland) (eu-west-1)
208	//
209	// In other Regions, the
210	// enableModelImprovements parameter is set to true by default. For example,
211	// suppose a bot is configured with the confidence threshold of 0.80 and the
212	// AMAZON.FallbackIntent. Amazon Lex returns three alternative intents with the
213	// following confidence scores: IntentA (0.70), IntentB (0.60), IntentC (0.50). The
214	// response from the PostText operation would be:
215	//
216	// * AMAZON.FallbackIntent
217	//
218	// *
219	// IntentA
220	//
221	// * IntentB
222	//
223	// * IntentC
224	NluIntentConfidenceThreshold *float64
225
226	// If you set the processBehavior element to BUILD, Amazon Lex builds the bot so
227	// that it can be run. If you set the element to SAVE Amazon Lex saves the bot, but
228	// doesn't build it. If you don't specify this value, the default value is BUILD.
229	ProcessBehavior types.ProcessBehavior
230
231	// A list of tags to add to the bot. You can only add tags when you create a bot,
232	// you can't use the PutBot operation to update the tags on a bot. To update tags,
233	// use the TagResource operation.
234	Tags []types.Tag
235
236	// The Amazon Polly voice ID that you want Amazon Lex to use for voice interactions
237	// with the user. The locale configured for the voice must match the locale of the
238	// bot. For more information, see Voices in Amazon Polly
239	// (https://docs.aws.amazon.com/polly/latest/dg/voicelist.html) in the Amazon Polly
240	// Developer Guide.
241	VoiceId *string
242}
243
244type PutBotOutput struct {
245
246	// The message that Amazon Lex uses to cancel a conversation. For more information,
247	// see PutBot.
248	AbortStatement *types.Statement
249
250	// Checksum of the bot that you created.
251	Checksum *string
252
253	// For each Amazon Lex bot created with the Amazon Lex Model Building Service, you
254	// must specify whether your use of Amazon Lex is related to a website, program, or
255	// other application that is directed or targeted, in whole or in part, to children
256	// under age 13 and subject to the Children's Online Privacy Protection Act (COPPA)
257	// by specifying true or false in the childDirected field. By specifying true in
258	// the childDirected field, you confirm that your use of Amazon Lex is related to a
259	// website, program, or other application that is directed or targeted, in whole or
260	// in part, to children under age 13 and subject to COPPA. By specifying false in
261	// the childDirected field, you confirm that your use of Amazon Lex is not related
262	// to a website, program, or other application that is directed or targeted, in
263	// whole or in part, to children under age 13 and subject to COPPA. You may not
264	// specify a default value for the childDirected field that does not accurately
265	// reflect whether your use of Amazon Lex is related to a website, program, or
266	// other application that is directed or targeted, in whole or in part, to children
267	// under age 13 and subject to COPPA. If your use of Amazon Lex relates to a
268	// website, program, or other application that is directed in whole or in part, to
269	// children under age 13, you must obtain any required verifiable parental consent
270	// under COPPA. For information regarding the use of Amazon Lex in connection with
271	// websites, programs, or other applications that are directed or targeted, in
272	// whole or in part, to children under age 13, see the Amazon Lex FAQ.
273	// (https://aws.amazon.com/lex/faqs#data-security)
274	ChildDirected *bool
275
276	// The prompts that Amazon Lex uses when it doesn't understand the user's intent.
277	// For more information, see PutBot.
278	ClarificationPrompt *types.Prompt
279
280	// True if a new version of the bot was created. If the createVersion field was not
281	// specified in the request, the createVersion field is set to false in the
282	// response.
283	CreateVersion *bool
284
285	// The date that the bot was created.
286	CreatedDate *time.Time
287
288	// A description of the bot.
289	Description *string
290
291	// true if the bot is configured to send user utterances to Amazon Comprehend for
292	// sentiment analysis. If the detectSentiment field was not specified in the
293	// request, the detectSentiment field is false in the response.
294	DetectSentiment *bool
295
296	// Indicates whether the bot uses accuracy improvements. true indicates that the
297	// bot is using the improvements, otherwise, false.
298	EnableModelImprovements *bool
299
300	// If status is FAILED, Amazon Lex provides the reason that it failed to build the
301	// bot.
302	FailureReason *string
303
304	// The maximum length of time that Amazon Lex retains the data gathered in a
305	// conversation. For more information, see PutBot.
306	IdleSessionTTLInSeconds *int32
307
308	// An array of Intent objects. For more information, see PutBot.
309	Intents []types.Intent
310
311	// The date that the bot was updated. When you create a resource, the creation date
312	// and last updated date are the same.
313	LastUpdatedDate *time.Time
314
315	// The target locale for the bot.
316	Locale types.Locale
317
318	// The name of the bot.
319	Name *string
320
321	// The score that determines where Amazon Lex inserts the AMAZON.FallbackIntent,
322	// AMAZON.KendraSearchIntent, or both when returning alternative intents in a
323	// PostContent
324	// (https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostContent.html) or
325	// PostText (https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html)
326	// response. AMAZON.FallbackIntent is inserted if the confidence score for all
327	// intents is below this value. AMAZON.KendraSearchIntent is only inserted if it is
328	// configured for the bot.
329	NluIntentConfidenceThreshold *float64
330
331	// When you send a request to create a bot with processBehavior set to BUILD,
332	// Amazon Lex sets the status response element to BUILDING. In the
333	// READY_BASIC_TESTING state you can test the bot with user inputs that exactly
334	// match the utterances configured for the bot's intents and values in the slot
335	// types. If Amazon Lex can't build the bot, Amazon Lex sets status to FAILED.
336	// Amazon Lex returns the reason for the failure in the failureReason response
337	// element. When you set processBehavior to SAVE, Amazon Lex sets the status code
338	// to NOT BUILT. When the bot is in the READY state you can test and publish the
339	// bot.
340	Status types.Status
341
342	// A list of tags associated with the bot.
343	Tags []types.Tag
344
345	// The version of the bot. For a new bot, the version is always $LATEST.
346	Version *string
347
348	// The Amazon Polly voice ID that Amazon Lex uses for voice interaction with the
349	// user. For more information, see PutBot.
350	VoiceId *string
351
352	// Metadata pertaining to the operation's result.
353	ResultMetadata middleware.Metadata
354}
355
356func addOperationPutBotMiddlewares(stack *middleware.Stack, options Options) (err error) {
357	err = stack.Serialize.Add(&awsRestjson1_serializeOpPutBot{}, middleware.After)
358	if err != nil {
359		return err
360	}
361	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpPutBot{}, middleware.After)
362	if err != nil {
363		return err
364	}
365	if err = addSetLoggerMiddleware(stack, options); err != nil {
366		return err
367	}
368	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
369		return err
370	}
371	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
372		return err
373	}
374	if err = addResolveEndpointMiddleware(stack, options); err != nil {
375		return err
376	}
377	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
378		return err
379	}
380	if err = addRetryMiddlewares(stack, options); err != nil {
381		return err
382	}
383	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
384		return err
385	}
386	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
387		return err
388	}
389	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
390		return err
391	}
392	if err = addClientUserAgent(stack); err != nil {
393		return err
394	}
395	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
396		return err
397	}
398	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
399		return err
400	}
401	if err = addOpPutBotValidationMiddleware(stack); err != nil {
402		return err
403	}
404	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutBot(options.Region), middleware.Before); err != nil {
405		return err
406	}
407	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
408		return err
409	}
410	if err = addResponseErrorMiddleware(stack); err != nil {
411		return err
412	}
413	if err = addRequestResponseLogging(stack, options); err != nil {
414		return err
415	}
416	return nil
417}
418
419func newServiceMetadataMiddleware_opPutBot(region string) *awsmiddleware.RegisterServiceMetadata {
420	return &awsmiddleware.RegisterServiceMetadata{
421		Region:        region,
422		ServiceID:     ServiceID,
423		SigningName:   "lex",
424		OperationName: "PutBot",
425	}
426}
427