4
votes

I have been working on an Alexa skill and till date it worked fine but today i have encountered a strange issue. The similar issue can be seen in other skills as well. The issue is that i am getting multiple authorities in resolutionsPerAuthority of my skill's request JSON. These authorities have different status code for match of slot values. Hence my code is finding difficulties because resolutionsPerAuthority is supposed to have only one object.

I am using the code provided in official docs of amazon to get slot values and it it failing due to this very scenario. Anyone else facing the similar issue ? Any solutions?

Here is my request 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
Totally unrelated: I saw you triaged for editing on stackoverflow.com/review/triage/20797871 . Simply: wrong. edit is only for postings that other people than the OP can edit and improve. Here, it is necessary to turn screen shots into text. And only the owner should do that. So please: be more careful about such reviews. A wrong review on triage affects other people. So please be really careful and well informed about the decisions you make there!GhostCat

3 Answers

0
votes

I just got the same issue today. Never had this problem before. I'm guessing Amazon changed something.

I think the best thing to do is sort through the resolutions per authority and select the one that has an er_success_match instead of just grabbing the first item in the resolutionsPerAuthority list. However, I'm not sure if it will be possible to have multiple er_success_matchs in one resolutionsPerAuthority list.

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

0
votes

Problem: We are unable to retrieve id and various data related to resolution.

Reason: Earlier we had only one resolution array element which we referenced as resolutionsPerAuthority[0]. However now there are more than one.

Bug: One of the resolution items shows Match and other shows No Match. We are not able to retrieve information just by directly extracting it from resolutionsPerAuthority[0]

Anubhav’s Solution: Understand that it is not necessary that only the 1st element of resolution array can show Match code. Try if else or iterate over that array to locate which element could capture your request.

//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"); 
              }
     }

Due to a similar Issue I was unable to retrieve slot ID

0
votes

This is normal since Dynamic Entities was added. You can have a dynamic entity match but not a static match. You need to accommodate the code to support multiple authorities and decide what you do if you have multiple matches, a single match or none.