title: Need help publishing to IoT topic using Lambda and node Js
body: <p>I'm trying to control my raspberry using Amazon Alexa, IoT and Lambda.
  What I got working so far:</p>
  
  <ul>
  <li>Setting up raspberry as IoT device and being able to publish and subscribe to a topic (Testes using the IoT Client)</li>
  <li>Setting up a test lambda node.js script</li>
  <li>Setting up a test Alexa Skill that triggers an intent in my lambda script</li>
  </ul>
  
  <p>Here's the intent handling in my node.js script:</p>
  
  <pre><code>switch(event.request.intent.name) {
        case "testone":
          var config = {};
          config.IOT_BROKER_ENDPOINT      = "restAPILinkFromIoT".toLowerCase();
          config.IOT_BROKER_REGION        = "us-east-1";
  
          //Loading AWS SDK libraries
          var AWS = require('aws-sdk');
          AWS.config.region = config.IOT_BROKER_REGION;
          var iotData = new AWS.IotData({endpoint: config.IOT_BROKER_ENDPOINT});
          var topic = "/test";
          var output = "test output without publish"
          var params = {
              topic: topic,
              payload: "foo bar baz",
              qos:0
          };
          iotData.publish(params, (err, data) =&gt; {
              if (!err){
                 output = "publish without error"
                  this.emit(':tell', tell);
              } else {
                  output = err
              }
          });
          context.succeed(
                generateResponse(
                  buildSpeechletResponse(output, true),
                  {}
                )
              )
          break;
          ...
  </code></pre>
  
  <p>Basically the script should either return "publish without error" or the error message. The Problem it always returns "test output without publish". It seems like the publish function (or at least the callback function) is never triggered. I also don't see a message in the topic.</p>
  
  <p>Am I doing something wrong? </p>
  
  <p>Thanks in advance!</p>