alexa-samples / alexa-smarthome

Resources for Alexa Smart Home developers.
https://alexa.design/smarthome
Other
685 stars 336 forks source link

Alexa not recognising json response #12

Closed fintan63 closed 6 years ago

fintan63 commented 6 years ago

Hi

I can sucessfully call my smart home skill by saying

Alexa switch input to Satellite

Lambda receives the directive as

{
    "directive": {
        "header": {
            "namespace": "Alexa.InputController",
            "name": "SelectInput",
            "payloadVersion": "3",
            "messageId": "53c9ac3f-d20e-4506-86b3-39ea422633d4",
            "correlationToken": "AAAAAAAAAACsqwiAPGRxeyZdhqLHHAfycAEAAAAAAABbsx0W67868BLmmNZ2/e8lXZlF5aGPno+dc7Em6/E3s/HVmWXRVPq4cFARu8F2lqj6C0esvl/1WxSxl5vBMEoG5zmwy8hRyfcrBg8JI3n28ckJPKMt3Y5EAJiIXs8sGMK43z1OkgAgtE20fAs6jL/TVKL5bsw7Vt/hk1cMNXE8pYknxWPBDXqFzX1HzjdD43CWP+g20vc+4TkHFq6Q8f0p2EvXrlQFJEmFXh+yQmXCya16AUbWCLfvCnApzEL0M1iwMIUY+vBOO4MB5mUmGOdZbnfe38nD23pPyD6LDOzkrGOeRvcg6W/v6kwYG9XBm4w8eWU8M8YxlvR+ztNFWk8Igvu+3jcAxwvbsnIz2YN00jVy5XcAE+Z0z6NP9j4QdIHhTHzRI0sSg03ClQoCsSYTdBZr8+x0250mX9SCgTQ/UstCKHK/C/CBRhlGhyjtdGvIS+xgr6srqF8W8go+Gjp5yNNjRP+CVad66I2pmzuoOg=="
        },
        "endpoint": {
            "scope": {
                "type": "BearerToken",
                "token": "Atza|IwEBIDVP74C8LqSZeP0g-MTGT-a5Qs3UHT50iQ64w4jQ8M9j1ZykTxVYyGRP3rtupeVMI5O_DG8KLLMAQUuwAI3gFpmca_ZEWZXyXSq_mXA6WeNahQe_t8kdTY0maeYCAjS98nAUJKlsBFbWNl7wOH3i8_GB0H8b7HBKOiOmwdS2GGH5owRvKe0gvoLcqulZfaBRQQQPwFYqJILON48fcza64jyDlai60KY0GT3GsHZ6QtzhkiXfFnSGz6aTI2TGjuUf87jJRt7sMshv4YB_TTC2KsV8_CisNEgOw9HGGgyXep8r_1MRpcL87QM2MB3_6Ll0dqxILRbiNsG5crhtn9mfqkUA8k3z0TzTqElsbFoRSG4S1rmkj_eihdXR5pabko0o72Lp2fBz2JRfN2BjHPp36I0C5byWtHE0gf9Pm298pQmIW2E0l_9jqJV2MV6NA1J92XnM5WDnWursjeA6ARUaGeKWWYdesz9NSnCMPznGGvbIvEkfaHV1TUfLPZuLLfT3kHU"
            },
            "endpointId": "appliance-001",
            "cookie": {
                "extraDetail3": "but they should only be used for reference purposes",
                "extraDetail4": "This is not a suitable place to maintain current device state",
                "extraDetail1": "optionalDetailForSkillAdapterToReferenceThisDevice",
                "extraDetail2": "There can be multiple entries"
            }
        },
        "payload": {
            "input": "SATELLITE"
        }
    }
}

I send back the following but Alexa says 'Hmm this device is not responding'

{
    "context": {
        "properties": [
            {
                "namespace": "Alexa.InputController",
                "name": "SelectInput",
                "value": "SATELLITE",
                "timeOfSample": "2017-11-27T15:11:42.574Z",
                "uncertaintyInMilliseconds": 50
            }
        ]
    },
    "event": {
        "header": {
            "namespace": "Alexa.InputController",
            "name": "Alexa.Response",
            "payloadVersion": "3",
            "messageId": "53c9ac3f-d20e-4506-86b3-39ea422633d4-R",
            "correlationToken": "AAAAAAAAAACsqwiAPGRxeyZdhqLHHAfycAEAAAAAAABbsx0W67868BLmmNZ2/e8lXZlF5aGPno+dc7Em6/E3s/HVmWXRVPq4cFARu8F2lqj6C0esvl/1WxSxl5vBMEoG5zmwy8hRyfcrBg8JI3n28ckJPKMt3Y5EAJiIXs8sGMK43z1OkgAgtE20fAs6jL/TVKL5bsw7Vt/hk1cMNXE8pYknxWPBDXqFzX1HzjdD43CWP+g20vc+4TkHFq6Q8f0p2EvXrlQFJEmFXh+yQmXCya16AUbWCLfvCnApzEL0M1iwMIUY+vBOO4MB5mUmGOdZbnfe38nD23pPyD6LDOzkrGOeRvcg6W/v6kwYG9XBm4w8eWU8M8YxlvR+ztNFWk8Igvu+3jcAxwvbsnIz2YN00jVy5XcAE+Z0z6NP9j4QdIHhTHzRI0sSg03ClQoCsSYTdBZr8+x0250mX9SCgTQ/UstCKHK/C/CBRhlGhyjtdGvIS+xgr6srqF8W8go+Gjp5yNNjRP+CVad66I2pmzuoOg=="
        }
    },
    "endpoint": {
        "endpointId": "appliance-001"
    },
    "payload": {}
}

Can anyone see anything wrong with my response?

dairong commented 6 years ago

@Griffinx, I believe the issue is because your response name and namespace are incorrect. They should be Response and Alexa respectively, as per sample code and documentation. Please give those a try, and if it still fails, re-open this issue, thanks!

rclai commented 6 years ago

The reason this was an issue to begin with is probably because the sample javascript code on this page is wrong and reflects the same response namespace and name that OP initially used: https://developer.amazon.com/docs/smarthome/steps-to-build-a-smart-home-skill.html