AWS SDK Version 3 for .NET
API Reference

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:

You can specify other optional information in the request, such as:

If you specify an existing intent name to update the intent, Amazon Lex replaces the values in the $LATEST version of the slot type 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.

For more information, see how-it-works.

This operation requires permissions for the lex:PutIntent action.

Note:

For PCL this operation is only available in asynchronous form. Please refer to PutIntentAsync.

Namespace: Amazon.LexModelBuildingService
Assembly: AWSSDK.LexModelBuildingService.dll
Version: 3.x.y.z

Syntax

C#
public abstract PutIntentResponse PutIntent(
         PutIntentRequest request
)
Parameters
request
Type: Amazon.LexModelBuildingService.Model.PutIntentRequest

Container for the necessary parameters to execute the PutIntent service method.

Return Value
The response from the PutIntent service method, as returned by LexModelBuildingService.

Exceptions

ExceptionCondition
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.

Examples

This example shows how to create an intent for ordering pizzas.

To create an intent


var response = client.PutIntent(new PutIntentRequest 
{
    Name = "DocOrderPizza",
    ConclusionStatement = new Statement {
        Messages = new List {
            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 {
            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 {
        new Message {
            Content = "Ok, I'll cancel your order.",
            ContentType = "PlainText"
        },
        new Message {
            Content = "I cancelled your order.",
            ContentType = "PlainText"
        }
    } },
    SampleUtterances = new List {
        "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 {
        new Slot {
            Name = "Type",
            Description = "The type of pizza to order.",
            Priority = 1,
            SampleUtterances = new List {
                "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 {
                    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 {
                "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 {
                    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 {
                "Make it {Sauce} sauce.",
                "I'd like {Sauce} sauce."
            },
            SlotConstraint = "Required",
            SlotType = "DocPizzaSauceType",
            SlotTypeVersion = "$LATEST",
            ValueElicitationPrompt = new Prompt {
                MaxAttempts = 1,
                Messages = new List {
                    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 sampleUtterances = response.SampleUtterances;
List slots = response.Slots;

            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

See Also