Create a file called send-sms.rb and another one called .env . Bash Copy the code touch send-sms.rb .env Open the .env file . We will store the credentials we need to 11-digit phone number format philippines call the API, as well as the Messaging Service SID we just created. Copy the lines below and enter the requested details for each of the credentials.

Now let's move on to writing the code. Open the send-sms.rb file . Start by requesting "dotenv/load", which loads the variables listed in the .env file into the environment, and "twilio-ruby", the Twilio Ruby library.'dotenv/load' require 'twilio-ruby' Get the variables we need from the environment: Ruby Copy the code account_sid = ENV.
Using a command ENV.fetch like this will throw an error if the variable is not present in the environment, which is useful for identifying bugs quickly. To send a message, you need a From address, managed by our Messaging Service, a Destination number, and the message you want to send.