New feature: Message Routes

Telerivet has always made it easy to connect multiple phones to your Telerivet account, whether you’re sending messages to multiple countries, taking advantage of in-network SMS rates, or sending more messages than a single phone can handle.

We know that being able to send messages from multiple phones gives you more flexibility and reliability with your communications. But it has required manual effort to choose the right phone to send each message.

So we’re happy to announce our new, long-awaited Message Routes feature!

Any Telerivet user with more than one phone connected to their Telerivet account can now easily create custom routing rules to determine which phone to use to send each message. Whether you utilize Android phones, virtual numbers, or a combination, it’s now easy to choose which phones send which messages.

Here are our top three reasons why you should try out Message Routes:

1. Make your SMS sending more reliable

 If some of your Android phones are disconnected, Message Routes can send messages using any active phones. And if one of your phones has an error sending a message, Telerivet can automatically transfer the message to another phone.

2. Decrease your SMS costs

If it’s cheaper to send an SMS message to another phone on the same mobile network, you can easily use phones on different mobile networks to send messages to different contacts.

3. Send more messages than a single phone can handle

 Message Routes can automatically distribute messages among multiple phones. If your phoneshave a lot of queued messages, Telerivet can automatically choose the phone with the shortest queue.

Better yet, Message Routes work everywhere in Telerivet, including Telerivet’s web app, automated services, and the developer API.

Sounds pretty great, right? When you’re ready to try it out, here’s how to do it.


Creating Routes

In your Telerivet project, go to the Phones page, and click on the "Routes" tab. Then click the "Add new route" button to set up your routing rules.

If you’ve used Telerivet’s Rules Engine, then you already know how to create a Message Route. Each message route is just a collection of one or more “rules” —  either an “if … then …” condition, or a rule choosing the phone(s) that can be used to send the message.

Depending on what you want your Message Route to accomplish, you can add rules in different ways. Below we’ll describe how to create two different types of Message Routes: Load-balancing routes, and Least-cost routes.


1. Load-balancing routes – Distributing messages among multiple phones

To create routes that distribute messages among multiple phones, all you need to do is click “Add rule…” and click "Choose phone(s) to send message":



Then add all the phones you want to use. Click the (+) button on the right hand side to add more phones:



That’s it! Just click “Save route” and you’re done.

Now, when you use this route to send messages, Telerivet will automatically distribute messages among all the of phones you list:

So, how does Telerivet choose which phone to use for each message? When you send a message, Telerivet calculates a numeric score for each phone in the list, and then chooses the phone with the highest score.

Curious how Telerivet calculates the score? Here’s how we do it:

1. If the phone has connected to Telerivet’s servers in the past half-hour (+1000 points)

 2. The number of errors sending messages in the past hour (-5 points per failure)

 3. The number of messages waiting to be sent (-1 point per queued message)

 If multiple phones have the same score, then Telerivet will just choose a phone at random.

If a phone tries to send a message and it fails (e.g. if airtime runs out on one of your phones), Telerivet will also retry sending the message via another phone in the list.

By creating a route with multiple phones, it’s easy to send SMS reliably, even if some of your phones are temporarily out-of-order.


2. Least-Cost Routing — Using different phones to send SMS to different contacts

The other big use case for Message Routes is when you want to send messages to different contacts using different phones.

To create a Message Route with this behavior, start by creating an "if … then …" condition for each of your phones, and then add a "Choose phone(s) to send message" rule underneath each one:




The next step is to actually define each of the if/then conditions, to specify which messages get sent via which phones. There are a few different ways you could do that:


Option 1. Look at first digits of the phone number:




Option 2. Create a custom variable for each of your contacts:



Option 3. Add contacts to a group:




If you can determine which phone to use from the first digits of the phone number, that’s usually the easiest option, since you don’t need manually import or organize your contacts.

It's possible to create a route that doesn't assign every phone number to a phone. If you try to send a message that is not routed to any phone, you'll just get an error message.


Using your routes

Once you’ve created your routing rules, using them is easy. After you create a route, it will show up anywhere in Telerivet where you select a phone to send a message:




If you click the "Set as default route when sending messages" checkbox when creating or editing your route, then it will be selected by default.

You can use custom routes on the Messages page, in polls, in the rules engine, and even in the Developer API.

To use your routes in the Developer API, visit the API page for your project to get the Route ID. Any time you send a message from the API, simply use your Route ID for the phone_id parameter. See API documentation.


Overriding the default route for each contact

Like before, there is also the ability to override the default route for each contact, but now you can also disable that functionality.

On your project settings page, there is now a checkbox labeled "Allow customizing sender phone for each contact":



If this setting is enabled, then you can set the "Default Sender Phone" (or route) separately for each contact, the route selected by default will show up as "Default phone" — which just means to use the default phone (route) for each contact.

For backwards compatibility, existing projects with multiple phones have this setting enabled by default, but new projects will not. So if you don’t need to have a different default route for each contact, you might want to disable this setting.

Try out the message routes feature and let us know what you think!