Heroku

How It Works

Moonshado SMS

Last Updated: 05 October 2011

moonshado sms text messaging

Table of Contents

Moonshado-SMS

Moonshado is an SMS gateway. The Heroku Moonshado-SMS add-on provides an interface between the Moonshado-SMS gateway and your application to deliver SMS messages to any US cellular device.

Gem Setup

Installation

Start by installing the moonshado-sms gem:

$ sudo gem install moonshado-sms

Add the gem to your Gemfile:

$ gem "moonshado-sms"

If using rails Rails 2.3 add gem to your .gem file:

$ echo moonshado-sms >> .gems

and add moonshado-sms as a dependency in your Rails 2.3 app by adding a config.gem statement to config/environment.rb:

$ config.gem "moonshado-sms"

Local Setup

In your development environment you will not want to send out real SMS messages as there is a cost associated for every SMS message. Add this to your config/environments/development.rb and config/environments/test.rb:

config.after_initialize do
  Moonshado::Sms.configure do |config|
    config.production_environment = false
  end
end

Production Setup

Add this to your config/environments/production.rb:

config.after_initialize do
  Moonshado::Sms.configure do |config|
    config.api_key = ENV['MOONSHADOSMS_URL']
  end
end

Keywords Setup:

You can also register/update keywords. Keyword is required so the incoming SMS can be routed to your application based on the keyword at the beginning of the text message. Each app currently can register one keyword.

Add this to your config/environments/production.rb:

config.after_initialize do
  Moonshado::Sms.configure do |config|
    config.api_key = ENV['MOONSHADOSMS_URL']
    config.keywords = {:bender => "http://planetexpress.com/sms/mo"}

    # This will auto register keywords on application startup
    config.auto_register_keywords = true
  end
end

Usage

Submit SMS

>> sms = Moonshado::Sms.new("15556345789", "test")
=> #<Moonshado::Sms:0x1032b4900 @number="15556345789", @message="test">
>> sms.deliver_sms
=> {:stat=>"ok", :id=>"e3debdc7f4719ec0", :credit => 500}

SMS Reports & Status

Reports will indicate success or delivery failure of the SMS:

>> Moonshado::Sms.find('e3debdc7f4719ec0')
=> {:stat=>"ok", :credit => 500, :sms=>{:reports=>"[{"update_date":"2010-01-03T22:56:45-08:00","status_info":"test"}]", :id=>"e3debdc7f4719ec0"}}

Receiving Incoming SMS & Keywords

Keyword is first word of a MO SMS (Mobile-Originated SMS). Based on your keyword MO SMS messages will be routed to your application:

Message from device 13135551234: bender the robot

Moonshado-Sms will POST this message to the callback url for the keyword ‘bender’ (http://planetexpress.com/sms/mo) that is specified in environment config: Parameters: {“device_address”=>”13135551234”, “carrier”=>”ATT”, “shortcode”=>”69940”, “message”=>”bender the robot”, “country” => “US”}

SMS Incoming (MO) and Outgoing (MT) limits

* MT/MO credit cost per carrier > Pricing

  • One credit is not equal to one SMS, please see pricing link above for details
  • Message char limit is 115 (reduced from 160 due to the Msg&Data rate and opt-out footer)
  • 198 Countries/620 Carriers Supported > List of Supported Carriers

Further reading:

  • US incoming SMS ShortCode is 69940 (International MO support coming soon)
  • SMS Validations and Reports Details
  • For support, faq, question, or anything else ask it here Support

Deploying to Heroku

To use moonshado-sms on Heroku, install the moonshado-sms add-on:

$ heroku addons:add moonshado-sms