I am using Node JS + twilio API to get whatsapp messages from a bot. Right now I am trying to get the GPS location sent by the user, but it does not appear in the body of the message, while in the SMS version, it does.
//Import model
const WhatsappTwilio = require('../models/WhatsappModel');
exports.postWhatsapp = (req, res, next) => {
const Body = req.body.Body;
const From = req.body.From;
const To = req.body.To;
const whatsappTwilio = new WhatsappTwilio({
Body: Body,
From: From,
To: To
});
let responseMsg = '';
if (Body.includes('http://maps.google.com/maps')) {
responseMsg ='Location received';
} else {
responseMsg ='Error, could not get location';
}
//Response through twilio whatsapp
client.messages
.create({
body: responseMsg ,
from: 'whatsapp:' + To,
to: 'whatsapp:' + From
})
.then(message => console.log(message.sid));
};
This is the controller that handles the whatsapp bot, in the SMS version it works, but in the whatsapp version it does not.