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 intent or replaces an existing intent. To define the interaction 16// between the user and your bot, you use one or more intents. For a pizza ordering 17// bot, for example, you would create an OrderPizza intent. To create an intent or 18// replace an existing intent, you must provide the following: 19// 20// * Intent name. For 21// example, OrderPizza. 22// 23// * Sample utterances. For example, "Can I order a pizza, 24// please." and "I want to order a pizza." 25// 26// * Information to be gathered. You 27// specify slot types for the information that your bot will request from the user. 28// You can specify standard slot types, such as a date or a time, or custom slot 29// types such as the size and crust of a pizza. 30// 31// * How the intent will be 32// fulfilled. You can provide a Lambda function or configure the intent to return 33// the intent information to the client application. If you use a Lambda function, 34// when all of the intent information is available, Amazon Lex invokes your Lambda 35// function. If you configure your intent to return the intent information to the 36// client application. 37// 38// You can specify other optional information in the request, 39// such as: 40// 41// * A confirmation prompt to ask the user to confirm an intent. For 42// example, "Shall I order your pizza?" 43// 44// * A conclusion statement to send to the 45// user after the intent has been fulfilled. For example, "I placed your pizza 46// order." 47// 48// * A follow-up prompt that asks the user for additional activity. For 49// example, asking "Do you want to order a drink with your pizza?" 50// 51// If you specify 52// an existing intent name to update the intent, Amazon Lex replaces the values in 53// the $LATEST version of the intent with the values in the request. Amazon Lex 54// removes fields that you don't provide in the request. If you don't specify the 55// required fields, Amazon Lex throws an exception. When you update the $LATEST 56// version of an intent, the status field of any bot that uses the $LATEST version 57// of the intent is set to NOT_BUILT. For more information, see how-it-works. This 58// operation requires permissions for the lex:PutIntent action. 59func (c *Client) PutIntent(ctx context.Context, params *PutIntentInput, optFns ...func(*Options)) (*PutIntentOutput, error) { 60 if params == nil { 61 params = &PutIntentInput{} 62 } 63 64 result, metadata, err := c.invokeOperation(ctx, "PutIntent", params, optFns, addOperationPutIntentMiddlewares) 65 if err != nil { 66 return nil, err 67 } 68 69 out := result.(*PutIntentOutput) 70 out.ResultMetadata = metadata 71 return out, nil 72} 73 74type PutIntentInput struct { 75 76 // The name of the intent. The name is not case sensitive. The name can't match a 77 // built-in intent name, or a built-in intent name with "AMAZON." removed. For 78 // example, because there is a built-in intent called AMAZON.HelpIntent, you can't 79 // create a custom intent called HelpIntent. For a list of built-in intents, see 80 // Standard Built-in Intents 81 // (https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/standard-intents) 82 // in the Alexa Skills Kit. 83 // 84 // This member is required. 85 Name *string 86 87 // Identifies a specific revision of the $LATEST version. When you create a new 88 // intent, leave the checksum field blank. If you specify a checksum you get a 89 // BadRequestException exception. When you want to update a intent, set the 90 // checksum field to the checksum of the most recent revision of the $LATEST 91 // version. If you don't specify the checksum field, or if the checksum does not 92 // match the $LATEST version, you get a PreconditionFailedException exception. 93 Checksum *string 94 95 // The statement that you want Amazon Lex to convey to the user after the intent is 96 // successfully fulfilled by the Lambda function. This element is relevant only if 97 // you provide a Lambda function in the fulfillmentActivity. If you return the 98 // intent to the client application, you can't specify this element. The 99 // followUpPrompt and conclusionStatement are mutually exclusive. You can specify 100 // only one. 101 ConclusionStatement *types.Statement 102 103 // Prompts the user to confirm the intent. This question should have a yes or no 104 // answer. Amazon Lex uses this prompt to ensure that the user acknowledges that 105 // the intent is ready for fulfillment. For example, with the OrderPizza intent, 106 // you might want to confirm that the order is correct before placing it. For other 107 // intents, such as intents that simply respond to user questions, you might not 108 // need to ask the user for confirmation before providing the information. You you 109 // must provide both the rejectionStatement and the confirmationPrompt, or neither. 110 ConfirmationPrompt *types.Prompt 111 112 // When set to true a new numbered version of the intent is created. This is the 113 // same as calling the CreateIntentVersion operation. If you do not specify 114 // createVersion, the default is false. 115 CreateVersion *bool 116 117 // A description of the intent. 118 Description *string 119 120 // Specifies a Lambda function to invoke for each user input. You can invoke this 121 // Lambda function to personalize user interaction. For example, suppose your bot 122 // determines that the user is John. Your Lambda function might retrieve John's 123 // information from a backend database and prepopulate some of the values. For 124 // example, if you find that John is gluten intolerant, you might set the 125 // corresponding intent slot, GlutenIntolerant, to true. You might find John's 126 // phone number and set the corresponding session attribute. 127 DialogCodeHook *types.CodeHook 128 129 // Amazon Lex uses this prompt to solicit additional activity after fulfilling an 130 // intent. For example, after the OrderPizza intent is fulfilled, you might prompt 131 // the user to order a drink. The action that Amazon Lex takes depends on the 132 // user's response, as follows: 133 // 134 // * If the user says "Yes" it responds with the 135 // clarification prompt that is configured for the bot. 136 // 137 // * if the user says "Yes" 138 // and continues with an utterance that triggers an intent it starts a conversation 139 // for the intent. 140 // 141 // * If the user says "No" it responds with the rejection 142 // statement configured for the the follow-up prompt. 143 // 144 // * If it doesn't recognize 145 // the utterance it repeats the follow-up prompt again. 146 // 147 // The followUpPrompt field 148 // and the conclusionStatement field are mutually exclusive. You can specify only 149 // one. 150 FollowUpPrompt *types.FollowUpPrompt 151 152 // Required. Describes how the intent is fulfilled. For example, after a user 153 // provides all of the information for a pizza order, fulfillmentActivity defines 154 // how the bot places an order with a local pizza store. You might configure Amazon 155 // Lex to return all of the intent information to the client application, or direct 156 // it to invoke a Lambda function that can process the intent (for example, place 157 // an order with a pizzeria). 158 FulfillmentActivity *types.FulfillmentActivity 159 160 // An array of InputContext objects that lists the contexts that must be active for 161 // Amazon Lex to choose the intent in a conversation with the user. 162 InputContexts []types.InputContext 163 164 // Configuration information required to use the AMAZON.KendraSearchIntent intent 165 // to connect to an Amazon Kendra index. For more information, see 166 // AMAZON.KendraSearchIntent 167 // (http://docs.aws.amazon.com/lex/latest/dg/built-in-intent-kendra-search.html). 168 KendraConfiguration *types.KendraConfiguration 169 170 // An array of OutputContext objects that lists the contexts that the intent 171 // activates when the intent is fulfilled. 172 OutputContexts []types.OutputContext 173 174 // A unique identifier for the built-in intent to base this intent on. To find the 175 // signature for an intent, see Standard Built-in Intents 176 // (https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/standard-intents) 177 // in the Alexa Skills Kit. 178 ParentIntentSignature *string 179 180 // When the user answers "no" to the question defined in confirmationPrompt, Amazon 181 // Lex responds with this statement to acknowledge that the intent was canceled. 182 // You must provide both the rejectionStatement and the confirmationPrompt, or 183 // neither. 184 RejectionStatement *types.Statement 185 186 // An array of utterances (strings) that a user might say to signal the intent. For 187 // example, "I want {PizzaSize} pizza", "Order {Quantity} {PizzaSize} pizzas". In 188 // each utterance, a slot name is enclosed in curly braces. 189 SampleUtterances []string 190 191 // An array of intent slots. At runtime, Amazon Lex elicits required slot values 192 // from the user using prompts defined in the slots. For more information, see 193 // how-it-works. 194 Slots []types.Slot 195} 196 197type PutIntentOutput struct { 198 199 // Checksum of the $LATESTversion of the intent created or updated. 200 Checksum *string 201 202 // After the Lambda function specified in thefulfillmentActivityintent fulfills the 203 // intent, Amazon Lex conveys this statement to the user. 204 ConclusionStatement *types.Statement 205 206 // If defined in the intent, Amazon Lex prompts the user to confirm the intent 207 // before fulfilling it. 208 ConfirmationPrompt *types.Prompt 209 210 // True if a new version of the intent was created. If the createVersion field was 211 // not specified in the request, the createVersion field is set to false in the 212 // response. 213 CreateVersion *bool 214 215 // The date that the intent was created. 216 CreatedDate *time.Time 217 218 // A description of the intent. 219 Description *string 220 221 // If defined in the intent, Amazon Lex invokes this Lambda function for each user 222 // input. 223 DialogCodeHook *types.CodeHook 224 225 // If defined in the intent, Amazon Lex uses this prompt to solicit additional user 226 // activity after the intent is fulfilled. 227 FollowUpPrompt *types.FollowUpPrompt 228 229 // If defined in the intent, Amazon Lex invokes this Lambda function to fulfill the 230 // intent after the user provides all of the information required by the intent. 231 FulfillmentActivity *types.FulfillmentActivity 232 233 // An array of InputContext objects that lists the contexts that must be active for 234 // Amazon Lex to choose the intent in a conversation with the user. 235 InputContexts []types.InputContext 236 237 // Configuration information, if any, required to connect to an Amazon Kendra index 238 // and use the AMAZON.KendraSearchIntent intent. 239 KendraConfiguration *types.KendraConfiguration 240 241 // The date that the intent was updated. When you create a resource, the creation 242 // date and last update dates are the same. 243 LastUpdatedDate *time.Time 244 245 // The name of the intent. 246 Name *string 247 248 // An array of OutputContext objects that lists the contexts that the intent 249 // activates when the intent is fulfilled. 250 OutputContexts []types.OutputContext 251 252 // A unique identifier for the built-in intent that this intent is based on. 253 ParentIntentSignature *string 254 255 // If the user answers "no" to the question defined in confirmationPrompt Amazon 256 // Lex responds with this statement to acknowledge that the intent was canceled. 257 RejectionStatement *types.Statement 258 259 // An array of sample utterances that are configured for the intent. 260 SampleUtterances []string 261 262 // An array of intent slots that are configured for the intent. 263 Slots []types.Slot 264 265 // The version of the intent. For a new intent, the version is always $LATEST. 266 Version *string 267 268 // Metadata pertaining to the operation's result. 269 ResultMetadata middleware.Metadata 270} 271 272func addOperationPutIntentMiddlewares(stack *middleware.Stack, options Options) (err error) { 273 err = stack.Serialize.Add(&awsRestjson1_serializeOpPutIntent{}, middleware.After) 274 if err != nil { 275 return err 276 } 277 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpPutIntent{}, middleware.After) 278 if err != nil { 279 return err 280 } 281 if err = addSetLoggerMiddleware(stack, options); err != nil { 282 return err 283 } 284 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 285 return err 286 } 287 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 288 return err 289 } 290 if err = addResolveEndpointMiddleware(stack, options); err != nil { 291 return err 292 } 293 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 294 return err 295 } 296 if err = addRetryMiddlewares(stack, options); err != nil { 297 return err 298 } 299 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 300 return err 301 } 302 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 303 return err 304 } 305 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 306 return err 307 } 308 if err = addClientUserAgent(stack); err != nil { 309 return err 310 } 311 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 312 return err 313 } 314 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 315 return err 316 } 317 if err = addOpPutIntentValidationMiddleware(stack); err != nil { 318 return err 319 } 320 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutIntent(options.Region), middleware.Before); err != nil { 321 return err 322 } 323 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 324 return err 325 } 326 if err = addResponseErrorMiddleware(stack); err != nil { 327 return err 328 } 329 if err = addRequestResponseLogging(stack, options); err != nil { 330 return err 331 } 332 return nil 333} 334 335func newServiceMetadataMiddleware_opPutIntent(region string) *awsmiddleware.RegisterServiceMetadata { 336 return &awsmiddleware.RegisterServiceMetadata{ 337 Region: region, 338 ServiceID: ServiceID, 339 SigningName: "lex", 340 OperationName: "PutIntent", 341 } 342} 343