Skip to contentSkip to navigationSkip to topbar
On this page

twilio/location


Twilio/location type contains a location pin and an optional label, which can be used to enhance delivery notifications or connect recipients to physical experiences you offer.

(information)

Info

Location templates are only available once the end user is in a 24 hr session. They can not initiate a business initiated session.

Location templates are not 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: numbers
  • Required: yes
  • Variable Support: no
  • Description: The longitude value of the location pin you want to send. Value must be between [-90.0, +90.0]

latitude:

  • Type: numbers
  • Required: yes
  • Variable Support: no
  • Description: The latitude value of the location pin you want to send. Value must be between [-180.0, +180.0]

label:

  • Type: string
  • Required: no
  • Variable Support: yes
  • Description: Label to be displayed to the end user 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
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.