Skip to content

obutuz/sms_blitz

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SmsBlitz

Build Status

SmsBlitz is a library for elixir that allows you to send SMS messages through multiple different providers.

SmsBlitz provides a generic behaviour to make it easy to write conforming client libraries, while also making it simple for developers to choose which provider to use (you could use ex_phone_number to detect the destination country and use the cheapest provider for that country, for example).

Installation

If available in Hex, the package can be installed as:

  1. Add sms_blitz to your list of dependencies in mix.exs:
        def deps do
          [{:sms_blitz, "~> 0.1.1"}]
        end
  1. Ensure sms_blitz is started before your application:
        def application do
          [applications: [:sms_blitz]]
        end

Setup

Setting up with SmsBlitz is easy. You simply add the authentication details for the providers you want to use into to your config:

config :sms_blitz, plivo: {"api_token", "api_key"}
config :sms_blitz, itagg: {"username", "password", "route"}
config :sms_blitz, twilio: {"account_sid"}
config :sms_blitz, nexmo: {"account_key", "account_secret"}

You can find out which adapters are available like so (note that the list of adapters is not the same as the list of adapters which has been configured correctly!):

SmsBlitz.adapters
# [:plivo, :itagg, :twilio, :nexmo]

Then you can send the SMS to the provider as simply as this:

SmsBlitz.send_sms(:adapter, from: "Johnny", to: "07123456789", message: "Here's Johnny!")

Where :adapter is the adapter you've chosen from the list.

The output of the send_sms/2 command above will either be like:

%{
  id: "id here",
  result_string: "Things went well",
  status_code: "1337"
}

Or an Array of maps formatted as above. It's important that you handle both types of responses!

About

Send SMS messages through multiple different providers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%