Build Ruby and Rails voice apps with the Vobiz SDK - outbound calls, SIP trunks, DID management, and VobizXML for global calling in 130+ countries.
The official Ruby SDK for the Vobiz Voice API. Make outbound calls, manage SIP trunks, handle phone numbers, and drive live call flows directly from your Ruby on Rails or native Ruby stack.
Source code: vobiz-ai/Vobiz-Ruby-SDK
Requires Ruby >= 3.3.0. The SDK is distributed from its GitHub repo (not RubyGems). Clone it, then reference it by path in your Gemfile:
bashgit clone https://github.com/vobiz-ai/Vobiz-Ruby-SDK.git
ruby# Gemfile gem "vobiz", path: "./Vobiz-Ruby-SDK"
Then run bundle install.
Place an outbound call. When the call connects, Vobiz queries your answer_url webhook, which must return a valid VobizXML document.
rubyrequire 'vobiz' client = Vobiz::Client.new( api_key: ENV['VOBIZ_AUTH_ID'], auth_token: ENV['VOBIZ_AUTH_TOKEN'] ) auth_id = ENV['VOBIZ_AUTH_ID'] response = client.calls.make_call( auth_id: auth_id, from: '14155551234', to: '+919876543210', answer_url: 'https://yourserver.com/answer', answer_method: 'POST' ) puts "Call UUID: #{response.call_uuid}"
The Ruby client uses your Auth ID and Auth Token. Find both in the Vobiz Console.
Pass your Auth ID as api_key (mapped to the X-Auth-ID header) and your Auth Token as auth_token (mapped to X-Auth-Token). It is recommended to load credentials from environment variables:
rubyrequire 'vobiz' client = Vobiz::Client.new( api_key: ENV['VOBIZ_AUTH_ID'], auth_token: ENV['VOBIZ_AUTH_TOKEN'] )
Most API methods also take your auth_id as a parameter:
rubyauth_id = ENV['VOBIZ_AUTH_ID']
When Vobiz calls your answer_url, your webhook must respond with a VobizXML document that defines the call flow. The gem ships a builder at Vobiz::XML (require "vobiz/xml") - each add_* returns the created child for nesting, and keyword args map to VobizXML attributes:
rubyrequire "vobiz/xml" # Example Sinatra/Rails handler returning VobizXML post '/answer' do content_type 'application/xml' r = Vobiz::XML::Response.new gather = r.add_gather( action: "https://yourapp.com/menu-choice", method: "POST", input_type: "dtmf", # -> inputType (Gather uses inputType / execution_timeout) num_digits: 1, execution_timeout: 10, ) gather.add_speak("Press 1 for sales, 2 for support, or 0 for an operator.") r.add_speak("We didn't receive your input. Goodbye.") r.add_hangup r.to_s # pretty; r.to_s(pretty: false) for one line end
ℹ️ Note: Prefer the builder, but returning a raw VobizXML string also works. See the VobizXML reference for all verbs and attributes.
ruby# Inject TTS dynamically into a live call client.speak_text.call( auth_id: auth_id, call_uuid: 'YOUR_CALL_UUID', text: 'Hello dynamically!', voice: 'WOMAN', language: 'en-US', legs: 'aleg' )
rubyrecordings = client.recordings.list_recordings(auth_id: auth_id, limit: 10) recordings.data.each { |rec| puts rec.recording_url }
ruby# List numbers you own numbers = client.phone_numbers.list_numbers(auth_id: auth_id) # List inventory numbers available to buy available = client.phone_numbers.list_inventory_numbers(auth_id: auth_id) # Purchase a number from inventory client.phone_numbers.purchase_from_inventory(auth_id: auth_id)
The SDK raises Vobiz::ApiError for any non-2xx response. Inspect the exception for the status code and raw body:
rubybegin client.calls.make_call( auth_id: auth_id, from: '14155551234', to: '+919876543210', answer_url: 'https://yourserver.com/answer', answer_method: 'POST' ) rescue Vobiz::ApiError => e puts "Status: #{e.status_code}, Body: #{e.body}" end
Connect 3CX PBX to Vobiz SIP trunking for inbound and outbound calling across 130+ countries - configure a generic SIP trunk in minutes.
Connect an Agora Conversational AI agent to Vobiz SIP trunking - add a Vobiz number to Agora for outbound campaigns and route inbound calls to your agent, including India and 130+ countries.
Bolna ships Vobiz as a built-in telephony provider. Paste two credentials into the Providers screen and your agents place and answer calls on numbers in 130+ countries, reaching 190, with audio streaming rather than a SIP trunk.
We use cookies to run this site and, with your permission, to understand how it's used. Read our Cookie Policy.