var express = require('express');
var router = express.Router();

// instantiate twilio
var twilio = require('twilio');
var accountSid = process.env.twilio_id;
var authToken = process.env.twilio_key;
var client = new twilio.RestClient(accountSid, authToken);


router.get('/', function(req, res, next) {
  res.send('Only Post requests accepted');
});

router.post('/', function(req, res, next) {
  console.log(req.body);
  console.log(req.body.Body);

  sendMessage('+13604640368', req.body.Body)
  res.send('ok');
});

module.exports = router;


function sendMessage(recipient_number, message) {
  client.messages.create({
      body: message,
      to: recipient_number,  // Text this number
      from: '+16504450791' // From a valid Twilio number
  }, function(err, message) {
      console.log(message.sid);
  });

}

@@ -410,93 +410,112 @@
 (req
-.body);%0A  console.log(req.body.Body);%0A%0A  sendMessage('+13604640368', req.body.Body
+);%0A  // data = parseIncomingMessage(req)%0A  // response =%0A%0A%0A  // sendMessage(data.content, response
 )%0A 
+ //
  res
@@ -558,16 +558,339 @@
 outer;%0A%0A
+// input = incoming post request%0A// output = %7Bcontent: 'content text', number: '+13604540021'%7D%0Afunction parseIncomingMessage(req)%7B%0A  textContent = req.body.Body;%0A  textFromNumber = req.body.From;%0A  return %7Bcontent: textContent, number: textFromNumber%7D%0A%7D%0A%0A%0A// input = number, message%0A// output = sends message via twilio API
 %0Afunctio

test log of photo being sent