Setting Up a Two-Way SMS Gateway with Gnokii and Drupal


2 min read

In addition to all of the work being done on the SMS Framework, we have also started researching how to quickly create our own two-way SMS gateway for sending and receiving SMS messages. It is a proof of concept based on needs we are hearing from development agencies. Our solution is based around gnokii, an open source project that can be used to control the various functions of any mobile phone it supports. gnokii sends and receives SMS text messages over a USB or Bluetooth connection with the phone.

b65563389af6  076HHlrU41zbJTYpr

In our setup we’re using a Nokia 6102i mobile phone, gnokii 0.6.8 (installed using Macports) and a MacBook Pro with Bluetooth.

A daemon, written in Python, manages the process of sending and receiving messages and a Drupal module acts as the end point on the Drupal side. The daemon periodically checks the phone for incoming messages and the server for outgoing messages. If a message is found it is processed and passed to the other side.

An outgoing message that originated from a Drupal module will be stored in a queue temporarily. The daemon checks the queue using an HTTP request. When it finds the queued message it connects the phone, sends the message, and clears the item from the queue. Incoming messages are handled in a similar fashion. When a message is first received it is queued on the mobile phone temporarily. When daemon finds the message waiting on the phone, it passes it to the server using an HTTP request and deletes the entry from the phone.

We are making the daemon open source so check out the code in the Drupal CVS repository and let me know if you want to talk about this.

What we're doing.