Skip to content

Instantly share code, notes, and snippets.

@dmbf29
Created August 6, 2022 02:27
Show Gist options
  • Save dmbf29/30b6ecb67f157bbaebae02de4ee63295 to your computer and use it in GitHub Desktop.
Save dmbf29/30b6ecb67f157bbaebae02de4ee63295 to your computer and use it in GitHub Desktop.
Twilio Sms Service object
require 'twilio-ruby'
class SendSmsService
def initialize(message)
@message = message
# probably pass in the user as well so you can get the phone number?
end
def call
client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
client.messages.create(
from: ENV['TWILIO_NUMBER'], # Your Twilio number
to: '+81802166xxxx', # User mobile phone number
body: message
)
end
end
# To call it:
# SendSmsService.new('YOUR MESSAGE').call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment