I've created a simple skill for Alexa based on this example: https://github.com/alexa/skill-sample-nodejs-fact/blob/en-US/lambda/custom/index.js

Now, I'd like the script to log something on a different server when GetNewFactIntent is called.

This is what I'm trying to do but have an issue with this which is not what it should be in the http.get callback.

    'GetNewFactIntent': function () {
    //var thisisit = this;
    http.get("http://example.com", function(res) {
      //console.log("Got response: " + res.statusCode);
      const factArr = data;
      const factIndex = Math.floor(Math.random() * factArr.length);
      const randomFact = factArr[factIndex];
      const speechOutput = GET_FACT_MESSAGE + randomFact;

      this.response.cardRenderer(SKILL_NAME, randomFact);
    }).on('error', function(e) {
      //console.log("Got error: " + e.message);

What this needs to be replaced with in the example above for this to work?

  • 2
    While IoT related I think you'll get a better response asking this on Stack Overflow – hardillb Nov 10 '17 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.