根据Alexa技能要求,每个决议中有多个授权机构

时间:2018-07-26 14:02:52

标签: alexa alexa-skills-kit alexa-skill alexa-slot alexa-app

我一直在研究Alexa技能,直到现在为止效果还不错,但是今天我遇到了一个奇怪的问题。在其他技能中也可以看到类似的问题。问题是我在技能请求JSON的resolutionsPerAuthority中获得了多个权限。这些授权机构具有不同的状态代码以匹配插槽值。因此,我的代码遇到了困难,因为resolutionsPerAuthority应该只有一个对象。

我正在使用亚马逊官方文档中提供的代码来获取广告位值,由于这种情况,它失败了。 还有其他人遇到类似的问题吗?有解决方案吗?

这是我的请求JSON:

{
    "version": "1.0",
    "session": {
        "new": false,
        "sessionId": "amzn1.echo-api.session.f4bf3a11-f882-4732-9275-6e494e0bca4d",
        "application": {
            "applicationId": "app id"
        },
        "attributes": {
            "launchCount": 0,
            "jokeCount": 0,
            "indexes": [
                34
            ],
            "lastSpeechOutput": {
                "outputSpeech": "response",
                "reprompt": "reprompt"
            },
            "history": [
                {
                    "IntentRequest": "LaunchRequest"
                }
            ],
            "currentJokeIndex": 34,
            "lastUseTimestamp": 0
        },
        "user": {
            "userId": "amzn1.ask.account.ncsdkncsdlcnskY"
        }
    },
    "context": {
        "Display": {
            "token": "string"
        },
        "System": {
            "application": {
                "applicationId": "id"
            },
            "user": {
                "userId": ""
            },
            "device": {
                "deviceId": "",
                "supportedInterfaces": {
                    "Display": {
                        "templateVersion": "1.0",
                        "markupVersion": "1.0"
                    }
                }
            },
            "apiEndpoint": "https://api.eu.amazonalexa.com",
            "apiAccessToken": ""
        }
    },
    "request": {
        "type": "IntentRequest",
        "requestId": "amzn1.echo-api.request.824ef2fe-5a6b-45c8-96d2-a5aa0063e9b5",
        "timestamp": "2018-07-26T13:47:56Z",
        "locale": "en-IN",
        "intent": {
            "name": "TellJokeIntent",
            "confirmationStatus": "NONE",
            "slots": {
                "joke": {
                    "name": "joke",
                    "value": "joke",
                    "resolutions": {
                        "resolutionsPerAuthority": [
                            {
                                "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.a4bb9873-04fa-486f-8e1e-e30cb3c3d669.joke",
                                "status": {
                                    "code": "ER_SUCCESS_MATCH"
                                },
                                "values": [
                                    {
                                        "value": {
                                            "name": "joke",
                                            "id": "e2ff3cfd4b43876adaa5767ce93bf7d3"
                                        }
                                    }
                                ]
                            },
                            {
                                "authority": "amzn1.er-authority.dynamic.amzn1.ask.skill.a4bb9873-04fa-486f-8e1e-e30cb3c3d669.joke",
                                "status": {
                                    "code": "ER_SUCCESS_NO_MATCH"
                                }
                            }
                        ]
                    },
                    "confirmationStatus": "NONE"
                }
            }
        }
    }
}

3 个答案:

答案 0 :(得分:0)

我今天刚遇到同样的问题。从来没有过这个问题。我猜亚马逊改变了一些。

我认为最好的办法是按权限对解决方案进行排序,并选择具有er_success_match的解决方案,而不是仅在resolutionsPerAuthority列表中获取第一项。但是,我不确定在一个resolutionsPerAuthority列表中是否可以有多个er_success_match。

https://forums.developer.amazon.com/questions/171318/when-would-you-have-multiple-resolution-authoritie.html

答案 1 :(得分:0)

问题:我们无法检索ID和与分辨率相关的各种数据。

原因:之前我们只有一个分辨率数组元素,我们将其称为resolutionsPerAuthority[0]。但是,现在不止一个。

错误:解决方案之一显示Match,其他显示No Match。我们无法直接从resolutionsPerAuthority[0]

中提取信息来检索信息

Anubhav的解决方案:请理解,分辨率数组的第一个元素不必显示Match代码。尝试是否进行其他操作或遍历该数组以查找哪个元素可以捕获您的请求。

//Check Status Code (Match/NoMatch) in 1st Element
console.log("Zero Code===>" +request.intent.slots.SlotName.resolutions.resolutionsPerAuthority[0].status.code); 

//Check Status Code (Match/NoMatch) in 2nd Element
console.log("One Code===>" +request.intent.slots.SlotName.resolutions.resolutionsPerAuthority[1].status.code); 

//Iterate and if Match condition is satisfied update the ID variable

if((request.intent.slots.SlotName.resolutions.resolutionsPerAuthority[0].status.code) === “ER_SUCCESS_MATCH")
 { 
      console.log("in If"); 
        try 
          { 
            var SlotID = request.intent.slots.SlotName.resolutions.resolutionsPerAuthority[0].values[0].value.id;                      console.log("SlotTwoID Collected"); 
           } 
        catch(Error) 
          {  
            console.log("In Catch”);
           }
 } 

else  
   { 
        console.log("in else"); 
          try 
              { 
               var SlotID = request.intent.slots.SlotName.resolutions.resolutionsPerAuthority[1].values[0].value.id;      console.log("SlotID Collected"); 
               } 
          catch(Error) 
             { 
             console.log("In Catch"); 
              }
     }

由于类似的问题,我无法检索插槽ID

答案 2 :(得分:0)

这是正常现象,因为添加了Dynamic Entities。您可以具有动态实体匹配,但不能具有静态匹配。您需要容纳代码以支持多个权限,并确定如果有多个匹配项,单个匹配项或没有匹配项,该怎么办。

相关问题