var slackToken = process.env.HUBOT_SLACK_VERIFY_TOKEN;

module.exports = function(robot)  {

  robot.router.post('/hubot/trello', function(req, res){
    var data = null;
    res.send('hello there');
    console.log("\n*********\n");
  });


  robot.router.post('/hubot/slack-msg-callback', function(req, res) {
    var data = null;

    if(req.body.payload) {
      try {
        data = JSON.parse(req.body.payload);
      } catch(e) {
        robot.logger.error("Invalid JSON submitted to Slack message callback");
        //res.send(422)
        res.send('You supplied invalid JSON to this endpoint.');
        return;
      }
    } else {
      robot.logger.error("Non-JSON submitted to Slack message callback");
      //res.send(422)
      res.send('You supplied invalid JSON to this endpoint.');
      return;
    }

    if(data.token === slackToken) {
      robot.logger.info("Request is good");
    } else {
      robot.logger.error("Token mismatch on Slack message callback");
      //res.send(403)
      res.send('You are not authorized to use this endpoint.');
      return;
    }

    var msg = 'slack:msg_action:'; 
    var callback_id = data.callback_id;
    console.log(data);
    var handled = robot.emit(msg+callback_id, data, res);
    if (!handled) {
      //res.send(500)
      res.send('No scripts handled the action.');
    }
  });
}

@@ -1170,30 +1170,358 @@
     
-console.log(data);%0A   
+var response_url = data.response_url;%0A    console.log(data.response_url);%0A    var slackMsg = require('./slackMsgs');%0A    var response = slackMsg.basicMessage();%0A%0A    robot.http(response_url)%0A    .header('Content-Type', 'application/json')%0A    .post(response)(function(err, res, body) %7B%0A      console.log('http')%0A      console.log(err)%0A    %7D);%0A%0A    //
  var
@@ -1574,16 +1574,19 @@
 es);%0A   
+ //
  if (!ha
@@ -1594,26 +1594,29 @@
 dled) %7B%0A    
+//
   
+ 
 //res.send(5
@@ -1618,24 +1618,27 @@
 end(500)%0A   
+ //
    res.send(
@@ -1675,16 +1675,19 @@
 .');%0A   
+ //
  %7D%0A  %7D);

update slack callback