Closed themessings closed 8 years ago
when testing Lambda I get "Unable to invoke the function because invoke parameters were not valid JSON."
Try validating your json with one of the json lint web sites..
On Saturday, August 15, 2015, themessings notifications@github.com wrote:
when testing Lambda I get "Unable to invoke the function because invoke parameters were not valid JSON."
— Reply to this email directly or view it on GitHub https://github.com/rgraciano/echo-sonos/issues/6#issuecomment-131276569.
Any idea which json file it is referencing?
It must be in the option json
here is what I have but not seeing where the error is. long day
var options = { appid: amzn1.echo-sdk-ams.app.echo, host: host_for_sonos_api, port: 5005 };
module.exports = options;
fixed that one. Now it looks like the json file "index" is not valid.
'use strict';
var http = require('http');
var options = require('./options');
var AlexaSkill = require('./AlexaSkill'); var EchoSonos = function() { AlexaSkill.call(this, options.appid); };
EchoSonos.prototype = Object.create(AlexaSkill.prototype); EchoSonos.prototype.constructor = EchoSonos;
EchoSonos.prototype.intentHandlers = { // register custom intent handlers PlayIntent: function(intent, session, response) { console.log("PlayIntent received"); options.path = '/preset/' + encodeURIComponent(intent.slots.Preset.value); httpreq(options, response, "Playing " + intent.slots.Preset.value); }, PauseIntent: function(intent, session, response) { console.log("PauseIntent received"); options.path = '/pauseall'; httpreq(options, response, "Pausing"); }, VolumeDownIntent: function(intent, session, response) { console.log("VolumeDownIntent received"); options.path = '/groupVolume/-10'; httpreq(options, response, "OK"); }, VolumeUpIntent: function(intent, session, response) { console.log("VolumeUpIntent received"); options.path = '/groupVolume/+10'; httpreq(options, response, "OK"); } };
// Create the handler that responds to the Alexa Request. exports.handler = function(event, context) { // Create an instance of the EchoSonos skill. var echoSonos = new EchoSonos(); echoSonos.execute(event, context); };
function httpreq(options, alexaResponse, responseText) { console.log("Trying http request with responseText " + responseText); http.request(options, function(httpResponse) { console.log(httpResponse.body); if (responseText) alexaResponse.tell(responseText); }).end(); }
What error are you getting exactly? Have you successfully tested your Lamba code using the test function?
no have not got the Lambda code to test successfully.
here is my test code that keep resulting in an error.
{ "session": { "new": true, "sessionId": "session1234", "attributes": {}, "user": { "userId": null }, "application": { "applicationId": "amzn1.echo-sdk-ams.app.823f94bd-4ec5-4af7-ab75-5dd8a5616558" } }, "version": "1.0", "request": { "type": "LaunchRequest", "requestId": "request5678" } }
result is;
{
"errorMessage": "Unexpected token :",
"errorType": "SyntaxError",
"stackTrace": [
"Module._compile (module.js:439:25)",
"Object.Module._extensions..js (module.js:474:10)",
"Module.load (module.js:356:32)",
"Function.Module._load (module.js:312:12)",
"Module.require (module.js:364:17)",
"require (module.js:380:17)",
"Object.
It looks like you're missing the whole request/intent block. You should use https://github.com/rgraciano/echo-sonos/blob/master/lambda/play_intent_testreq.json as a template and drop in your app id
Any idea's on solutions?