How I implemented Flowroute’s SMS services into my X-Lite softphone’s IM feature.
Introduction and background
As many of you are no doubt aware, SMS messaging is not really an integrated part of FreePBX/Asterisk. In fact as far as I know, SIPStation is the only SIP Trunk provider that offers integrated SMS capabilities. Other providers offer SMS, but they don’t work out of the box like SIPStation. However for my basic home VoIP needs, their offerings aren’t a lot cheaper than the services I already had through my provider.
I did some shopping around and decided on Flowroute for my SIP trunk. Their basic services were within my budget, and they offer SMS. Now came the fun part; making it work with the X-Lite instant messenger. From what I understand, the SIP SIMPLE protocol used by the X-Lite softphone also works with a variety of SIP phones as well, but I don’t own any SIP phones and don’t really have a way to verify that my solution works on those phones as well.
How Flowroute’s SMS services work
Flowroute’s SMS service works via a basic RESTful HTTP interface, using simple POST and GET HTTP requests.
Through Flowroute’s account manager, their SMS API can be “pointed” to an SMS Callback URL, a specific address on your network. Any incoming SMS messages they receive for one of your DIDs is sent to this callback URL in the form of an HTTP request. Software on your end receives the message, and it’s up to you to take it from there.
They also provide a URL on their network to receive outgoing SMS messages, utilizing an HTTP request as well. Again, it’s up to software on your end to format, prepare, and send the message.
How I handle incoming SMS messages
Using Apache and a perl script, I receive an incoming SMS message and use the information to create a .call file that I drop into Asterisk’s outgoing call directory. Asterisk takes it from there and sends the message to a specific softphone extension as an IM.
How I handle outbound SMS messages
Using a custom context stored in Asterisk’s custom extension file, instant messages are examined to determine if the destination is a local extension or a 10 digit phone number. If it’s a 10 digit phone number, the message data is passed on to a bash script where it’s formatted into a valid HTTP request and sent to Flowroute through cURL.
Overall, it’s a working solution. It’s a bit of a kludge, but it does work. I have been considering writing up a more detailed explanation with an explanation of the underlying code, if anyone is interested.