The Twilio API for WhatsApp supports sending and receiving GPS location data in messages to WhatsApp users. This guide explains how it's done.
Send location data
You can send a location in a Session message by including the PersistentAction
parameter in your API requests. In these location messages, the message body will be used as the name of the location. You can also include an optional label. Here are usage examples:
Send location | PersistentAction=geo:{latitude},{longitude} |
Send location w/label | PersistentAction=geo:{latitude},{longitude}|{label} |
For full details and code samples, see Location Messages with WhatsApp (Twilio Docs).
Notice: Location sending is currently only supported in Session Messages. Location cannot be included on a Template message.
Receive location data
End users can also send a location message to your Twilio WhatsApp number. This data will be included in the HTTP POST request for the incoming message that we send to your webhook.
It is important to note that this location data is not available via a REST API fetch request to the Message resource at a later time. Later attempts to fetch location via the API will result in receiving an empty location, which can be expected.
The following additional parameters are added to incoming location messages:
Latitude
Longitude
Address
Label
Notice: Location data from messages is not visible in Console at this time.