Created
January 10, 2021 20:24
-
-
Save dsasse07/84e165ccc8400e2ad69ccb23de8c223a to your computer and use it in GitHub Desktop.
Incorporating Twilio send SMS code snippet into a module for inclusion in necessary classes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dotenv/load' #This ruby gem will is what we will be using to secure our Twilio credentials | |
require 'twilio-ruby' | |
module TwilioControls | |
# To set up environmental variables, see http://twil.io/secure | |
@@account_sid = ENV['TWILIO_ACCOUNT_SID'] #This is used in conjuction with the 'dotenv/load' gem | |
@@auth_token = ENV['TWILIO_AUTH_TOKEN'] #This is used in conjuction with the 'dotenv/load' gem | |
@@client = Twilio::REST::Client.new(@@account_sid, @@auth_token) | |
@@from = '+1##########' # Your Twilio number | |
to = '+1##########' # Phone number to receive the text message | |
def send_sms(to_phone_number, message) | |
@@client.messages.create( | |
from: @@from, | |
to: to_phone_number, | |
body: message | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment