I've searched the documentation of Twilio Studio and I haven't found any information about sending Interactive Messages or receiving latitude and longitude from Location Messages. In case of the latter I have found unofficial mentions of location information not being supported in Twilio Studio.
Are interactive messages and location information currently supported in Twilio Studio? If not, are there plans of implementing support for them? Is there a current workaround, specially about obtaining the location information?
Many thanks.
What workarounds I've tried
In the case of the location info:
I've tried running calling a Twilio Function in Studio that receives a location and echoes the coordinates in a reply. The Function connected to the Whatsapp Sandbox by itself works, but when it's called inside the Twilio Flow doesn't.
I assume that the Function cannot access the event parameters when it's called from a Studio Flow.
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.MessagingResponse();
if (!event.Latitude || !event.Longitude) {
twiml.message("Send a location.");
callback(null, twiml);
} else {
const location = {
lat: event.Latitude,
lon: event.Longitude
};
twiml.message(
`${location.lat}, ${location.lon}`
);
callback(null, twiml);
}
};
(The code was originally taken from this tutorial.)
EDIT:
This is quite embarrassing, but I figured how to access the Latitude annd Longitude info.
Simply access the following Liquid variable
{{widgets.send_and_reply_1.inbound.Longitude}}
{{widgets.send_and_reply_1.inbound.Latitude}}
(Change the send_and_reply by the name of the correct node.)
You already answered your question above but for completion, I want to add my two cents too.
Yes, it is possible to send locations, formatted and interactive messages in WhatsApp via the Twilio platform. Here's a link to the respective docs page that contains all the features. Note that this is the docs page of the "WhatsApp Business API with Twilio" and not Studio but the content still applied when Studio handles WhatsApp messaging flow.
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
client.messages
.create({
messagingServiceSid: 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
body: 'This is one of the Twilio office locations',
persistentAction: ['geo:37.787890,-122.391664|375 Beale St'],
to: 'whatsapp:+15005550006'
})
.then(message => console.log(message.sid));
There's also this docs page about using buttons in WhatsApp, which mentions which message types are currently supported. The trick is that you create message templates with the buttons and then you'll use the normal message body in Studio to refer to the template.