Sending SMS through Twilio -- where specific account info?

Hi all – this question is a little embarrassing because it’s so simple.

My app, here in Thailand, has already been successfully sending SMSs for a long time. But when we set it up originally, we used the Telerivet android gateway.

But now I want to change things to use Twilio instead. So I am trying to set up sending through Twilio.

My problem is, I looked through the CommCare help documents, and all I can find to do is just select “MOBILE_BACKEND_TWILIO” in the SMS connectivity page. That is great, but I can not find any place to set up my own specific account information so it knows my specific Twilio account to send through (and charge money through)!

For example, over in Twilio, I can see my Account SID, and my Auth token, etc. How do I tell commcare that info so it knows to send via my own Twilio account?

Or maybe I am thinking about this wrong, and you always use one central acccount? *** But… that would feel weird, because with Telerivet I had to tell it about my Telerivet account…

Thanks!
Eric

Hi Eric,

Before I address your question I’d just like to understand a little bit better why you’d like to switch.

If you’re still sending SMS to recipients in Thailand, you will likely get better SMS delivery rates using Telerivet because the SMS are sent over a local phone number. Using Twilio may work for now, but if your recipients are in Thailand it requires sending SMS internationally because Twilio doesn’t currently provide local Thai numbers over which to send SMS. And sending SMS internationally can lead to lower delivery rates as opposed to sending over local numbers.

Hi there – well, Telerivet worked, but: there were hiccups, and overall it didn’t feel ideal … and I hope to set up a simpler situation where there is simply an immediate link from the commcareHQ app to a SMS gateway. A simpler, clearer situation that didn’t require me to handle this “additional layer” in the process, involving the phone.

When we used Telerivet, I found I always had to worry about the state of this phone sitting on a desk in my office – did it have enough credits? Had our procurements people handled the latest mobile service bill for that phone? Had the phone gotten unplugged or get frozen by some android auto-update? The overall experience meant that when I tried to understand the number of send failures, I never felt totally sure which ones were “my fault because of the phone” or a genuine problem due to the destination number being fake, etc.

On a different project I did, in India, we made a regular PHP web app (unrelated to commcare) and connected it to a regular API-based SMS gateway based directly in india. It was just very refreshing to connect the apps using the API and totally “forget about it,” not requiring additional babysitting on my part.

– I didn’t have the sense that a gateway like Twilio sending from the USA caused lots of sending drop-outs. So, if the price is not outrageous, then that still seems OK to me.

– Also, Thailand is a quite large country, I keep suspecting that instead of Twilio or some other non-thailand gateway, I can find a “native” SMS gateway to Thailand. So my question for how to connect CommCare directly to an API-based system actually also applies to not just Twilio but to an API-based gateway I might be able to find in Thailand.

… So, in general, that’s the general context of why I’m interested in finding where are the settings to connect CommCare to an API of an SMS sending gateway.

BUT, as I said above… I’m not fully decided on Twilio specifically – I’m also glad to hear all other suggestions on what you think to be the best way to find my goals!

Eric

P.S. Also, any time I say “Twilio” above, assume that I also mean “or Nexmo or some other big common SMS sending company.”

One more note – Twilio subscription cost me $300 per year for the plan we used (since, using the cheaper option meant that I had remember to go in and “clear my address book” every once in a while, or it would wind up unable to send more. While regular SMS gateways don’t have a big membership fee, is that right? It’s likely I’m wrong about some of this. Just aiming for the easiest method to send SMS’s to thailand, triggered by my CommCare app.

Hi Eric,

If you’d like to use one of Dimagi’s gateways capable of sending SMS internationally instead of using your Telerivet gateway, you can just go to the Messaging > SMS Connectivity page for your project and choose one of the international gateways there to be the default gateway for your project.

There currently isn’t a Thai in-country gateway listed there, so you’ll have to choose one of the gateways which list “Multiple” under the supported countries column. Probably the two most popular international gateways we have are MOBILE_BACKEND_TWILIO and MOBILE_BACKEND_MACH. You don’t have to setup extra gateway accounts to use these gateways. Instead you will be charged for your SMS usage in your invoices from CommCareHQ.

Please note, as I mentioned before, that using an international gateway might result in more dropped messages than using an in-country gateway will.

To answer your question about connecting CommCareHQ to a new type of gateway for which you have an account, that might possible depending on your subscription. Looking at the pricing page (https://www.dimagi.com/commcare/pricing/), right now the feature “Support to connect new in-country gateways” is only available for Advanced or Enterprise subscriptions.

Thanks much, this is valuable info!

Two questions:

1-- You have mentioned the dropped SMS issue when sent from outside one's country (i.e., like twilio to thailand.) Do you recall any specific observations on how common that is? of course twilio gives impression that sending internationally is something that they proudly advertise and doesn't seem too sketchy... have you seen it have fails?

2-- Also, I am a little bit hazy about understanding the SMS prices when sent through the built-in commcare connection to twilio.

  • On the bottom of my "current subscription" page, I see that 50 SMS messages are "included in software plan." Is that 50 per month?
  • On a different page, SMS Pricing - CommCare HQ ... when I choose thailand, it doesn't include the Twilio option on those prices. Other ones like Tropo are listed at USD 0.05 per SMS. Would you say that Twilio is $0.05 also?
  • For this question, let's assume the twilio cost is $0.05. Is that 0.05 the total amount I pay for each SMS, there is no other SMS fee I have to pay, that includes everything (both commcare and twilio?)
  • and those 50 "included" SMS's per month, those pay for one full SMS even if the SMS is through the relatively expensive twilio route instead of the cheaper routes? Or does it gobble up 5 of those credits? :slight_smile:

Thanks! This will help me plan the best method...
Eric

In our past experience, we have noticed that sending SMS internationally can potentially lead to more dropped or blocked messages than sending in-country does, but we don’t have any specific data to share on this.

The 50 SMS you see do mean 50 per month, and it means your CommCare invoice will not charge for the first 50 SMS you send that month. In the case of sending long messages which get sent as multipart concatenated SMS, it would only be the first 50 SMS parts.

The rates you pay per SMS can fluctuate as the gateway’s rates (and exchange rates for some gateways) fluctuate, but currently it looks like Twilio charges USD 0.029 per SMS to send to Thailand: https://www.twilio.com/sms/pricing/th. Also note that if you’re sending in the Thai script, it means the per SMS charges will be charged for each 70 characters (roughly) for long messages.

Answers to the rest of the questions about pricing can be found here: https://confluence.dimagi.com/display/commcarepublic/SMS+Basics#SMSBasics-SMSPricing

Thanks, this is helpful, and I bet others will appreciate it too. One question: Below you said that Twilio charges USD 0.029 for each SMS sent. Am I correct that in addition to that 0.029, there is also an additional 0.01 fee that goes to Dimagi, so that will mean that each SMS sent will cost a total of USD 0.039?

Thanks! And let me know if there is any other cost I am forgetting. (I know that of course there is the monthly cost of my existing Pro subscription.) – Eric.

You’re correct that the current per-SMS cost to use Dimagi’s Twilio gateway to send SMS to Thailand from CommCareHQ would be USD 0.039 per SMS (or per SMS part in a multipart SMS).

That’s of course based on current rates, which may change.