I’ve always wondered how in a country where only 6.50% of the population has access to electricity, telecommunications companies manage to do business and bring mobile penetration to ~40% of the population!

If you live in a sub-Saharan country like me ( Burundi), you know how we power our phones, right ?

Anyway.

Dumb phones ( opposed to Smartphones)

It means we heavily use ‘dumb phones’ which don’t consume a lot the scarce energy we have…, opposed to the now worldwide known smartphones.

It also means, there is a great potential of using SMS all over the country even if internet coverage is weak.

That’s what I’ve been doing since 2013, at UNICEF, building SMS-based web-applications, and dashboards for … youth engagement (U-report), or for collecting data on diseases ( Cholera App ) or health systems ( Mother and Child Health Week ), Acute Malnutrition, …

And many young people don’t understand the necessity of using the available/affordable techs (SMS for example in Africa) and instead keep waiting for the big, much awaited optical-fiber revolution, when Internet will be available everywhere.

But, … considering the success of M-Pesa ( 237 million person-to-person transactions ! man! ), we better reconsider our view on the subject.

And if you’re a Python/Django developer like me and like open-source softwares, let me show you how you can build a ‘SMS-gateway’ to start ‘dabbling’ with SMS based apps in Python, so you can send and receive in a convenient way SMSs and familiarize yourself with … *ntumbaze* !

The technologies we’re going to be using are quite ‘simple’ and affordable since all of them are open-sourced. I mentioned them in my first post .

Install requirements

Let’s assume you have your computer on which you have root privileges. Preference is for a Debian-based distribution (… been using Ubuntu/Linux for 7 years!).

Install virtualenvs

Virtualenvs helps you have many versions of the same Python package on the same machine without incompatibility issues. Virtualenv is easy to install:

$ sudo apt-get install python-virtualenv

Create a directory to store your application in mysmsapp and cd into it

$ mkdir mysmsapp && cd mysmsapp

Build the RapidSMS app

What follows is to build your web app. Let’s use RapidSMS, which is a Django framework for interacting with SMS. You just need to do what’s in these tutorial 1, tutorial 2, tutorial 3. It’s so simple if you know Python or Django.

At the end of tutorial 3, you need to chose a Backend so our app can send and receive actual real world text messages. We’ll use a Kannel backend on our machine. I like it because I know so many telecoms companies use it on their big servers. We’ll use on our small machine and it actually works well… even on a Raspberry Pi!

Kannel and modem

Take a GSM modem containing a sim-card and hook it to your machine. It’s advised not to connect it to the internet because some modems are configured not to do SMS and Internet stuffs at the same time.

Gear we’ll use!

It’s also advised to use modems that use the ‘AT’ protocol. Some are found here.

Kannel help distribute incoming or outgoing SMS to our application.

You can now install kannel and configure to use our app like explained in here but keep in mind that you have to modify some parts of the kannel configuration like in this Gist.

At the end you have an interface to send SMS like this one :

RapidSMS interface

Message logs

‘Fini’!

We’ve created our SMS-center to send and receive some messages.

As bonus , here I’ve made a cool ‘Raspberry based’ SMS-center which actually mimics what we do at the office with a 64GB/ram server!

Raspberry ($35) + ZTE Modem and sim-card ($25) = 518Mb sms-server-center

Cool. Happy new 2016 year.