Project

actionsms

0.0
No commit activity in last 3 years
No release in over 3 years
Like ActionMailer, but for SMS
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.8.0

Runtime

 Project Readme

ActionSMS

ActionSMS was inspired by ActionMailer and it aims to provide a unified interface for using an SMS provider.

Synopsis

# config/initializers/sms.rb
require 'sms/method/twilio'
Sms.delivery_method = Sms::Method::Twilio.new(account_sid, auth_token, default_from)
# app/models/user.rb
require 'actionsms'
after_create do
  message = Sms::Message.new(from: '123', to: phone, text: 'Thanks for signing up!')
  message.deliver
end

Example controller receiving SMS:

require 'sms'

class SmsController < ActionController::Metal
  def receive
    self.content_type = 'text/plain'
    unless %w[from to text].all? { |key| params.key?(key) }
      self.status = 400
      self.response_body = "Invalid Request\n"
      return
    end
    SmsReceiver.receive(params)
    self.response_body = ''
  end
end

class SmsReceiver < Sms
  def receive(sms)
    Rails.logger.info "SMS: #{sms.inspect}"
  end
end

TODO

  • Railtie for doing things like config.action_sms.delivery_method = :file
  • Configurable place for the file