Skip to contentSkip to navigationSkip to topbar
On this page

twilio/location


The Twilio/location type allows you to send a location pin and an optional label, which you can use to enhance delivery notifications or provide location information to recipients.

(information)

Info

You can send location templates during an active 24-hour session with the recipient. You can't use them to initiate a business-initiated session.

Location templates aren't supported for approval on WhatsApp and can't be submitted for approval.


Supported channels

supported-channels page anchor

WhatsApp


Content API - Location sample.

longitude:

  • Type: Number
  • Required: Yes
  • Variable Support: No
  • Description: The longitude value of the location pin to send. Value must be between -180.0 and +180.0.

latitude:

  • Type: Number
  • Required: Yes
  • Variable Support: No
  • Description: The latitude value of the location pin to send. Value must be between -90.0 and +90.0.

label:

  • Type: String
  • Required: No
  • Variable Support: Yes
  • Description: Label to be displayed to the recipient alongside the location pin.
Create Location TemplateLink to code sample: Create Location Template
1
// Install the C# / .NET helper library from twilio.com/docs/csharp/install
2
3
using System;
4
using Twilio;
5
using Twilio.Rest.Content.V1;
6
7
TwilioClient.Init(accountSid, authToken);
8
9
// define the twilio/text
10
var twilioText = new TwilioText.Builder();
11
twilioText.WithBody("Owl Air: Time to board, SFO is located at San Francisco International Airport, P.O. Box 8097, San Francisco, CA 94128 ");
12
13
// define the twilio/location
14
var twilioLocation = new TwilioLocation.Builder();
15
twilioLocation.WithLabel("Time to Board @ SFO");
16
twilioLocaiton.WithLatitude(37.62159755922449)
17
twilioLocaiton.WithLongitude(-122.37888566473057)
18
19
// define all the content types to be part of the template
20
var types = new Types.Builder();
21
types.WithTwilioText(twilioText.Build());
22
types.WithTwilioLocation(twilioLocation.Build());
23
24
// build the create request object
25
var contentCreateRequest = new ContentCreateRequest.Builder();
26
contentCreateRequest.WithTypes(types.Build());
27
contentCreateRequest.WithLanguage("en");
28
contentCreateRequest.WithFriendlyName("owl_air_location");
29
30
// create the twilio template
31
var contentTemplate = await CreateAsync(contentCreateRequest.Build());
32
33
Console.WriteLine($"Created Twilio Content Template SID: {contentTemplate.Sid}");

Output

1
{
2
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
3
"date_created": "2022-08-29T15:23:12Z",
4
"date_updated": "2022-08-29T15:23:12Z",
5
"friendly_name": "owl_air_location",
6
"language": "en",
7
"links": {
8
"approval_create": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests/whatsapp",
9
"approval_fetch": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ApprovalRequests"
10
},
11
"sid": "HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
12
"types": {
13
"twilio/location": {
14
"label": "Time to Board @ SFO",
15
"latitude": 37.62159755922449,
16
"longitude": -122.37888566473057
17
},
18
"twilio/text": {
19
"body": "Owl Air: Time to board, SFO is located at San Francisco International Airport, P.O. Box 8097, San Francisco, CA 94128 "
20
}
21
},
22
"url": "https://content.twilio.com/v1/Content/HXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
23
"variables": {}
24
}