Last active
November 6, 2019 04:26
-
-
Save atsmith813/26e96c3492e3ed2364f25c4ea9365263 to your computer and use it in GitHub Desktop.
Send text of today's birthdays
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
# Continuing with the birthdays object created above... | |
todays_birthdays = birthdays.select { |birthday| birthday[:date] == Date.today } | |
account_sid = TWILIO_ACCOUNT_SID # Your Twilio phone number | |
auth_token = TWILIO_AUTH_TOKEN # Your Twilio auth token | |
client = Twilio::REST::Client.new(account_sid, auth_token) | |
from = '+11234567890' # Your Twilio number | |
to = '+10987654321' # Your mobile phone number | |
# Create the text message | |
birthday_message = | |
if todays_birthdays.length > 0 | |
birthday_text = "Friends with birthdays today:\n" | |
todays_birthdays.each { |birthday | birthday_text += "#{birthday[:name]}\n" } | |
birthday_text | |
else | |
"No birthdays today!" | |
end | |
# Send the text message | |
client.messages.create( | |
from: from, | |
to: to, | |
body: birthday_message | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment