fason avatar image
fason asked

What does alexa see as valid response? (The response is invalid)

Having issues making a REST call to an API between a node.js Lambda function and Alexa. I'm using the request library to make the calls with an account linked skill. I've only set one sample utterance for the intent, and the simulator see this fine.

Also, the cloudwatch logs show a 200 response code from the api endpoint and any of the returned data from the API from console.logs to CW.

'use strict';
var http = require('http');
var request = require('request');
var Alexa = require('alexa-sdk');

exports.handler = function(event, context, callback) {
    var alexa = Alexa.handler(event, context);
    alexa.appId = APP_ID;

var handlers = {
   'LaunchRequest': function () {
        this.emit(':tell', 'Hi!');

   'ApiWelcomeIntent': function () {
        request('https://some.web/api', function (error, response, body) {
            if (!error && response.statusCode == 200) {
            // from within the callback, write data to response, essentially returning it.
                var speechOutput = JSON.stringify(body);
                console.log(body + " :Raw output?");
                console.log(speechOutput + ' :JSON stringified');
                this.emit(':tell', speechOutput);
            } else {
                console.log(error + ' : ' + response.statusCode);
                this.emit(':tell', 'There was an error');

    'AMAZON.HelpIntent': function () {} //.........And other built in intents.


This is the skill in its basic form, with one custom intent. the Api server is in my domain so i can clearly see the 200 status and that my express.js api logs the URI path access as expected.

Its just what seems like formatting the response correctly but what ever I try it fails at this point. Even after reading countless examples and the Alexa docs I cant seem to find an answer.

alexa skills kitskilllambdanode_js
1.png (61.2 KiB)
2.png (23.3 KiB)
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Brian@Amazon avatar image
Brian@Amazon answered

Hi can you go into lambda or your webservice, make a request with the json from the service request tab, and paste that here for us to look at?

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.