var plivo = require('plivo-node');
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var path = require('path');

/**
 * serve static
 */
app.use(express.static('dist'));
app.use(bodyParser.urlencoded({ extended: false })); // Required for parsing POST
app.use(bodyParser.json()); // parse application/json

/** SMS received **/
app.post('/ld36/sms', function(req, res) {
    console.log(req.body);
    var sender = req.body["From"];
    var senderMessage = req.body['Text'];

    var r = plivo.Response();
    var smsOptions = {};

    // Pete's Ext
    if (senderMessage == 'A382' || senderMessage == 'a382') {
      smsOptions.text = "x843p_33.32.12.txt.hex";
    }

    // Sara's Ext
    else if (senderMessage == 'DV47' || senderMessage == 'dv47') {
      smsOptions.text = 'x666p_66.66.66.txt.hex';
    }

    // Marshall's Ext
    else if (senderMessage == '43E0' || senderMessage == '43e0') {
      smsOptions.text = 'x448p_21.21.21.txt.hex';
    }

    // Dr. Destin's Ext
    else if (senderMessage == '88Z2' || senderMessage == '88z2') {
      smsOptions.text = 'x903p_48.83.52.txt.hex';
    }


    else {
      smsOptions.text = "Network Engineers Frontier SMS Gateway. Reply with your extension."
    }

    smsOptions.src = 15092625208;
    smsOptions.dst = sender;
    console.log(r.toXML());

    r.addMessage(smsOptions);
    res.set({
        'Content-Type': 'text/xml'
    });
    res.end(r.toXML());

});


app.post('/ld36/marshall.smith/hangup/', function(req, res) {
  //console.log('hangup check');
  //console.log(req.query);
  var hangup = req.params['HangupCause'];
  var id = req.params['CallUUID'];

  if (hangup) {
      console.log("This call is done! call id: "+id+" HangupCause: "+hangup);
  }

  return res.status(200).send('THANKS FOR LETTING ME KNOW');
});

app.listen(process.env.PORT || 5000);
console.log('listening on %s', process.env.PORT || 5000);

@@ -664,29 +664,32 @@
   smsOptions
-.
+%5B'
 text
+'%5D
  = %22x843p_33
@@ -809,29 +809,32 @@
   smsOptions
-.
+%5B'
 text
+'%5D
  = 'x666p_66
@@ -958,29 +958,32 @@
   smsOptions
-.
+%5B'
 text
+'%5D
  = 'x448p_21
@@ -1113,21 +1113,24 @@
 sOptions
-.
+%5B'
 text
+'%5D
  = 'x903
@@ -1189,13 +1189,16 @@
 ions
-.
+%5B'
 text
+'%5D
  = %22
@@ -1290,12 +1290,15 @@
 ions
-.
+%5B'
 src
+'%5D
  = 1
@@ -1327,12 +1327,15 @@
 ions
-.
+%5B'
 dst
+'%5D
  = s
@@ -1344,36 +1344,8 @@
 der;
-%0A    console.log(r.toXML());
 %0A%0A  
@@ -1372,16 +1372,45 @@
 tions);%0A
+    console.log(r.toXML());%0A%0A
     res.

switch object form