How RevRing WebRTC Works
WebRTC enables real-time voice communication in browsers and mobile apps:- End user clicks a call button in your web or mobile app
- Your app uses the RevRing SDK to connect them to one of your AI agents
- The call bridges through your connected Twilio account
- End user speaks directly with your agent through their device microphone and speakers
- After the call ends, you receive full transcript, recording, and analytics just like phone calls
WebRTC calls appear in your call logs with a “WebRTC” badge for easy identification. All features like transcripts, recordings, webhooks, and custom tools work exactly the same as regular phone calls.
Prerequisites
Before you begin:- Active RevRing account with at least one configured agent
- Your own Twilio account (can be the same account used for your SIP trunk)
- At least one phone number assigned to your agent for inbound routing
Twilio Rates
RevRing WebRTC uses your own Twilio account - Twilio might charge you the following:- User call leg: $0.004/minute
- Agent call leg: $0.004/minute
- Total: around $0.008/minute (check Twilio’s website to calculate your cost)
RevRing does not charge any additional fees for WebRTC. You only pay Twilio voice rates on your own Twilio account. Your existing RevRing plan covers WebRTC calls just like regular phone calls.
Setup
Step 1: Connect Your Twilio Account
- Navigate to Developer → WebRTC in your RevRing dashboard
- You’ll need two values from your Twilio Console:
Get Your Twilio Account SID
- Log into Twilio Console
- From the console homepage, copy your Account SID
- Paste it into the Twilio Account SID field in RevRing
Get Your Twilio Auth Token
- In the Twilio Console, click Show next to Auth Token
- Copy the Auth Token
- Paste it into the Twilio Auth Token field in RevRing
- Click Set Up WebRTC to submit the form
Step 2: Assign a Phone Number to Your Agent
Your agent needs at least one assigned phone number for WebRTC routing:- Navigate to Agents and select your agent
- Go to the Phone Numbers tab
- Add an inbound number in E.164 format:
- Click Add Number
JavaScript SDK
The RevRing JavaScript SDK works in any modern browser and supports TypeScript out of the box.Installation
Install the SDK via npm:Basic Usage
Here’s a minimal example of a call button:Configuration Options
Initialize Client
Start Call Options
Call Events
The call object returned bystartCall() emits several events:
Methods
startCall(options)
Initiates a WebRTC call to connect the end user with one of your agents.
Parameters:
to(string, required): Phone number assigned to your agent (E.164 format)twilioLogLevel(string, optional): Log level for debuggingapiBaseUrl(string, optional): Override API base URL
hangupAll()
Disconnects all active calls.
destroy()
Cleans up the SDK and releases resources. Call this when unmounting your component or page.
Complete Example
Here’s a full implementation with UI state management:Mobile SDKs
WebRTC support extends beyond the browser. Build native mobile experiences with our platform SDKs:- iOS SDK: Native Swift implementation for iPhone and iPad apps
- Android SDK: Native Kotlin/Java implementation for Android devices
- React Native SDK: Cross-platform support for React Native apps
Best Practices
Microphone Permissions
Modern browsers require user interaction (like a button click) before accessing the microphone. Always initiate calls from an end user action:Error Handling
Handle permission denials gracefully:Resource Cleanup
Always clean up when your component unmounts or page unloads:Testing
Test your WebRTC implementation thoroughly:- Test with microphone permissions granted and denied
- Test hang up during connecting state
- Test hang up during active call
- Test network interruptions
- Test on different browsers (Chrome, Safari, Firefox, Edge)
- Test on mobile browsers (iOS Safari, Android Chrome)
Embedding on Your Website
To add a call widget to your website, build your widget as a standalone page and embed it using an iframe. Host your widget on platforms like Cloudflare Pages, Vercel, or AWS S3/CloudFront, then embed it in your main website:The
allow="microphone" attribute is required for WebRTC calls to work inside an iframe.Monitoring Calls
WebRTC calls appear in your Call Logs with a “WebRTC” badge in the “From” column. All standard call features are available:- Full conversation transcript
- Call recording playback
- Call duration and status
- Pre-call and post-call webhook data
- Custom tool invocations
Troubleshooting
”Failed to get WebRTC token”
Cause: Twilio account not configured or phone number not assigned to an agent. Solution:- Verify WebRTC is configured in Developer → WebRTC
- Verify the phone number is assigned to an agent in the agent’s Phone Numbers tab
”Permission denied” errors
Cause: End user denied microphone access or browser doesn’t support microphone API. Solution:- Ensure calls are triggered from end user interactions (button clicks)
- Check browser permissions and prompt end user to allow microphone access
- Test in a supported browser (Chrome, Safari, Firefox, Edge)
Calls not connecting
Cause: Invalid phone number or agent offline. Solution:- Verify the phone number is in E.164 format (
+12025551234) - Verify the agent status is “Active”
- Check Call Logs for error details
No audio in call
Cause: Browser audio permissions or speaker issues. Solution:- Check browser permissions for microphone and speaker
- Verify device audio output is working
- Test with headphones to rule out speaker issues