Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Using Messaging Services with Content Template Builder


Using a Messaging Service is not only a prerequisite of using the Content Templates, but also a great tool to organize your account and reduce complexity as your messaging application grows. To learn more about Messaging Services, click here. To create a messaging service, navigate to the Messenger section of your console.

MSGSER1.

Send Messages with a Messaging Service in the "From" field

send-messages-with-a-messaging-service-in-the-from-field page anchor

There are multiple ways to send a template created with the Content Template Builder. One way is to add a Sender to a Messaging Service's Sender Pool and specify the Messaging Service Sid (MGXXXX...XXXX) in the send request's "From" field.

How to Add Channel Specific Senders to a Sender Pool

how-to-add-channel-specific-senders-to-a-sender-pool page anchor

To add a specific channel's sender to a Messaging Service's Sender Pool, go to the Messaging Service and click edit. In the edit screen, there is a "Sender Pool" Section with the following options to add.

  1. Phone Number
  2. Short Code
  3. Alpha Sender
  4. WhatsApp Number
  5. Facebook Messenger (Public Beta) - If you do not see this option, file a support ticket asking to enable the feature for your account: Enable the FBM messaging service setting to add FBM Senders to your existing Messaging Service. For more information read our Facebook Messenger documentation .
MSGSER2.

How to Send Messages with a Messaging Service in the 'From' field

how-to-send-messages-with-a-messaging-service-in-the-from-field page anchor

On Whatsapp

curl

_10
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages \
_10
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN \
_10
-H 'Content-Type: application/x-www-form-urlencoded' \
_10
-d "To=whatsapp:+1XXXXXXXXXX" \
_10
-d "From=MGXXXXXXXXXXXXXXXXXXX" \
_10
-d "ContentSid=HXXXXXXXXXXXXXXXXXXX" \
_10
-d 'ContentVariables={"1":"Name"}'

Output

_27
<?xml version='1.0' encoding='UTF-8'?>
_27
<TwilioResponse>
_27
<Message>
_27
<Body></Body>
_27
<NumSegments>0</NumSegments>
_27
<Direction>outbound-api</Direction>
_27
<From/>
_27
<DateUpdated>Mon, 29 Aug 2022 18:40:01 +0000</DateUpdated>
_27
<Price/>
_27
<ErrorMessage/>
_27
<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages/MMXXXXXXXXXXXXXXXXXX</Uri>
_27
<AccountSid>ACXXXXXXXXXXXXXXXXXXX</AccountSid>
_27
<NumMedia>0</NumMedia>
_27
<To>whatsapp:+17604209954</To>
_27
<DateCreated>Mon, 29 Aug 2022 18:40:01 +0000</DateCreated>
_27
<Status>accepted</Status>
_27
<Sid>MMXXXXXXXXXXXXXXXXXX</Sid>
_27
<DateSent/>
_27
<MessagingServiceSid>MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</MessagingServiceSid>
_27
<ErrorCode/>
_27
<PriceUnit/>
_27
<ApiVersion>2010-04-01</ApiVersion>
_27
<SubresourceUris>
_27
<Media>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages/MMXXXXXXXXXXXXXXXXXX/Media</Media>
_27
</SubresourceUris>
_27
</Message>
_27
</TwilioResponse>


Send Messages with a Phone Number in the "From" field

send-messages-with-a-phone-number-in-the-from-field page anchor

Another way to send messages is to use the phone number in the from field and specify a MessagingServiceSid field. This allows you to dedicate a "From" field for compliance or any other reason. If you would like to utilize this method, you do not have to add the channel sender to the messaging service's sender pool, but a valid messaging service is still required.

How to Send Messages Without a Messaging Service in the 'From' field

how-to-send-messages-without-a-messaging-service-in-the-from-field page anchor

On Whatsapp

curl

_10
curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages \
_10
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN \
_10
-H 'Content-Type: application/x-www-form-urlencoded' \
_10
-d "To=whatsapp:+15551234567" \
_10
-d "MessagingServiceSid=MGXXXXXXXXXXXXXXXXXXX" \
_10
-d "From=whatsapp:+15559991111" \
_10
-d "ContentSid=HXXXXXXXXXXXXXXXXXXX" \
_10
-d 'ContentVariables={"1":"ABC123"}'

Output

_27
<?xml version='1.0' encoding='UTF-8'?>
_27
<TwilioResponse>
_27
<Message>
_27
<Body></Body>
_27
<NumSegments>0</NumSegments>
_27
<Direction>outbound-api</Direction>
_27
<From>whatsapp:15559991111</From>
_27
<DateUpdated>Mon, 17 Oct 2022 21:50:25 +0000</DateUpdated>
_27
<Price/>
_27
<ErrorMessage/>
_27
<Uri>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages/MMXXXXXXXXXXXXXX</Uri>
_27
<AccountSid>ACXXXXXXXXXXXXXXXXXXX</AccountSid>
_27
<NumMedia>0</NumMedia>
_27
<To>whatsapp:+15551234567</To>
_27
<DateCreated>Mon, 17 Oct 2022 21:50:25 +0000</DateCreated>
_27
<Status>accepted</Status>
_27
<Sid>MMXXXXXXXXXXXXXX</Sid>
_27
<DateSent/>
_27
<MessagingServiceSid>MGXXXXXXXXXXXXXXXXXX</MessagingServiceSid>
_27
<ErrorCode/>
_27
<PriceUnit/>
_27
<ApiVersion>2010-04-01</ApiVersion>
_27
<SubresourceUris>
_27
<Media>/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages/MMXXXXXXXXXXXXXX/Media</Media>
_27
</SubresourceUris>
_27
</Message>
_27
</TwilioResponse>


Rate this page: