How users can send text messages to each other over Twilio

A Twilio app can allow users to have SMS conversations with other users, just like they would have normally on their phone, while still keeping your app involved in the conversation. There are several strategies for achieving this, but we think that the following is the cleanest and easiest to manage technique.

The Scenario

Group Messaging with Twilio

Two users, "Monkey" and "Unicorn" want to be able to send SMS messages back and forth without exposing their real phone numbers to the other user.

First, we will buy a Twilio number. Next we set up our Twilio application so that when Monkey sends an SMS to that particular Twilio number, it forwards the message to Unicorn. We also need to specify in the app's logic that When Unicorn replies to that number, the reply should go to Monkey.

Using this same logic, we can add more Twilio numbers and allow SMS messaging between Monkey and other users, like her friends Pigeon and Owl. When Monkey sends messages to Number A, those messages are forwarded to Unicorn. If Pigeon sends an SMS to Number B, the application realizes that the message is meant for Monkey. If Owl sends a message to Number C, the application knows to forward the message to Monkey.

Scaling the Concept

Twilio Group SMS

But wait! In order for this to work, wouldn't you need thousands of numbers?! One for each pair of friends? Well, not exactly.

While Monkey and Unicorn only ever use a single number to forward their SMS messages to each other, other pairs of friends can use that same number to message each other because the application knows that if the Unicorn sends an SMS message to number A it is meant for Monkey, but if Owl sends an SMS message to number A, that message is meant for Laser Cat.

Scaling this concept will require multiple Twilio numbers, but you will only ever need to have as many numbers as people who a single user can contact. Therefore, if you limit every user to 100 friends in their "address book", you would only ever need 100 numbers, even if you had 100,000 users.

Have more questions? Submit a request
Powered by Zendesk