AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Creates an intent or replaces an existing intent.
To define the interaction between the user and your bot, you use one or more intents.
For a pizza ordering bot, for example, you would create an OrderPizza
intent.
To create an intent or replace an existing intent, you must provide the following:
Intent name. For example, OrderPizza
.
Sample utterances. For example, "Can I order a pizza, please." and "I want to order a pizza."
Information to be gathered. You specify slot types for the information that your bot will request from the user. You can specify standard slot types, such as a date or a time, or custom slot types such as the size and crust of a pizza.
How the intent will be fulfilled. You can provide a Lambda function or configure the intent to return the intent information to the client application. If you use a Lambda function, when all of the intent information is available, Amazon Lex invokes your Lambda function. If you configure your intent to return the intent information to the client application.
You can specify other optional information in the request, such as:
A confirmation prompt to ask the user to confirm an intent. For example, "Shall I order your pizza?"
A conclusion statement to send to the user after the intent has been fulfilled. For example, "I placed your pizza order."
A follow-up prompt that asks the user for additional activity. For example, asking "Do you want to order a drink with your pizza?"
If you specify an existing intent name to update the intent, Amazon Lex replaces the
values in the $LATEST
version of the intent with the values in the request.
Amazon Lex removes fields that you don't provide in the request. If you don't specify
the required fields, Amazon Lex throws an exception. When you update the $LATEST
version of an intent, the status
field of any bot that uses the $LATEST
version of the intent is set to NOT_BUILT
.
For more information, see how-it-works.
This operation requires permissions for the lex:PutIntent
action.
For .NET Core this operation is only available in asynchronous form. Please refer to PutIntentAsync.
Namespace: Amazon.LexModelBuildingService
Assembly: AWSSDK.LexModelBuildingService.dll
Version: 3.x.y.z
public virtual PutIntentResponse PutIntent( PutIntentRequest request )
Container for the necessary parameters to execute the PutIntent service method.
Exception | Condition |
---|---|
BadRequestException | The request is not well formed. For example, a value is invalid or a required field is missing. Check the field values, and try again. |
ConflictException | There was a conflict processing the request. Try your request again. |
InternalFailureException | An internal Amazon Lex error occurred. Try your request again. |
LimitExceededException | The request exceeded a limit. Try your request again. |
PreconditionFailedException | The checksum of the resource that you are trying to change does not match the checksum in the request. Check the resource's checksum and try again. |
This example shows how to create an intent for ordering pizzas.
var client = new AmazonLexModelBuildingServiceClient(); var response = client.PutIntent(new PutIntentRequest { Name = "DocOrderPizza", ConclusionStatement = new Statement { Messages = new List<Message> { new Message { Content = "All right, I ordered you a {Crust} crust {Type} pizza with {Sauce} sauce.", ContentType = "PlainText" }, new Message { Content = "OK, your {Crust} crust {Type} pizza with {Sauce} sauce is on the way.", ContentType = "PlainText" } }, ResponseCard = "foo" }, ConfirmationPrompt = new Prompt { MaxAttempts = 1, Messages = new List<Message> { new Message { Content = "Should I order your {Crust} crust {Type} pizza with {Sauce} sauce?", ContentType = "PlainText" } } }, Description = "Order a pizza from a local pizzeria.", FulfillmentActivity = new FulfillmentActivity { Type = "ReturnIntent" }, RejectionStatement = new Statement { Messages = new List<Message> { new Message { Content = "Ok, I'll cancel your order.", ContentType = "PlainText" }, new Message { Content = "I cancelled your order.", ContentType = "PlainText" } } }, SampleUtterances = new List<string> { "Order me a pizza.", "Order me a {Type} pizza.", "I want a {Crust} crust {Type} pizza", "I want a {Crust} crust {Type} pizza with {Sauce} sauce." }, Slots = new List<Slot> { new Slot { Name = "Type", Description = "The type of pizza to order.", Priority = 1, SampleUtterances = new List<string> { "Get me a {Type} pizza.", "A {Type} pizza please.", "I'd like a {Type} pizza." }, SlotConstraint = "Required", SlotType = "DocPizzaType", SlotTypeVersion = "$LATEST", ValueElicitationPrompt = new Prompt { MaxAttempts = 1, Messages = new List<Message> { new Message { Content = "What type of pizza would you like?", ContentType = "PlainText" }, new Message { Content = "Vegie or cheese pizza?", ContentType = "PlainText" }, new Message { Content = "I can get you a vegie or a cheese pizza.", ContentType = "PlainText" } } } }, new Slot { Name = "Crust", Description = "The type of pizza crust to order.", Priority = 2, SampleUtterances = new List<string> { "Make it a {Crust} crust.", "I'd like a {Crust} crust." }, SlotConstraint = "Required", SlotType = "DocPizzaCrustType", SlotTypeVersion = "$LATEST", ValueElicitationPrompt = new Prompt { MaxAttempts = 1, Messages = new List<Message> { new Message { Content = "What type of crust would you like?", ContentType = "PlainText" }, new Message { Content = "Thick or thin crust?", ContentType = "PlainText" } } } }, new Slot { Name = "Sauce", Description = "The type of sauce to use on the pizza.", Priority = 3, SampleUtterances = new List<string> { "Make it {Sauce} sauce.", "I'd like {Sauce} sauce." }, SlotConstraint = "Required", SlotType = "DocPizzaSauceType", SlotTypeVersion = "$LATEST", ValueElicitationPrompt = new Prompt { MaxAttempts = 1, Messages = new List<Message> { new Message { Content = "White or red sauce?", ContentType = "PlainText" }, new Message { Content = "Garlic or tomato sauce?", ContentType = "PlainText" } } } } } }); string version = response.Version; string name = response.Name; string checksum = response.Checksum; Statement conclusionStatement = response.ConclusionStatement; Prompt confirmationPrompt = response.ConfirmationPrompt; DateTime createdDate = response.CreatedDate; string description = response.Description; FulfillmentActivity fulfillmentActivity = response.FulfillmentActivity; DateTime lastUpdatedDate = response.LastUpdatedDate; Statement rejectionStatement = response.RejectionStatement; List<string> sampleUtterances = response.SampleUtterances; List<Slot> slots = response.Slots;
.NET Framework:
Supported in: 4.5, 4.0, 3.5