I am currently writing multiple skills to enable Misty to get past doors by interacting with humans. Long story short the current objective is, that Misty recognizes the door using Azure Custom Vision. Everything works perfectly fine apart from one thing: When passing the response to Misty I should in theory have a JSON that I can then go into to extract the information I want. This is not possible as one of two things happens, either the value of the called field is undefined or it doesn’t even give anything to misty.Debug() and no output happens at all. I have yet to find any logic behind what happens when.
I am using a Node Server as middleware since as I need to format the request to Azure somewhat. After receiving the answer from Azure I use a callback function like so:
callback({
"doorState": JSON.parse(responseData).predictions[0].tagName,
"probability": JSON.parse(responseData).predictions[0].probability
});
And the callback function within the skill in Misty looks like follows:
function _SendExternalRequest(data) {
// Parse response to variable as JSON
_data = data.Result.ResponseObject.Data;
misty.Debug(_data);
};
This works perfectly fine and I get the expected output of { doorState: “closed”, probability: 0.856167513 }.
Now the problem is, when I try to access a field of the JSON. If I’m not mistaken
function _SendExternalRequest(data) {
// Parse response to variable as JSON
_data = data.Result.ResponseObject.Data;
misty.Debug(_data.doorState);
};
should return “closed”. Yet it returns undefined. The same happens when I stringify the response on the server and parse it again in the skill (as it should). Any other JSON works perfectly fine and I can go into it no problem. I have also tried the tutorial with weatherstack and it works perfectly as well.
Is there anything I’m missing here? I have tried sending simple JSONs like
callback('{"name":"John", "lastName":"Smith"}');
but the result stays the exact same. As far as I can tell the problem should be something on the Misty side, but I’m at a complete loss as the exact same thing worked flawlessly in the SendExternalRequest tutorial.