← Back to Blog

Integrating WhatsApp API in Ruby on Rails

By 5MinutesAPI Engineering

Rails and Conversational Alerts

If you run a SaaS or e-commerce backend on Ruby on Rails, adding WhatsApp notifications for background jobs (like Sidekiq) or order callbacks is seamless with 5MinutesAPI.

The HTTP Request in Ruby

You can use the native Net::HTTP library or a gem like HTTParty to hit our endpoints. Here is a quick implementation:



require 'httparty'

class WhatsappService
include HTTParty
base_uri 'https://api.5minutesapi.com/v1'

def self.send_otp(phone, code)
post('/send-otp',
headers: {
'Authorization' => 'Bearer ' + ENV['WA_API_KEY'],
'Content-Type' => 'application/json'
},
body: { to: phone, code: code }.to_json
)
end
end

Handling ActiveJob Failures

With our Auto-Refund architecture, if your Sidekiq job triggers an OTP to a non-existent WhatsApp number, Meta's failure webhook reaches our Golang engine, and we instantly credit your wallet. You get enterprise reliability without writing complex retry logic in Rails.

Ready to upgrade your infrastructure?

Start Building with 5MinutesAPI