LogoDTreeLabs

Set up a Twilio account with phone numbers

Deepak JadhavBy Deepak Jadhav in TwilioRuby on November 25, 2019

Twilio is a cloud-based platform as a service that provides voice, SMS, video and WhatsApp communication services. The best part is, it can be easily integrated with ruby using twilio-ruby gem. The scope of this post is limited to setting up a Twilio account with phone numbers.

Basic steps in setting up a Twilio account

Buy a Twilio Number Verify caller IDs Create and link TwiML to phone numbers

Step 1: Buy a Twilio Number

The first thing while setting up the Twilio account is to buy a Twilio number. After signing in to the account go to the console and select phone numbers menu option as shown below

Twilio_buy_number_search

Now, we can search for the phone number of our preference by selecting different options as shown below

Twilio_buy_number_search_result

Choose a number and buy it

Step 2: Verify caller IDs

Inbound or outbound calls made to or from the phone numbers must be verified numbers for a free trial account. We can add verified phone number either by using REST API ( This is not included in the scope of this post. Please check the Twilio API Documentation for details) or from Twilio console.

Add a verified phone number using the console.

Select the Phone Numbers option.

Twilio_select_phone_numbers_options

Select the Verified Caller IDs option. Click on plus sign shown in the following snapshot.

Twilio_verify_phone_number

Now, enter the phone number and choose the method for the verification. Phone number can either be verified by a call from Twilio or Text.

Step 3: Create and link TwiML to phone numbers

TwiML (Twilio Markup Language) is a set of instructions used to tell Twilio the actions to be performed when an incoming call, SMS or Fax placed to our Twilio number.

Create a new TwiML

  • Select TwiML Bins option from the console. Twili_TwiML_option
  • Click Create New TwiML Bin button to create new TwiML. Twili_create_new_TwiML
  • Write TwiML code here. Twili_sample_TwiML
  • Link TwiML to Twilio Phone Number. Twilio_link_TwiML_to_Number
  • Select a Twilio Phone number to associate a TwiML. Twili_select_number_for_twiml
  • Select and Associate a TwiML to a Twilio number.

Conclusion

Setting up a Twilio account to integrate with Rails is straightforward and easy. A free trial account provided by Twilio is a very good facility to learn features like inbound calls, outbound calls, sending SMS & fax, etc. Also, Twilio provides a very user-friendly UI.

References

Twilio Documentation