gpt4 book ai didi

go - 在 Alexa 中,我如何在 Intent 代码中定义插槽默认值?

转载 作者:数据小太阳 更新时间:2023-10-29 03:23:24 25 4
gpt4 key购买 nike

我的 lambda 函数只有一个 intent 。我正在尝试填充 4 个插槽,其中 3 个是必需的。在我的测试中,似乎我必须将 Assignee 字段设置为默认值,否则我的实际处理程序中的某些内容会在下面的 else 语句之后发生。以下是我目前定义默认值的方式:

if strings.ToUpper(request.DialogState) == "STARTED"{

        log.Println("DialogState == STARTED")
// Pre-fill slots: update the intent object with slot values for which
// you have defaults, then return Dialog.Delegate with this updated intent
// in the updatedIntent property.
slots := make(map[string]alexa.IntentSlot)
slots["Summary"] = alexa.IntentSlot{
Name: "Summary",
Value: "",
ConfirmationStatus: "NONE",
}
slots["TicketType"] = alexa.IntentSlot{
Name: "TicketType",
Value: "",
ConfirmationStatus: "NONE",
}
slots["Project"] = alexa.IntentSlot{
Name: "Project",
Value: "",
ConfirmationStatus: "NONE",
}
slots["Assignee"] = alexa.IntentSlot{
Name: "Assignee",
Value: "tcheek",
ConfirmationStatus: "NONE",
}
i := &alexa.Intent{
Name: "OpenTicketIntent",
ConfirmationStatus: "NONE",
Slots: slots,
}
response.AddDialogDirective("Dialog.Delegate", "", "", i)
response.ShouldSessionEnd = false
log.Println("DialogState has exited STARTED")

} else if strings.ToUpper(request.DialogState) != "COMPLETED" {

log.Println("DialogState == IN PROGRESS")
// return a Dialog.Delegate directive with no updatedIntent property.
response.ShouldSessionEnd = false
response.AddDialogDirective("Dialog.Delegate", "", "", nil)
log.Println("DialogState has exited IN PROGRESS")

} else {

我也试过将 Assignee 字段设置为默认值,如下所示:

    slots := make(map[string]alexa.IntentSlot)

slots["Assignee"] = alexa.IntentSlot{
Name: "Assignee",
Value: "tcheek",
ConfirmationStatus: "NONE",
}
i := &alexa.Intent{
Name: "OpenTicketIntent",
ConfirmationStatus: "NONE",
Slots: slots,
}
response.AddDialogDirective("Dialog.Delegate", "", "", i)

在这种情况下,我在模拟器中得到以下 lambda 函数响应:

{
"body": {
"version": "1.0",
"response": {
"directives": [
{
"type": "Dialog.Delegate",
"updatedIntent": {
"name": "OpenTicketIntent",
"confirmationStatus": "NONE",
"slots": {
"Assignee": {
"name": "Assignee",
"value": "tcheek",
"confirmationStatus": "NONE"
}
}
}
}
],
"shouldEndSession": false
}
}
}

问题是,一旦我要求它打开一个错误票(它映射到带有“打开 {ticketType} 票”话语的 intent ),它给出的响应是“所请求技能的响应存在问题".

我认为必须设置默认值是错误的吗?我是否错误地设置了默认值?

最佳答案

据我所知,您需要包括所有广告位。因为这里的 intent 名称和插槽匹配,所以只有你会得到正确的响应

关于go - 在 Alexa 中,我如何在 Intent 代码中定义插槽默认值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49022585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com