putIntent
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.
Samples
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.Message
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.Slot
fun main() {
//sampleStart
// This example shows how to create an intent for ordering pizzas.
val resp = lexModelBuildingClient.putIntent {
name = "DocOrderPizza"
description = "Order a pizza from a local pizzeria."
slots = listOf<Slot>(
Slot {
name = "Type"
description = "The type of pizza to order."
slotConstraint = SlotConstraint.fromValue("Required")
slotType = "DocPizzaType"
slotTypeVersion = "$LATEST"
valueElicitationPrompt = Prompt {
messages = listOf<Message>(
Message {
contentType = ContentType.fromValue("PlainText")
content = "What type of pizza would you like?"
},
Message {
contentType = ContentType.fromValue("PlainText")
content = "Vegie or cheese pizza?"
},
Message {
contentType = ContentType.fromValue("PlainText")
content = "I can get you a vegie or a cheese pizza."
}
)
maxAttempts = 1
}
priority = 1
sampleUtterances = listOf<String>(
"Get me a {Type} pizza.",
"A {Type} pizza please.",
"I'd like a {Type} pizza."
)
},
Slot {
name = "Crust"
description = "The type of pizza crust to order."
slotConstraint = SlotConstraint.fromValue("Required")
slotType = "DocPizzaCrustType"
slotTypeVersion = "$LATEST"
valueElicitationPrompt = Prompt {
messages = listOf<Message>(
Message {
contentType = ContentType.fromValue("PlainText")
content = "What type of crust would you like?"
},
Message {
contentType = ContentType.fromValue("PlainText")
content = "Thick or thin crust?"
}
)
maxAttempts = 1
}
priority = 2
sampleUtterances = listOf<String>(
"Make it a {Crust} crust.",
"I'd like a {Crust} crust."
)
},
Slot {
name = "Sauce"
description = "The type of sauce to use on the pizza."
slotConstraint = SlotConstraint.fromValue("Required")
slotType = "DocPizzaSauceType"
slotTypeVersion = "$LATEST"
valueElicitationPrompt = Prompt {
messages = listOf<Message>(
Message {
contentType = ContentType.fromValue("PlainText")
content = "White or red sauce?"
},
Message {
contentType = ContentType.fromValue("PlainText")
content = "Garlic or tomato sauce?"
}
)
maxAttempts = 1
}
priority = 3
sampleUtterances = listOf<String>(
"Make it {Sauce} sauce.",
"I'd like {Sauce} sauce."
)
}
)
sampleUtterances = listOf<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."
)
confirmationPrompt = Prompt {
messages = listOf<Message>(
Message {
contentType = ContentType.fromValue("PlainText")
content = "Should I order your {Crust} crust {Type} pizza with {Sauce} sauce?"
}
)
maxAttempts = 1
}
rejectionStatement = Statement {
messages = listOf<Message>(
Message {
contentType = ContentType.fromValue("PlainText")
content = "Ok, I'll cancel your order."
},
Message {
contentType = ContentType.fromValue("PlainText")
content = "I cancelled your order."
}
)
}
conclusionStatement = Statement {
messages = listOf<Message>(
Message {
contentType = ContentType.fromValue("PlainText")
content = "All right, I ordered you a {Crust} crust {Type} pizza with {Sauce} sauce."
},
Message {
contentType = ContentType.fromValue("PlainText")
content = "OK, your {Crust} crust {Type} pizza with {Sauce} sauce is on the way."
}
)
responseCard = "foo"
}
fulfillmentActivity = FulfillmentActivity {
type = FulfillmentActivityType.fromValue("ReturnIntent")
}
}
//sampleEnd
}