const INVALID = 'INVALID';

function trigger(user, api, message) {
  // get threadID
  var threadID = message.threadID;
  getThreadUsers(threadID, api, function(info) {
    // get username info
    var nicks = info.nicknames;
    var users = info.participantIDs;

    // check nicknames
    for (var id in nicks) {
      if (nicks[id] == user) {
        //process user
        return;
      }
    }

    // check real names
    getIDFromName(user, users, threadID, api, function(userID) {
      if (userID != INVALID) {
        // process user
        return;
      }
    });
  });
}

function getThreadUsers(threadID, api, callback) {
  api.getThreadInfo(threadID, function(err, info) {
    callback(info);
  });
}

function getIDFromName(user, users, threadID, api, callback) {
  if (!user) return callback(INVALID);
  api.getUserID(user, function(err, data) {
    if (err) return console.log(err);
    for (var id in data) {
      for (var userID in users) {
        if (data[id].userID == users[userID]) return callback(users[userID]);
      }
    }
    return callback(INVALID);
  });
}

module.exports = {
  trigger: trigger
}
@@ -64,61 +64,8 @@
 ) %7B%0A
-  // get threadID%0A  var threadID = message.threadID;%0A
   ge
@@ -105,24 +105,24 @@
 ion(info) %7B%0A
+
     // get u
@@ -298,22 +298,40 @@
     
-//process user
+ping(message.senderID, id, api);
 %0A   
@@ -490,23 +490,44 @@
     
-// process user
+ping(message.senderID, userID, api);
 %0A   
@@ -1029,24 +1029,24 @@
     %7D%0A    %7D%0A
-
     return c
@@ -1072,16 +1072,267 @@
  %7D);%0A%7D%0A%0A
+function ping(pingerID, pingeeID, api) %7B%0A  api.getUserInfo(pingerID, function(err, obj) %7B%0A    if (err) return console.error(err);%0A    msg = %7B%0A      body: obj%5BpingerID%5D.firstName + ' has pinged you!'%0A    %7D;%0A    api.sendMessage(msg, pingeeID);%0A  %7D);%0A%7D%0A%0A
 module.e

Implement ping functionality