Build the future of communications.
Start building for free

How to Build A Twilio-Hosted Group Messaging Service with Sync, Functions and SMS


With Twilio’s services you can manage your own group SMS application for Scheduling business meetings, planning wedding activities, parties, or a dinner get together. A friend of mine uses group SMS for family communications among his siblings and parents.

Don’t like Facebook? Or someone you want to include in your group doesn’t use Facebook or WhatsApp? No worries, use SMS. Yes, everyone with a mobile phone has an SMS app because your phone comes with an SMS app. You’re Group SMS app ready for group messaging.

The blog, How To: Set Up SMS Broadcasts in Five Minutes, says, “SMS messages are opened 98% of the time within minutes of being received. When you need to reach your constituents quickly and consistently, there’s no better medium than SMS.”

This blog gives you the configuration steps to communicate quickly and effectively with your friends, colleagues or customers.


The complete implementation is managed using Twilio Console, no developer skills required. After opening an account with Twilio, you would buy a phone number for the group to use. Then you copy and paste code into a new Twilio Function. After the Function is created, create a Messaging Service and a Notify service. And finally, create Sync service to manage the member list. Then your ready for group messaging.

Create a Twilio Function. Click here, to view the code.


Create the messaging components to broadcast member messages: a Copilot Messaging service and a Notify service.

Messaging Service which uses the Function’s URL as the Request URL:

A Notify service which uses the Messaging Service:

A Twilio Sync Service is used to maintain the member database.

Configure your Function to use your Notify and Sync service.

Your ready for group SMS using the components: a phone number, an application program, a messaging and notify service to broadcast, and a database to manage members. All managed from the Twilio Console.

For the detailed configuration steps, go the Owl Group SMS GitHub repository.

Testing your Application

Now that you have Group SMS configured, it’s time to do group SMS. Following are the steps to initiate the group. Then users will subscribe and use the other application commands.

The admin sends a message to the group phone number (example: +12223331234):

!init Harry

Group SMS replies with:

Group phone number initialized and you are subscribed as the admin.

The admin sends a message to the group phone number:


Group SMS replies with:

Help: Text "!subscribe name" to join. "!authorize +PhoneNumber" to accept a new subscriber. "!unsubscribe" to leave the group. "!who" to receive a group list.

Note that Group SMS commands can be in the form of: “!help” or “! help”, with or without a space between “!” and the command.

Someone else sends a message to the group phone number:

!subscribe David

Group SMS replies with:

You are subscribed to this Group's SMS messages.

Group SMS broadcasts to other members:

Application notice, new group subscriber: David.


Note, in this example, members are auto-authorized, as in, new members don’t need to be authorized by a current member.

Another person subscribes:

!subscribe Sally

Group SMS replies with:

You are subscribed to this Group's SMS messages

Group SMS broadcasts to other members:

Application notice, new group subscriber: Sally.

Note, David and Harry receive the broadcast message that Sally has joined.

Sally sends:

Hello all :-)

Group SMS broadcasts to other members:

From: Sally, Hello all :-)

Sally sends:


Group SMS replies with:

Members: David,Harry,Sally

Sally can see that she send the message to David and Harry.

David sends:


Group SMS replies with:

You have been unsubscribed from this group phone number.

Note, no broadcast is sent to let the other members know that David has unsubscribed.

Harry sends:


Group SMS replies with:

Members: Harry,Sally

Harry sends: 

Hello Sally.

Group SMS broadcasts to other members, only Sally at this time:

From: Harry, Hello Sally.

And, if you haven’t watched the movie, you now know how, Harry met Sally.

If you want to turn authorization on, edit your Group SMS Function. Change:

const authorizedDefault = "self";


const authorizedDefault = "new";

Then, when a someone subscribes to the group, the broadcast message will say:

Application notice, new unauthorized group subscriber: David.

Any authorized member can send a message to authorize the new members. For example:

!authorize +17778889999

Where, 17778889999, is the new subscriber's phone number.

If you want to have a second group, buy another Twilio phone, create another Messaging Service using the new phone number, and create a new Notify Service using the new Messaging Service SID. Create another Function that uses the new Notify SID. The new group will use the same Sync service SID as the other group.

To test your new (second) group, go through the above steps using your new phone number. The new group will be initialized and the broadcasts will be separate from the first group’s messages.


You started your Group SMS configuration by setting up an upgraded Twilio account and buying a phone number. Then you added the application program code into a new Twilio Function. You then created the infrastructure to broadcast group messages: a Messaging Service and a Notify Service. Your Group SMS configuration was then complete.

For developers, here is a diagram of the components to broadcast messages, which includes a link to the Twilio Functions application:

Notify Service: name = GroupSMS


Messaging Service: name = GroupSMS

         |      |

         |   Twilio phone number: +12223331234


         Twilio Function: Group SMS


The Sync components are as follows. You created the service and the application creates the Sync Map and the Map items.

Sync Service: name = GroupSMS


Sync Service Map: name = +12223331234


Sample Map items:

key = +12223337777, data = {'name':  'David', 'authorized': ‘admin’ }
key name = +12223337777, data = {'name':  'Sally' , 'authorized': ‘self’ }
key name = +12223338888, data = {'name':  'Harry' , 'authorized': '+12223337777}
key name = +12223339999, data = {'name':  'Stacy', 'authorized': 'new'}

Once configured, the first SMS message, !init David, initialized the group. Then people subscribed and broadcasted messages to the group. You are off to the races.

Feel free to explore this Sync sample programs and other ones not mentioned in this blog post in this example Git code repository.

Sign up and start building
Not ready yet? Talk to an expert.