Overview
The Outbox Web SDK (@outbox-ai/web) lets you start Outbox voice calls directly in your web application. Use it to create custom voice interfaces, embed AI calls into websites, and build interactive voice experiences.NPM Package: Install the SDK with
npm install @outbox-ai/webInstallation
You can install the package via npm:Quick Start
1. Import the SDK
2. Create an Instance
3. Start a Call
You can start a call by passing either an agent configuration object or an agent ID:Core Methods
Start a Call
Start a new voice call. You can pass either an agent ID or a complete agent configuration.Using Agent ID
Using Agent Configuration
Override Agent Parameters
You can override existing agent parameters or set variables:recordingEnabled
recordingEnabled
Enable or disable call recording (boolean)
variableValues
variableValues
Set variable values for your agent prompts (object)Example:
Stop a Call
Stop the current call and close the connection:Send Messages
Send text messages to the agent during the call:system
System instructions for the agent
user
User messages or context
assistant
Assistant responses
tool
Tool function results
Mute/Unmute
Control the user’s microphone:Say Message
Make the agent speak a specific message and optionally end the call:message(string) - The message for the agent to speakendCallAfterSpoken(boolean, optional) - If true, end the call after speaking
Events
Listen to call events to react to state changes:Speech Events
Call Events
Volume Level
Messages
Function calls and transcripts are sent via the message event:Error Handling
Complete Example
Here’s a complete example of integrating the Outbox SDK into a web application:Use Cases
Custom Voice Interfaces
Custom Voice Interfaces
Build completely custom voice interfaces for your web applications. Control every aspect of the call experience, from UI to behavior.
Website Integration
Website Integration
Add voice capabilities to your existing website. Let visitors speak with AI agents directly from any page.
Web Apps
Web Apps
Integrate voice calling into web applications like dashboards, admin panels, or customer portals.
Progressive Web Apps
Progressive Web Apps
Create voice-enabled PWAs that work offline and provide native-like experiences across devices.
Kiosk Applications
Kiosk Applications
Build kiosk applications where users can interact with AI agents via voice without traditional interfaces.
Best Practices
Handle Connection States
Handle Connection States
Always listen to
call-start and call-end events to update your UI and prevent duplicate calls.Error Handling
Error Handling
Implement robust error handling to gracefully handle network issues, permission errors, or API failures.
Microphone Permissions
Microphone Permissions
Request microphone permissions before starting a call, and handle cases where users deny access.
UI Feedback
UI Feedback
Provide visual feedback for all call states: connecting, active, speaking, listening, error, and disconnected.
Clean Up
Clean Up
Always call
outbox.stop() when the user navigates away or when your component unmounts.Troubleshooting
Microphone Not Working
Microphone Not Working
- Check browser permissions for microphone access
- Ensure the site is using HTTPS (required for media devices)
- Try different browsers to rule out browser-specific issues
Call Won't Start
Call Won't Start
- Verify your agent ID is correct
- Check network connectivity
- Review browser console for error messages
- Ensure the agent exists and is active
No Audio Heard
No Audio Heard
- Check system volume settings
- Verify audio output devices are working
- Review event logs for audio-related errors
Events Not Firing
Events Not Firing
- Ensure event listeners are set up before starting the call
- Check browser console for JavaScript errors
- Verify SDK version is up to date
TypeScript Support
The package includes built-in TypeScript declarations:Package Information
- Package Name:
@outbox-ai/web - Latest Version: 1.0.3
- Repository: GitHub
- NPM: @outbox-ai/web

