Voice Broadcast API

Voice API
Quick Start Guides
Methods
Types
FAQ

Quick Start: Ruby

There are three steps to integrating the Voice Broadcast API into your Ruby project.

1. Create an account.

Sign up for an Esendex account. When you register you will receive a license key. You will need this to use the API.

2. Install Ruby.

Install Ruby if it is not on your computer already. To check, run this command in your terminal: ruby --version

PS C:\> ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]

3. Send a test phone call.

Install Savon, a SOAP client for Ruby. Run this command in your terminal: gem install savon

Create a new Ruby file. Let’s call it demo.rb.

You can use the NotifyPhoneBasic method to send a phone call. Add the displayed code to your new file.

Replace the phone_number_to_dial value with your own phone number.

Replace the license_key value with your account’s license key.

require 'savon'

client = Savon.client(wsdl: 'https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl')
phone_number_to_dial = '7575559999'
text_to_say = 'Hello, this call was sent with Ruby.'
caller_id = ''
caller_id_name = 'Test Caller'
voice_id = 0
license_key = '00000000-0000-0000-0000-000000000000'

response = client.call(
  :notify_phone_basic,
  message: {
    'PhoneNumberToDial' => phone_number_to_dial,
    'TextToSay' => text_to_say,
    'CallerID' => caller_id,
    'CallerIDname' => caller_id_name,
    'VoiceID' => voice_id,
    'LicenseKey' => license_key
  }
)

puts response.body[:notify_phone_basic_response][:notify_phone_basic_result][:response_text]

Run the project in your terminal with this command: ruby demo.rb. If the response is Queued, the call has been successfully scheduled. You will receive the phone call shortly.

PS C:\RubyDemo> ruby demo.rb
Queued

Let’s start sending, together.