All Projects β†’ alexford β†’ twilito

alexford / twilito

Licence: MIT license
A tiny, zero dependency Ruby helper for sending text messages with Twilio πŸ’¬

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to twilito

Twilio Csharp
Twilio C#/.NET Helper Library for .NET Framework 3.5+ and supported .NET Core versions
Stars: ✭ 541 (+3281.25%)
Mutual labels:  twilio, sms
Botkit
Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
Stars: ✭ 10,555 (+65868.75%)
Mutual labels:  twilio, sms
Authy
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Stars: ✭ 34 (+112.5%)
Mutual labels:  twilio, sms
botkit-sms
Twilio Programmable SMS implementation for Botkit.
Stars: ✭ 18 (+12.5%)
Mutual labels:  twilio, sms
PySMS
Simple Python API that that allows you to send texts via SMTP with a best effort approach and process replies via IMAP
Stars: ✭ 19 (+18.75%)
Mutual labels:  twilio, sms
Spoke
mass-contact text/SMS distribution tool
Stars: ✭ 367 (+2193.75%)
Mutual labels:  twilio, sms
30 Days Of Python 3.6
This is a soon-to-be archived project version of 30 Days of Python. The original tutorial still works but we have an updated version in the works right now.
Stars: ✭ 98 (+512.5%)
Mutual labels:  twilio, sms
dj-twilio-sms
Twilio SMS Integration for Django
Stars: ✭ 15 (-6.25%)
Mutual labels:  twilio, sms
apostello
sms for your church
Stars: ✭ 62 (+287.5%)
Mutual labels:  twilio, sms
plivo
This package enables to send message or OTP to any mobile.This package uses external plivo api.
Stars: ✭ 20 (+25%)
Mutual labels:  twilio, sms
React Native Phone Verification
The best React Native example for phone verification (an alternative to Twitter Digits).
Stars: ✭ 332 (+1975%)
Mutual labels:  twilio, sms
sms-bot
an SMS bot built with Google sheets and Twilio
Stars: ✭ 61 (+281.25%)
Mutual labels:  twilio, sms
Gotwilio
Twilio library for Go (golang).
Stars: ✭ 328 (+1950%)
Mutual labels:  twilio, sms
Twilio Java
A Java library for communicating with the Twilio REST API and generating TwiML.
Stars: ✭ 371 (+2218.75%)
Mutual labels:  twilio, sms
laravel-authy
Rinvex Authy is a simple wrapper for @authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Stars: ✭ 35 (+118.75%)
Mutual labels:  twilio, sms
Faxserver
Send and Receive Faxes Using The Twilio Programmable Fax API.
Stars: ✭ 92 (+475%)
Mutual labels:  twilio, sms
actions-sms
Send an SMS through GitHub Actions
Stars: ✭ 108 (+575%)
Mutual labels:  twilio, sms
sample-template-nodejs
A template repository serving as the base for new Twilio sample apps
Stars: ✭ 16 (+0%)
Mutual labels:  twilio, sms
Simple Sms
Send and receive SMS messages with Laravel
Stars: ✭ 181 (+1031.25%)
Mutual labels:  twilio, sms
useful-twilio-functions
A set of useful Twilio Functions.
Stars: ✭ 53 (+231.25%)
Mutual labels:  twilio, sms

Twilito

A tiny, zero dependency helper for sending text messages with Twilio. Just enough of a wrapper to abstract away Twilio's REST API for sending messages, without anything else.

Gem Version Actions Status

Why

Twilio's full Ruby library does a lot, and has a large memory footprint to go with itβ€”too large for just sending a message. It's also more difficult to mock and verify in tests than I'd like.

Using Twilio's REST API directly is fine, but can be cumbersome.

You should consider using Twilito if the only thing you need to do is send text messages and you don't want to worry about making HTTP requests to Twilio yourself.

If you use more of Twilio, consider twilio-ruby or interact with the REST API in another way.

Usage

Twilito should work on Ruby 2.4 and up. Unit tests run in CI on 2.4, 2.5, 2.6, 2.7, and 3.0.

Install the gem

gem 'twilito'

Simplest case

# All of these arguments are required, but can be configured as defaults (see below)
result = Twilito.send_sms(
  to: '+15555555555',
  from: '+15554444444',
  body: 'This is my content',
  account_sid: '...', # Twilio Credentials
  auth_token: '...'
)


# Returns instance of Twilito::Result

result.success? # => boolean
result.errors # => [] or error messages
result.sid #=> Twilio SID for Message (SM[...])
result.response # => Raw response (instance of Net::HTTPResponse)
result.data # => Hash of response data (parsed from JSON)

Use send_sms! to raise on error instead

begin
  Twilito.send_sms!(
    to: '+15555555555',
    from: '+12333',
    body: 'This is my content',
    account_sid: '...',
    auth_token: '...'
  )
rescue Twilito::SendError => e
  e.message # => 'Error from Twilio API'
  e.response # => Raw response (instance of Net::HTTPResponse)
end

Configuring Defaults For Required Arguments

The five required arguments (to, from, body, account_sid, and auth_token) can be configured as defaults with Twilito.configure.

# In an initializer or something like that:

Twilito.configure do |config|
  # Store your secrets elsewhere
  config.account_sid = ENV['TWILIO_ACCOUNT_SID']
  config.auth_token = ENV['TWILIO_AUTH_TOKEN']

  config.from = '+16145555555'
end
# Later, in your code:

Twilito.send_sms!(to: '+15555555555', body: 'Foo')

Using Other, Optional (Arbitrary) Arguments

There are a number of optional parameters defined by Twilio for sending a message (see the API documentation). Any of these can be sent with Twilito using the "Ruby-style" snake cased equivalent of the parameter.

# Twilito sends arbitrary arguments to Twilio's API after CamelCasing keys to match Twilio's style.
# NOTE: This example assumes auth_token, account_sid, and from have already been configured.

result = Twilito.send_sms(
  to: '+15555555555',
  body: 'This is my content',
  media_url: 'https://example.com/image.png', # MediaUrl
  status_callback: 'https://your.app.io/sms/callback', # StatusCallback
  smart_encoded: true # SmartEncoded
)

Testing your code

TODO: Add examples of mocking and/or test helpers for asserting your code sends an SMS

Contributing

Contribute Feedback, Ideas, and Bug Reports

  • Create or comment on an issue

Contribute Code

  • Find an open issue or create one
  • Fork this repo and open a PR
  • Write unit tests for your change

Contribute Docs

  • Open a PR to make the README better, or help with contribution guidelines, etc.
  • There is currently an open issue for adding RDoc/YARD documentation

Contribute Beer

Did Twilito save you some RAM?

Buy Me A Beer

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].