Ruby SDK
The official Ruby SDK for the Vobiz Voice API. Make outbound calls, manage SIP trunks, handle phone numbers, and construct programmatic XML workflows directly from your Ruby on Rails or native Ruby stack.
Source Code: vobiz-ai/Vobiz-Ruby-SDK
Installation
Clone the repository directly into your workspace:
git clone https://github.com/vobiz-ai/Vobiz-Ruby-SDK.git
cd Vobiz-Ruby-SDK
bundle installAuthentication
Like all SDKs, the Ruby client relies on your Auth ID and Auth Token. Both can be found within the Vobiz Console.
Initialize the client automatically using environment variables:
export VOBIZ_AUTH_ID=YOUR_AUTH_ID\nexport VOBIZ_AUTH_TOKEN=YOUR_AUTH_TOKENrequire 'vobiz'
client = Vobiz::Client.newOr passed explicitly:
client = Vobiz::Client.new('YOUR_AUTH_ID', 'YOUR_AUTH_TOKEN')Quick Start (Outbound Calls)
Creating an outbound call requires passing your origin number, destination number, and your webhook URLs using Ruby symbols. Upon the call connecting successfully, Vobiz will query your answer_url webhook. This webhook must return a valid VobizXML document instructing the platform on how to handle the live call (e.g., playing audio, capturing DTMF digits, speaking TTS).
require 'vobiz'
client = Vobiz::Client.new
call = client.calls.create(
from: '+1xxxxxxxxxx',
to: '+1xxxxxxxxxx',
answer_url: 'https://yourserver.com/answer',
answer_method: 'POST',
hangup_url: 'https://yourserver.com/hangup',
hangup_method: 'POST'
)
puts "Successfully Initialized Call UUID: #{'#{'}call[:request_uuid]}"VobizXML Module
The Ruby SDK includes an object-oriented XML::Response builder. Generate complex nested call flows natively. Instead of manually concatenating raw XML strings in your controllers, you can instantiate elements like add_speak or add_record and safely render them out via to_xml. This prevents syntax errors and ensures your webhooks are always schema-compliant.
require 'vobiz/xml'
response = Vobiz::XML::Response.new
response.add_speak('Welcome to Vobiz!', voice: 'WOMAN', language: 'en-US')
response.add_record(action: 'https://yourserver.com/recording', max_length: 30)
puts response.to_xmlCore Resources
The Ruby SDK effortlessly maps your abstract components directly into the Vobiz trunk natively. Below are a few quick utility snippets executing structural operations.
Live Call Mutators & Storage
# Inject TTS dynamically onto a live conversational party
client.calls.speak_text('call-uuid', text: 'Hello dynamically!', voice: 'WOMAN', language: 'en-US')
# Pull existing recordings locally via native pagination loops
recordings = client.recordings.list
recordings.each { |rec| puts rec[:recording_url] }DID Phone Management
# Browse global numbering available within the Vobiz trunk seamlessly
available = client.numbers.search(country_iso: 'US', type: 'local')
# Provision right from the terminal securely
number = client.numbers.purchase(number: '+12025550123')