I have a serverless function that is executed when an user sends a message through whatsapp, if the user sends a fixed location, the function get it's latitude and longitude and returns an object on the callback with the location info. I want to make the function run and redirect to a studio flow that is integrated with flex through proxy so I can handle the user's location there and eventually send to a flex agent.
This is the function I have:
exports.handler = function(context, event, callback) {
console.log("lat: ", event.Latitude);
console.log("lon: ", event.Longitude);
if (!event.Latitude || !event.Longitude) {
callback(null, {
lat: null,
lon: null
});
} else {
const location = {
lat: event.Latitude,
lon: event.Longitude
};
callback(null, location);
}
};
I'm using WhatsApp Sandbox with the above function being called on "when a message comes in". After the function executes I want it to redirect to a Studio Flow (inside the function), is that possible? How can I do it? I'm a beginner dev and new to Twilio.