【问题标题】:In Alexa, how do I define slot defaults in my Intent code?在 Alexa 中,如何在 Intent 代码中定义插槽默认值?
【发布时间】:2018-07-04 02:04:42
【问题描述】:

我的 lambda 函数有一个意图。我正在尝试填补 4 个插槽,其中 3 个是必需的。在我的测试中,似乎我必须将 Assignee 字段设置为默认值,否则在我的实际处理程序中发生故障,这发生在下面的 else 语句之后。以下是我当前定义默认值的方式:

如果 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 {

我也尝试将受让人字段设置为默认值,如下所示:

    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
        }
    }
}

问题是,一旦我要求它打开一个 bug 票(它映射到带有“打开 {ticketType} 票”话语的意图),它给出的响应是“请求的技能的响应有问题”。

我认为设置默认值是必要的,我错了吗?我设置的默认值不正确吗?

【问题讨论】:

    标签: go alexa alexa-skills-kit alexa-slot


    【解决方案1】:

    据我所知,您需要包含所有插槽。因为这里的意图名称和插槽匹配,那么只有你会得到正确的响应

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多