function receivedMessage(event) {
        var senderID = event.sender.id;
        var recipientID = event.recipient.id;
        var timeOfMessage = event.timestamp;
        var message = event.message;

        console.log("Received message for user %d and page %d at %d with message:", 
        senderID, recipientID, timeOfMessage); 

        var messageId = message.mid;
        var messageText = message.text;
        console.log(typeof messageText !== 'undefined');
        if(typeof messageText !== 'undefined') {                //If the message contains text and not a gif or attachment
                console.log("Before parsing the message is: " + messageText);           //Log what the message is before and after parsing
                messageText = parseInt(messageText.replace ( /[^0-9]/g, ""));           //Takes out everything but the number
                console.log("After parsing the message is: " + messageText);
                if(messageText) {                                                       //If the message is a number send route to dublin bus system                                                    
                        sendBusStopInfo(messageText,senderID);                  //Otherwise we are good to go                       
                } 
                else { 
                        console.log("Non bus stop number received, requested bus stop number.");        //If NaN
                        sendTextMessage(senderID, "Hi welcome to the Irish BusBot. To begin please enter your Bus Stop ID number. This can be found at the stop itself (usually a 6 digit number like  555411) or on http://www.rtpi.ie/ (where this bot gets its data). Bus Eireann, Luas & Dublin bustimes are currently advailable. Please enter a valid bus stop number");            //If we receive just a string with no number this should occur
                }
        }
        else {
                console.log("Non bus stop number received, requested bus stop number.");        //If no text is sent but instead a gif or other attachment
                sendTextMessage(senderID, "Hi welcome to the Irish BusBot. To begin please enter your Bus Stop ID number. This can be found at the stop itself (usually a 6 digit number like  555411) or on http://www.rtpi.ie/ (where this bot gets its data). Bus Eireann, Luas & Dublin bus times are currently advailable. Please enter a valid bus stop number.");
        }                
}
/*
        This is a function which will interpret a message received. The time of message and sender Id is logged in case of an error.
        If the message contains a gif or attachment, a response is sent to the user stating it is not a valid bus stop number.
        Otherwise if the message contains text, the message is logged before parsing the number and after parsing for troubleshooting purposes 
        If the message if not a number send a response to the user requesting a valid bus stop number
        Otherwise if the message is a number, use the sendBusStopInfo() function to check the number with the RTPI
*/
This is a function which will interpret a message received. The time of message and sender Id is logged in case of an error.
If the message contains a gif or attachment, a response is sent to the user stating it is not a valid bus stop number.
Otherwise if the message contains text, the message is logged before parsing the number and after parsing for troubleshooting purposes
If the message if not a number send a response to the user requesting a valid bus stop number
Otherwise if the message is a number, use the sendBusStopInfo() function to check the number with the RTPI
This is a function which will interpret a message received . The time of message and sender Id is logged in case of an error . If the message contains a gif or attachment a response is sent to the user stating it is not a valid bus stop number . Otherwise if the message contains text the message is logged before parsing the number and after parsing for troubleshooting purposes If the message if not a number send a response to the user requesting a valid bus stop number Otherwise if the message is a number use the sendBusStopInfo () function to check the number with the RTPI
function receivedMessage(event) {
        var senderID = event.sender.id;
        var recipientID = event.recipient.id;
        var timeOfMessage = event.timestamp;
        var message = event.message;
        console.log("Received message for user %d and page %d at %d with message:", 
        senderID, recipientID, timeOfMessage); 
        var messageId = message.mid;
        var messageText = message.text;
        console.log(typeof messageText !== 'undefined');
        if(typeof messageText !== 'undefined') {                
                console.log("Before parsing the message is: " + messageText);           
                messageText = parseInt(messageText.replace ( /[^0-9]/g, ""));           
                console.log("After parsing the message is: " + messageText);
                if(messageText) {                                                       
                        sendBusStopInfo(messageText,senderID);                  
                } 
                else { 
                        console.log("Non bus stop number received, requested bus stop number.");        
                        sendTextMessage(senderID, "Hi welcome to the Irish BusBot. To begin please enter your Bus Stop ID number. This can be found at the stop itself (usually a 6 digit number like  555411) or on http://www.rtpi.ie/ (where this bot gets its data). Bus Eireann, Luas & Dublin bustimes are currently advailable. Please enter a valid bus stop number");            
                }
        }
        else {
                console.log("Non bus stop number received, requested bus stop number.");        
                sendTextMessage(senderID, "Hi welcome to the Irish BusBot. To begin please enter your Bus Stop ID number. This can be found at the stop itself (usually a 6 digit number like  555411) or on http://www.rtpi.ie/ (where this bot gets its data). Bus Eireann, Luas & Dublin bus times are currently advailable. Please enter a valid bus stop number.");
        }                
}
function receivedMessage ( event ) { var senderID = event . sender . id ; var recipientID = event . recipient . id ; var timeOfMessage = event . timestamp ; var message = event . message ; console . log ( "Received message for user %d and page %d at %d with message:" , senderID , recipientID , timeOfMessage ) ; var messageId = message . mid ; var messageText = message . text ; console . log ( typeof messageText !== 'undefined' ) ; if ( typeof messageText !== 'undefined' ) { console . log ( "Before parsing the message is: " + messageText ) ; messageText = parseInt ( messageText . replace ( / [^0-9] / g , "" ) ) ; console . log ( "After parsing the message is: " + messageText ) ; if ( messageText ) { sendBusStopInfo ( messageText , senderID ) ; } else { console . log ( "Non bus stop number received, requested bus stop number." ) ; sendTextMessage ( senderID , "Hi welcome to the Irish BusBot. To begin please enter your Bus Stop ID number. This can be found at the stop itself (usually a 6 digit number like  555411) or on http://www.rtpi.ie/ (where this bot gets its data). Bus Eireann, Luas & Dublin bustimes are currently advailable. Please enter a valid bus stop number" ) ; } } else { console . log ( "Non bus stop number received, requested bus stop number." ) ; sendTextMessage ( senderID , "Hi welcome to the Irish BusBot. To begin please enter your Bus Stop ID number. This can be found at the stop itself (usually a 6 digit number like  555411) or on http://www.rtpi.ie/ (where this bot gets its data). Bus Eireann, Luas & Dublin bus times are currently advailable. Please enter a valid bus stop number." ) ; } }
This is a function which will interpret a message received.
This is a function which will interpret a message received .
//If the message contains text and not a gif or attachment //Log what the message is before and after parsing //Takes out everything but the number //If the message is a number send route to dublin bus system                                                     //Otherwise we are good to go                        //If NaN //If we receive just a string with no number this should occur //If no text is sent but instead a gif or other attachment