title: Simple example on how to receive an AWS IOT topic on a Raspberry Pi
body: <p>I'm looking for a <em>simple</em> JavaScript example of how to receive messages from a topic. I'm trying to create a Build Cop using CodeBuild, Lambda, SNS, and finally, IoT. I've successfully published messages to the topic, but I can't for the life of me figure out what to do to receive the message.</p>
  
  <p>The examples in the SDK are not well-documented (to me at least) and I can't figure out which import to use or why, and how to subscribe to a simple topic.</p>
  
  <p>The code to <em>send</em> the message to the thing is the following. I'm sending it from a Lambda. The code is written in TypeScript, but I'm copying and pasting the transpiled JavaScript into the console since it does not seem to support TypeScript natively.</p>
  
  <pre><code>const params = {
    topic: 'topic/buildcop',
    payload: color,
    qos: 1
  };
  
  
  this.iotdata.publish(params, function(err, data){
    if(err){
      console.log(`error: ${err}`);
    }
    else{
      console.log("success?");
      //context.succeed(event);
    }
  });
  </code></pre>