# Using SMS gateway to receive Text messages for a RoR app

**URL:** <https://www.ruby-forum.com/t/using-sms-gateway-to-receive-text-messages-for-a-ror-app/151604>\
**Category:** Rails\
**Created:** [October 23, 2008, 12:48pm UTC](https://www.ruby-forum.com/t/using-sms-gateway-to-receive-text-messages-for-a-ror-app/151604 "2008-10-23T12:48:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yung-Rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/dec6dc/32.png) [@Yung-Rick](https://www.ruby-forum.com/u/Yung-Rick)\
**Post date:** [October 23, 2008, 12:48pm UTC](https://www.ruby-forum.com/t/using-sms-gateway-to-receive-text-messages-for-a-ror-app/151604/1 "2008-10-23T12:48:57Z")

</div>

I am supposed to develop an application for a client that retrieves  
text messages from three different GSM Network providers. I am a  
newbie and looking for any knowledge concerning this area. Information  
concerning server technology, suggestions of any sort would be  
helpful. Materials or sample applications are also welcomed. Counting  
on your help.

Ricko.

---

<div class="post-metadata">

**Author:** ![Yung-Rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/dec6dc/32.png) [@Yung-Rick](https://www.ruby-forum.com/u/Yung-Rick)\
**Post date:** [October 24, 2008, 3:51pm UTC](https://www.ruby-forum.com/t/using-sms-gateway-to-receive-text-messages-for-a-ror-app/151604/2 "2008-10-24T15:51:42Z")

</div>

There are two sources that I am familiar with:

1. Peepcode PDF doc:  
[http://peepcode.com/products/mms2r-pdf](http://peepcode.com/products/mms2r-pdf)
2. A book published by Packt Publishing:  
Ruby on Rails Web Mashup Projects [eBook] (9781847193940)  
They are both decent references.  
Hope this helps.  
Bharat

---

<div class="post-metadata">

**Author:** ![Yung-Rick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/dec6dc/32.png) [@Yung-Rick](https://www.ruby-forum.com/u/Yung-Rick)\
**Post date:** [October 24, 2008, 4:28pm UTC](https://www.ruby-forum.com/t/using-sms-gateway-to-receive-text-messages-for-a-ror-app/151604/3 "2008-10-24T16:28:05Z")

</div>

Yung-Rick,

One option is to register your own shortcode, but this is super pricey  
(prob around $1500 to $2000 per month plus setup costs). Another  
option (this is what I use) is to receive messages on a shared  
shortcode through an SMS gateway. The way this works is the SMS  
gateway owns shortcode 12345, for example. Any messages that arrive  
at that short code and start with my keyword are routed via an HTTP  
POST request to a URL I specify. For example, if my keyword is  
‘GAVIN’, the text message ‘GAVIN THIS IS A TEST MESSAGE’ will be  
routed to my server. The URL I specified for routing is simply an  
action for a controller I created to receive the message, and the  
parameters passed by the SMS gateway are saved by this method. Here’s  
an excerpt of the code I use. All the params are passed from the SMS  
gateway to the URL [http://www.myurl.com/messenger/sms\_in](http://www.myurl.com/messenger/sms_in), so the HTTP  
request from the gateway looks something like  
[http://www.myurl.com/messenger/sms\_in?smsfrom=123456789&subject=Test+Message+Subject&gateway\_id=29298348](http://www.myurl.com/messenger/sms_in?smsfrom=123456789&subject=Test+Message+Subject&gateway_id=29298348)…  
etc.)

class MessengerController \< ApplicationController  
def sms\_in  
@incoming\_message = IncomingMessage.new(:sender =\>  
params[:smsfrom],  
:subject =\> params[:smsmsg],  
:gateway\_id =\> params[:smsid],  
:date =\> params[:smsdate],  
:carrier =\> params[:network],  
:delivery\_point =\> params[:smsto])  
end  
end

As you can see, it’s pretty simple. The gateway I use is Interlinked  
([www.interlinkedmedia.com](http://www.interlinkedmedia.com)). If you’re interested in contacting them,  
you can email Cal Morton at cal [at] interlinked.mobi and tell him I  
referred you (don’t worry, I don’t get a referral bonus so that’s not  
why I’m referring you to Interlinked, but Cal knows me). With SMS  
gateways there is a setup fee, a monthly service fee, and a per-  
message fee, but hopefully that’s something your client is prepared to  
pay for.

It would be easier and cheaper if you only needed to send  
messages…you could use a bulk gateway like Clickatell…but it  
sounds like you need to actually receive them.

-Gavin
