var commonBots = {};    
(function (commonBots) {
    // get sender id of facebook bot
    commonBots.getSenderId = function(botEvent){
        var senderId = '';
        if(botEvent.entry){
            botEvent.entry.forEach(function(event){
                event.messaging.forEach(function(msg){
                    if(msg.sender && msg.sender.id){
                        senderId = msg.sender.id;
                    }
                });
           });
        } 
        return senderId;
    }

    // get message time of facebook bot
    commonBots.getEventTime = function(botEvent){
        var time = 0;
        if(botEvent.entry){
            botEvent.entry.forEach(function(event){
                time = parseInt(parseInt(event.time)/1000);
           });
        } 
        return time;
    }

}(commonBots));

module.exports = commonBots;

