playSMS Gateway Plugin Twilio

playSMS is a web application for managing users, credits, features, routes and gateways, for sending and receiving SMS. playSMS is not an actual SMS gateway, it cannot send or receive SMS by itself. It needs another application or service, SMS gateway or gateway for short, to actually send and receive SMS. Twilio is one of those SMS gateway.

playSMS uses plugins for various functions and one of them is for handling those SMS gateways. Gateway Plugin in playSMS is referred to plugin that handles actions such as sending and receiving SMS for playSMS from/to actual SMS gateway.

In this article I will explain how to configure a Gateway Plugin Twilio to connect playSMS with SMS service in Twilio.

Requirements

Before we start there are several things need to be ready:

  1. Access to Twilio
    • Register for free. You may get trial fund for testing purposes. You need to upgrade your trial account and add more fund to use it in production.
  2. Working playSMS accessible from the Internet
  3. Twilio must be able to push HTTP POST to playSMS and vice versa
    • playSMS must run on HTTPS (articles on point 2 above will explain how to do it if you haven’t)

Let’s start the configuration!

Part 1 – Twilio

Login to Twilio and enter Twilio’s dashboard.

1.1. Add SMS Service

In my example I gave the service name playSMS Test. The use case set to Mixed.

1.2. Add Phone Number

Once the SMS service ready, add a phone number to it. Buy a number in my case.

1.3. Set Callback

If you need to receive SMS.

Example, suppose your playSMS URL is https://example.com/playsms/ then your callback URL (or REQUEST URL in Twilio) is:
https://example.com/playsms/plugin/gateway/twilio/callback.php

1.4. Account SID and Auth Token

Last, you need to take notes on Account SID and Auth Token. Those will be used by playSMS to access the SMS service in Twilio.

Part 2 – playSMS

Login to your playSMS as admin user.

2.1. Manage Gateway Twilio

Go to Settings -> Manage gateway and SMSC. Choose Gateway Twilio and click the Manage button (folder icon) to enter Twilio’s access information.

Next, enter Account SID, Auth Token and Module sender ID. Module sender ID is your +E164 phone number on your Twilio’s account (see 1.2). Callback URL should be automatically filled in, if not then set it to your Callback URL (see 1.3).

2.2. Sender ID

Remember to set Module sender ID in full phone number with plus sign, and this number must be your phone number set in Twilio. Twilio can add alphanumeric sender ID and shortcodes to your Twilio SMS service too, you can set this to one of those sender ID too.

You can also empty it if you want to set caller ID by other way for example perhaps you want to set it in Settings -> Main configuration instead as your Default sender ID, or maybe you want to give some flexibility to your users so that you allow your users to set sender ID too from their playSMS dashboard.

But again, those numbers (alphanumerics and shortcodes too), must be already added to your Twilio SMS service. You cannot use any number or label as your SMS sender ID.

2.3. SMSC

Go back to Settings -> Manage gateway and SMSC, this time click the plus icon next to folder icon to add an SMSC. One gateway can have multiple SMSC for logging purposes, and for service differentiation. For example, same Gateway Twilio but different SMSC will use different Account SID and Auth Token, and can be different phone numbers.

Just set the SMSC name, and empty other fields. If you set some information on those fields you will then override the setting on Gateway Twilio (see 2.1).

In my example the SMSC name is twilio1. Other fields are empty because I don’t need to override the Gateway Twilio settings.

2.4. Route Outgoing SMS

Next, route outgoing SMS through twilio1.

In my example above I routed all SMS to +628xxxxxxx to twilio1. 62 is Indonesia country code, and 628 is mobile phones only.

Suppose you have added multiple SMSC. You can then set same prefix but for different user, using different SMSC.

2.5. Always Add Plus

This is additional configuration I set to make sure that all destination number will be full phone number with plus sign. But, my users won’t have to, they will just send to 08xxxxxxxx instead of typing +628xxxxxxxx.

Go to Settings -> Main configuration.

Some explanation:

  • Default sender ID is empty, I chose to set it on Module sender ID (see 2.1)
  • Default SMSC is blocked, to make sure only routed destination allowed
  • Default prefix or country code set to 62, it means when user send to 089012345 it will be modified by playSMS to 6289012345 (playSMS replace 0 with country code)
  • Always remove plus sign set to yes, I expect my users dont send SMS with plus sign
  • Always add plus sign set to yes, but then since Twilio requires plus sign for country code then I set to yes so that playSMS will add it automatically when sending to SMSC

Log

The easiest way to debug is by watching playsms.log, from console or from menu Reports -> View log.

When playSMS access Twilio, Twilio will respond with meaningful information, such as whether or not theres error. Error will be displayed in red marker part in the playsms.log.

Still having problem ? I’m not saying you will get help soon, or any kind of help for that matter, it’s all voluntary work, but you can start discussing this article in playSMS Forum here:

Leave a Reply, be nice :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s