doyz51819 2018-02-21 03:18
浏览 58

对话框模型填充的Alexa Skill中的最后一个插槽始终会引发问题,Cloudwatch日志中没有错误

I'm trying to build a custom Alexa skill that takes 4 values as input, the first 3 of which are required. I have my dialog model fully set up so that Alexa will ask the user for required values until all slots are filled. My problem is that whenever Alexa gets to the last required slot to fill, once the user gives their input, the skill invariably says "Sorry, something went wrong" (physical device) or "There was a problem processing your input" (simulator). When making the first 3 required, it fails after the user gives an answer to the 3rd slot. If I make only 2 required, it fails after the user gives an answer to the 2nd slot. Same thing if only one is required. If all 4 are required, the skill works in the simulator, but not on the physical device. Here's my Intent, in golang:

case "OpenTicketIntent":
    log.Println("OpenTicketIntent triggered")

    // The request variable here is the IntentRequest object sent to the skill.
    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.
        // myMap := make(map[string]alexa.IntentSlot)
        // myMap["Assignee"] = alexa.IntentSlot{
        //  Name:               "assignee",
        //  Value:              "Unassigned",
        //  ConfirmationStatus: "NONE",
        // }
        // i := &alexa.Intent{
        //  Name:               "OpenTicketIntent",
        //  ConfirmationStatus: "NONE",
        //  Slots:              myMap,
        // }
        response.AddDialogDirective("Dialog.Delegate", nil)
        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 {

        log.Println("DialogState == COMPLETED")
        // Dialog is now complete and all required slots should be filled,
        // so call your normal intent handler.
        ticketType := request.Intent.Slots["TicketType"].Value
        project := request.Intent.Slots["Project"].Value
        summary := request.Intent.Slots["Summary"].Value
        assignee := request.Intent.Slots["Assignee"].Value
        response.ShouldSessionEnd = false
        log.Printf("Ticket Type is %s, Project is %s, Issue Title is %s, and Assignee is %s
", ticketType, project, summary, assignee)

        jiraClient, err := jira.NewClient(nil, "https://imaginovation.atlassian.net/")
        if err != nil {
            log.Println(err.Error())
            response.SetOutputText("There was a problem creating the Jira Client")
            log.Printf("Set Output speech, value now: %s", response.OutputSpeech.Text)
        }
        log.Println("Created Jira Client...")
        jiraClient.Authentication.SetBasicAuth("tcheek@imaginovation.net", "Stormlight94")

        i := &jira.Issue{
            Fields: &jira.IssueFields{
                Summary: "Created from JiraBot",
                Type: jira.IssueType{
                    ID: "10000",
                },
                Project: jira.Project{
                    Key: "IMJ",
                },
                Assignee: &jira.User{
                    Name: "tcheek",
                },
            },
        }
        _, jiraResponse, err := jiraClient.Issue.Create(i)
        log.Println(jiraResponse.Status)
        if jiraResponse.StatusCode == 400 {
            buf := new(bytes.Buffer)
            buf.ReadFrom(jiraResponse.Body)
            jiraResponseStr := buf.String()
            log.Println(jiraResponseStr)
        }
        if err != nil {
            log.Println(err.Error())
            response.SetOutputText("There was a problem creating the Jira ticket")
            log.Printf("Set Output speech, value now: %s", response.OutputSpeech.Text)
        }
        log.Println("DialogState has exited COMPLETED")

    }

The first thing you might think of is that I'm setting response.ShouldSessionEnd to false. But this doesn't change anything, it fails the same way if it's true or false. I am making it false because 3 seconds is sometimes not enough time for the skill to do the things it needs to do after the else statement, and setting this to false gives the skill the 8 seconds that Alexa gives while expecting a response. If there is no response or the skill finishes, the session will end normally.

The second thing you might think of is that there is an error somewhere I'm not looking for. Here's the Cloudwatch output:

enter image description here enter image description here

The skill goes through the motions of getting each slot value until the 3rd required slot is filled and then quietly stops.

I'm also getting an Internal Service Error when looking at the logs through the simulator.

{
    "header": {
        "namespace": "System",
        "name": "Exception",
        "messageId": "b528b1ac-9809-4c1a-a2ad-bbff68988ce8"
    },
    "payload": {
        "code": "INTERNAL_SERVICE_EXCEPTION",
        "description": "Request could not be executed due to an internal service error."
    }
}

Why might my skill be failing on the last slot?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集