mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-25 08:48:13 +02:00
feat: add vonage telephony
This commit is contained in:
parent
a01f2df7ea
commit
26a9ae2381
35 changed files with 2031 additions and 539 deletions
|
|
@ -55,6 +55,7 @@
|
|||
"pages": [
|
||||
"integrations/telephony/overview",
|
||||
"integrations/telephony/twilio",
|
||||
"integrations/telephony/vonage",
|
||||
"integrations/telephony/webhooks",
|
||||
"integrations/telephony/custom"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Dograh AI provides a flexible integration architecture that allows you to connec
|
|||
Connect your voice agents with telephony services to make and receive calls.
|
||||
|
||||
<Card title="Telephony Providers" href="/integrations/telephony/overview">
|
||||
Configure telephony providers like Twilio, Vonage, and Plivo for voice communication
|
||||
Configure telephony providers like Twilio and Vonage for voice communication
|
||||
</Card>
|
||||
|
||||
### Future Integration Categories
|
||||
|
|
@ -25,7 +25,7 @@ The integration architecture is designed to support additional categories in the
|
|||
Our integration system follows these core principles:
|
||||
|
||||
- **Provider Abstraction**: All integrations implement a common interface, making it easy to switch between providers
|
||||
- **Configuration Flexibility**: Support for both environment-based (OSS) and database-based (SaaS) configuration
|
||||
- **Configuration Flexibility**: Database-based configuration through the web interface
|
||||
- **Backward Compatibility**: New integrations don't break existing implementations
|
||||
- **Secure by Default**: All credentials are encrypted and never exposed in logs or UI
|
||||
|
||||
|
|
@ -33,12 +33,12 @@ Our integration system follows these core principles:
|
|||
|
||||
1. Choose the integration category you need
|
||||
2. Follow the provider-specific setup guide
|
||||
3. Configure credentials through the UI or environment variables
|
||||
3. Configure credentials through the UI
|
||||
4. Test your integration with the provided verification tools
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Store credentials securely using environment variables (OSS) or database configuration (SaaS)
|
||||
- Store credentials securely using database configuration
|
||||
- Test integrations in a development environment before production deployment
|
||||
- Use the provider abstraction to maintain clean separation between business logic and provider specifics
|
||||
- Monitor integration health through application logs
|
||||
|
|
@ -47,4 +47,4 @@ Our integration system follows these core principles:
|
|||
|
||||
- Check provider-specific documentation for detailed setup instructions
|
||||
- Visit our [GitHub Issues](https://github.com/dograh-hq/dograh/issues) for community support
|
||||
- Join our [Slack community](https://join.slack.com/t/dograh-ai/shared_invite/zt-2u29h3bkm-RrkJ2f2B5lvTVZo0ZQ1MMA) for assistance
|
||||
- Join our [Slack community](https://join.slack.com/t/dograh-community/shared_invite/zt-3czr47sw5-MSg1J0kJ7IMPOCHF~03auQ) for assistance
|
||||
|
|
@ -57,6 +57,10 @@ class TelephonyProvider(ABC):
|
|||
) -> str:
|
||||
"""Generate initial webhook response."""
|
||||
pass
|
||||
|
||||
async def get_call_cost(self, call_id: str) -> Dict[str, Any]:
|
||||
"""Get cost information for a completed call."""
|
||||
pass
|
||||
```
|
||||
|
||||
## Implementation Guide
|
||||
|
|
@ -107,15 +111,17 @@ Update `api/services/telephony/factory.py` to include your provider:
|
|||
from api.services.telephony.providers.your_provider import YourProvider
|
||||
|
||||
async def get_telephony_provider(
|
||||
organization_id: Optional[int] = None
|
||||
organization_id: int
|
||||
) -> TelephonyProvider:
|
||||
"""Factory function to get appropriate telephony provider."""
|
||||
|
||||
config = await load_telephony_config(organization_id)
|
||||
provider_type = config.get("provider", "twilio").lower()
|
||||
provider_type = config.get("provider", "twilio")
|
||||
|
||||
if provider_type == "twilio":
|
||||
return TwilioProvider(config)
|
||||
elif provider_type == "vonage":
|
||||
return VonageProvider(config)
|
||||
elif provider_type == "your_provider":
|
||||
return YourProvider(config)
|
||||
else:
|
||||
|
|
@ -124,31 +130,28 @@ async def get_telephony_provider(
|
|||
|
||||
### 3. Add Configuration Support
|
||||
|
||||
For OSS deployment (environment variables):
|
||||
|
||||
```bash
|
||||
# .env
|
||||
TELEPHONY_PROVIDER=your_provider
|
||||
YOUR_PROVIDER_API_KEY=your_api_key
|
||||
YOUR_PROVIDER_API_SECRET=your_api_secret
|
||||
YOUR_PROVIDER_FROM_NUMBER=+1234567890
|
||||
```
|
||||
|
||||
Update the configuration loader in `factory.py`:
|
||||
Update the configuration loader in `factory.py` to handle your provider's database configuration:
|
||||
|
||||
```python
|
||||
# In load_telephony_config function
|
||||
if provider == "your_provider":
|
||||
return {
|
||||
"provider": "your_provider",
|
||||
"api_key": os.getenv("YOUR_PROVIDER_API_KEY"),
|
||||
"api_secret": os.getenv("YOUR_PROVIDER_API_SECRET"),
|
||||
"from_numbers": [os.getenv("YOUR_PROVIDER_FROM_NUMBER")]
|
||||
"api_key": config.value.get("api_key"),
|
||||
"api_secret": config.value.get("api_secret"),
|
||||
"from_numbers": config.value.get("from_numbers", [])
|
||||
}
|
||||
```
|
||||
|
||||
The configuration will be stored in the database under the `TELEPHONY_CONFIGURATION` key in the `organization_configuration` table and managed through the web interface.
|
||||
|
||||
## Audio Format Considerations
|
||||
|
||||
Different providers use different audio formats. Twilio uses MULAW at 8000 Hz encoded in Base64. Your provider may differ, so ensure proper audio format conversion in your WebSocket handler.
|
||||
Different providers use different audio formats:
|
||||
- **Twilio**: 8kHz μ-law (MULAW) encoded in Base64
|
||||
- **Vonage**: 16kHz Linear PCM as binary frames
|
||||
|
||||
Your provider may differ, so ensure proper audio format conversion in your WebSocket handler and configure the audio pipeline accordingly.
|
||||
|
||||
## Testing
|
||||
|
||||
|
|
@ -179,6 +182,13 @@ async def test_validate_config():
|
|||
4. **Configuration Validation**: Validate config on initialization
|
||||
5. **Security**: Always verify webhook signatures
|
||||
|
||||
## Reference Implementation
|
||||
## Reference Implementations
|
||||
|
||||
See the Twilio provider implementation at `api/services/telephony/providers/twilio_provider.py` for a complete example.
|
||||
See these provider implementations for complete examples:
|
||||
- **Twilio**: `api/services/telephony/providers/twilio_provider.py` - Basic authentication, XML (TwiML) responses
|
||||
- **Vonage**: `api/services/telephony/providers/vonage_provider.py` - JWT authentication, JSON (NCCO) responses
|
||||
|
||||
<Note>
|
||||
Other providers like Plivo, Telnyx, or custom SIP providers can be implemented following the same pattern.
|
||||
These are not included out-of-the-box but can be easily added by implementing the TelephonyProvider interface.
|
||||
</Note>
|
||||
|
|
@ -9,11 +9,13 @@ Dograh AI's telephony integration system provides a unified interface for connec
|
|||
|
||||
## Supported Providers
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Twilio" href="/integrations/telephony/twilio">
|
||||
Industry-leading cloud communications platform with global reach
|
||||
</Card>
|
||||
{/* Additional providers can be added in the future by implementing the TelephonyProvider interface */}
|
||||
<Card title="Vonage" href="/integrations/telephony/vonage">
|
||||
High-quality voice with 16kHz audio and excellent international coverage
|
||||
</Card>
|
||||
<Card title="Custom Provider" href="/integrations/telephony/custom">
|
||||
Build your own telephony provider integration
|
||||
</Card>
|
||||
|
|
@ -25,30 +27,19 @@ The telephony integration system uses a provider abstraction pattern that ensure
|
|||
|
||||
```python
|
||||
# All providers implement this interface
|
||||
class TelephonyProvider:
|
||||
async def initiate_call(to_number, webhook_url, ...)
|
||||
async def get_call_status(call_id)
|
||||
async def verify_webhook_signature(url, params, signature)
|
||||
# ... more methods
|
||||
class TelephonyProvider(ABC):
|
||||
async def initiate_call(to_number: str, webhook_url: str, workflow_run_id: Optional[int] = None, **kwargs)
|
||||
async def get_call_status(call_id: str) -> Dict[str, Any]
|
||||
async def get_available_phone_numbers() -> List[str]
|
||||
def validate_config() -> bool
|
||||
async def verify_webhook_signature(url: str, params: Dict, signature: str) -> bool
|
||||
async def get_webhook_response(workflow_id: int, user_id: int, workflow_run_id: int) -> str
|
||||
async def get_call_cost(call_id: str) -> Dict[str, Any]
|
||||
```
|
||||
|
||||
## Configuration Methods
|
||||
## Configuration
|
||||
|
||||
### OSS Deployment (Environment Variables)
|
||||
|
||||
For self-hosted deployments, configure your telephony provider using environment variables:
|
||||
|
||||
```bash
|
||||
# .env file
|
||||
TELEPHONY_PROVIDER=twilio # Required to specify which provider to use
|
||||
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
TWILIO_AUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
TWILIO_FROM_NUMBER=+1234567890
|
||||
```
|
||||
|
||||
### SaaS Deployment (Database Configuration)
|
||||
|
||||
For cloud deployments, configure providers through the web interface:
|
||||
Dograh AI uses database configuration for all telephony providers. Configure providers through the web interface:
|
||||
|
||||
1. Navigate to **Settings** → **Integrations** → **Telephony**
|
||||
2. Select your provider
|
||||
|
|
@ -64,6 +55,30 @@ The telephony integration in Dograh AI supports:
|
|||
- **WebSocket Streaming**: Real-time audio streaming for voice agents
|
||||
- **Webhook Authentication**: Secure webhook signature verification
|
||||
|
||||
## Code Usage
|
||||
|
||||
Here's how to use the telephony provider in your code:
|
||||
|
||||
```python
|
||||
from api.services.telephony.factory import get_telephony_provider
|
||||
|
||||
# Get provider based on organization configuration
|
||||
provider = await get_telephony_provider(organization_id)
|
||||
|
||||
# Initiate a call
|
||||
result = await provider.initiate_call(
|
||||
to_number="+1234567890",
|
||||
webhook_url="https://your-domain.com/webhook",
|
||||
workflow_run_id=123
|
||||
)
|
||||
|
||||
# Check call status
|
||||
status = await provider.get_call_status(result["call_id"])
|
||||
|
||||
# Get call cost after completion
|
||||
cost_info = await provider.get_call_cost(result["call_id"])
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
The telephony system exposes these unified endpoints:
|
||||
|
|
@ -72,16 +87,18 @@ The telephony system exposes these unified endpoints:
|
|||
|----------|---------|-------------|
|
||||
| `/api/v1/telephony/initiate-call` | POST | Start an outbound call |
|
||||
| `/api/v1/telephony/status-callback/{id}` | POST | Receive call status updates |
|
||||
| `/api/v1/telephony/twiml` | POST | Handle initial webhook |
|
||||
| `/api/v1/telephony/webhook/{id}` | GET/POST | Handle initial webhook |
|
||||
| `/api/v1/telephony/ws/{id}` | WebSocket | Real-time audio streaming |
|
||||
|
||||
## Implementation Status
|
||||
|
||||
- **Twilio**: ✅ Fully implemented and tested
|
||||
- **Vonage**: ✅ Fully implemented with 16kHz audio support
|
||||
- **Custom Providers**: The abstraction layer supports adding new providers by implementing the `TelephonyProvider` interface
|
||||
- **API Endpoints**: All telephony operations use the unified `/api/v1/telephony/*` endpoints:
|
||||
- `/api/v1/telephony/initiate-call` - Start outbound calls
|
||||
- `/api/v1/telephony/status-callback/{id}` - Receive call status updates
|
||||
- `/api/v1/telephony/status-callback/{id}` - Receive call status updates
|
||||
- `/api/v1/telephony/webhook/{workflow_id}/{user_id}/{workflow_run_id}` - Initial call webhook
|
||||
- `/api/v1/telephony/ws/{workflow_id}/{user_id}/{workflow_run_id}` - WebSocket for audio streaming
|
||||
|
||||
## Troubleshooting
|
||||
|
|
@ -98,7 +115,9 @@ The telephony system exposes these unified endpoints:
|
|||
- Check network bandwidth and latency
|
||||
- Verify audio codec compatibility
|
||||
- Review WebSocket connection stability
|
||||
- Ensure proper audio format (MULAW for Twilio)
|
||||
- Ensure proper audio format:
|
||||
- Twilio: 8kHz μ-law (MULAW)
|
||||
- Vonage: 16kHz Linear PCM
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Webhook signature validation failing">
|
||||
|
|
|
|||
|
|
@ -39,37 +39,14 @@ Watch this step-by-step guide to set up Twilio with Dograh AI:
|
|||
|
||||
### Step 2: Configure in Dograh AI
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Web Interface (SaaS)">
|
||||
1. Navigate to **Settings** → **Integrations** → **Telephony**
|
||||
2. Select **Twilio** as your provider
|
||||
3. Enter your credentials:
|
||||
- Account SID
|
||||
- Auth Token
|
||||
- Phone Numbers (comma-separated if multiple)
|
||||
4. Click **Test Connection**
|
||||
5. Save configuration
|
||||
</Tab>
|
||||
|
||||
<Tab title="Environment Variables (OSS)">
|
||||
Add these variables to your `.env` file:
|
||||
|
||||
```bash
|
||||
# Telephony Configuration
|
||||
TELEPHONY_PROVIDER=twilio # Specifies Twilio as the telephony provider
|
||||
TWILIO_ACCOUNT_SID="ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
TWILIO_AUTH_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
TWILIO_FROM_NUMBER="+1234567890"
|
||||
# For multiple numbers, use comma separation:
|
||||
# TWILIO_FROM_NUMBER="+1234567890,+0987654321"
|
||||
```
|
||||
|
||||
Restart your Dograh AI services:
|
||||
```bash
|
||||
docker-compose restart api
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
1. Navigate to **Settings** → **Integrations** → **Telephony**
|
||||
2. Select **Twilio** as your provider
|
||||
3. Enter your credentials:
|
||||
- Account SID
|
||||
- Auth Token
|
||||
- Phone Numbers (comma-separated if multiple)
|
||||
4. Click **Test Connection**
|
||||
5. Save configuration
|
||||
|
||||
### Step 3: Test Your Configuration
|
||||
|
||||
|
|
@ -122,6 +99,6 @@ When using Twilio with campaigns:
|
|||
|
||||
## Best Practices
|
||||
|
||||
- Store credentials securely in environment variables (OSS) or database (SaaS)
|
||||
- Store credentials securely in the database
|
||||
- Test your configuration with a single call before running campaigns
|
||||
- Monitor Twilio Console for usage and billing
|
||||
202
docs/integrations/telephony/vonage.mdx
Normal file
202
docs/integrations/telephony/vonage.mdx
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
---
|
||||
title: "Vonage Integration"
|
||||
description: "Configure Vonage (Nexmo) for voice communication in Dograh AI"
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Vonage (formerly Nexmo) is a cloud communications platform that provides global voice, messaging, and video capabilities. Dograh AI's Vonage integration enables high-quality voice interactions with your agents using Vonage's robust infrastructure.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before setting up Vonage integration, you'll need:
|
||||
|
||||
- A [Vonage account](https://www.vonage.com/communications-apis/)
|
||||
- Vonage Application with Voice capability enabled
|
||||
- Application ID and Private Key from your Vonage Dashboard
|
||||
- At least one Vonage phone number
|
||||
- Dograh AI instance running and accessible
|
||||
|
||||
## Configuration
|
||||
|
||||
### Step 1: Create Vonage Application
|
||||
|
||||
1. Log in to your [Vonage Dashboard](https://dashboard.nexmo.com/)
|
||||
2. Navigate to **Applications** → **Create a new application**
|
||||
3. Enable **Voice** capability
|
||||
4. Generate a private key (save this securely - you'll need it)
|
||||
5. Note your **Application ID**
|
||||
|
||||
### Step 2: Get API Credentials
|
||||
|
||||
1. Find your **API Key** and **API Secret** in the dashboard
|
||||
2. Navigate to **Numbers** → **Your Numbers**
|
||||
3. Copy your phone number(s)
|
||||
4. Link your numbers to your application
|
||||
|
||||
### Step 3: Configure in Dograh AI
|
||||
|
||||
1. Navigate to **Settings** → **Integrations** → **Telephony**
|
||||
2. Select **Vonage** as your provider
|
||||
3. Enter your credentials:
|
||||
- Application ID
|
||||
- Private Key (entire key including BEGIN/END lines)
|
||||
- API Key
|
||||
- API Secret
|
||||
- Phone Numbers (comma-separated if multiple)
|
||||
4. Click **Test Connection**
|
||||
5. Save configuration
|
||||
|
||||
### Step 4: Test Your Configuration
|
||||
|
||||
1. Create a test workflow
|
||||
2. Click "Test Call" to verify connection
|
||||
3. Check call logs for successful connection
|
||||
|
||||
## How It Works
|
||||
|
||||
### Technical Details
|
||||
|
||||
Vonage integration differs from other providers in key ways:
|
||||
|
||||
- **Audio Format**: Uses 16kHz Linear PCM (vs Twilio's 8kHz μ-law)
|
||||
- **Protocol**: NCCO (Nexmo Call Control Objects) instead of TwiML
|
||||
- **Authentication**: JWT-based authentication using private keys
|
||||
- **WebSocket**: Binary audio frames instead of base64-encoded
|
||||
|
||||
### Call Flow
|
||||
|
||||
1. Dograh AI generates a JWT token using your private key
|
||||
2. Call is initiated via Vonage Voice API
|
||||
3. Vonage requests NCCO instructions at the webhook URL
|
||||
4. Dograh returns WebSocket connection details
|
||||
5. Audio streams as 16kHz PCM over WebSocket
|
||||
6. Real-time voice interaction occurs with your agent
|
||||
|
||||
### NCCO Response Example
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"action": "connect",
|
||||
"endpoint": [{
|
||||
"type": "websocket",
|
||||
"uri": "wss://your-domain/api/v1/telephony/ws/123/456/789",
|
||||
"content-type": "audio/l16;rate=16000",
|
||||
"headers": {}
|
||||
}]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Campaign Features
|
||||
|
||||
When using Vonage with campaigns:
|
||||
- **Global Reach**: Excellent international call quality and coverage
|
||||
- **Number Pool Management**: Automatic rotation of configured numbers
|
||||
- **Call Analytics**: Detailed metrics via Vonage Dashboard
|
||||
- **Cost Tracking**: Per-call cost calculation for billing
|
||||
|
||||
## Audio Quality Optimization
|
||||
|
||||
Vonage uses higher quality audio (16kHz) which provides:
|
||||
- Clearer voice reproduction
|
||||
- Better speech recognition accuracy
|
||||
- More natural-sounding TTS output
|
||||
- Reduced transcription errors
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Voice application capabilities error">
|
||||
- Ensure "Voice" is enabled in your Vonage application
|
||||
- Verify the application ID matches your configuration
|
||||
- Check that your phone numbers are linked to the application
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="JWT authentication failed">
|
||||
- Verify your private key is complete (including BEGIN/END lines)
|
||||
- Check the Application ID is correct
|
||||
- Ensure the private key hasn't been regenerated in Vonage Dashboard
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Invalid phone number error">
|
||||
- Remove the '+' prefix for Vonage (use `1234567890` not `+1234567890`)
|
||||
- Ensure numbers are in E.164 format without the '+'
|
||||
- Verify numbers are active in your Vonage account
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="No audio on calls">
|
||||
- Verify WebSocket connection is established
|
||||
- Check audio pipeline is configured for 16kHz PCM
|
||||
- Monitor WebSocket for binary audio frames
|
||||
- Review VAD (Voice Activity Detection) settings
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Calls disconnecting early">
|
||||
- Check WebSocket heartbeat/ping-pong frames
|
||||
- Verify no timeout in load balancer/proxy
|
||||
- Monitor for audio pipeline errors
|
||||
- Review max call duration settings
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
## Best Practices
|
||||
|
||||
- **Security**: Private keys are stored securely in the database
|
||||
- **Testing**: Use Vonage Voice Inspector for debugging call issues
|
||||
- **Numbers**: Configure multiple numbers for redundancy
|
||||
- **Monitoring**: Set up alerts in Vonage Dashboard for failures
|
||||
- **Cost Management**: Monitor usage to control costs
|
||||
|
||||
## Cost Considerations
|
||||
|
||||
Vonage pricing includes:
|
||||
- Per-minute charges for calls
|
||||
- Phone number rental fees
|
||||
- Optional features (recording, transcription)
|
||||
|
||||
Check [Vonage pricing](https://www.vonage.com/communications-apis/voice/pricing/) for current rates.
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
### Custom Headers
|
||||
|
||||
Add custom headers to WebSocket connections:
|
||||
|
||||
```python
|
||||
# In your webhook response
|
||||
"headers": {
|
||||
"X-Custom-Header": "value",
|
||||
"Authorization": "Bearer token"
|
||||
}
|
||||
```
|
||||
|
||||
### Call Recording
|
||||
|
||||
Enable call recording via NCCO:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "record",
|
||||
"eventUrl": ["https://your-domain/recording-webhook"],
|
||||
"format": "mp3"
|
||||
}
|
||||
```
|
||||
|
||||
## API Differences from Twilio
|
||||
|
||||
| Feature | Twilio | Vonage |
|
||||
|---------|---------|---------|
|
||||
| Audio Format | 8kHz μ-law | 16kHz Linear PCM |
|
||||
| Control Format | TwiML (XML) | NCCO (JSON) |
|
||||
| Authentication | Basic Auth | JWT |
|
||||
| WebSocket Data | Base64 text | Binary frames |
|
||||
| Phone Format | With '+' | Without '+' |
|
||||
|
||||
## Next Steps
|
||||
|
||||
- Test your Vonage integration with a simple workflow
|
||||
- Configure VAD settings for optimal voice detection
|
||||
- Set up monitoring and alerts
|
||||
- Explore advanced features like call recording
|
||||
|
|
@ -13,19 +13,36 @@ Dograh AI uses webhooks to communicate with telephony providers for call events
|
|||
|
||||
When a call is initiated, the telephony provider requests instructions.
|
||||
|
||||
**Endpoint**: `/api/v1/telephony/twiml`
|
||||
**Endpoint**: `/api/v1/telephony/webhook/{workflow_id}/{user_id}/{workflow_run_id}`
|
||||
|
||||
**Purpose**: Returns provider-specific instructions (TwiML for Twilio)
|
||||
**Purpose**: Returns provider-specific instructions
|
||||
|
||||
**Example Response**:
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Response>
|
||||
<Connect>
|
||||
<Stream url="wss://your-domain/api/v1/telephony/ws/123/456/789" />
|
||||
</Connect>
|
||||
</Response>
|
||||
```
|
||||
<Tabs>
|
||||
<Tab title="Twilio (TwiML)">
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Response>
|
||||
<Connect>
|
||||
<Stream url="wss://your-domain/api/v1/telephony/ws/123/456/789" />
|
||||
</Connect>
|
||||
</Response>
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="Vonage (NCCO)">
|
||||
```json
|
||||
[
|
||||
{
|
||||
"action": "connect",
|
||||
"endpoint": [{
|
||||
"type": "websocket",
|
||||
"uri": "wss://your-domain/api/v1/telephony/ws/123/456/789",
|
||||
"content-type": "audio/l16;rate=16000"
|
||||
}]
|
||||
}
|
||||
]
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### 2. Status Callback
|
||||
|
||||
|
|
@ -48,14 +65,21 @@ Real-time audio streaming for voice interaction.
|
|||
|
||||
**Endpoint**: `/api/v1/telephony/ws/{workflow_id}/{user_id}/{workflow_run_id}`
|
||||
|
||||
**Audio Formats**:
|
||||
- **Twilio**: 8kHz μ-law (MULAW), Base64-encoded in JSON messages
|
||||
- **Vonage**: 16kHz Linear PCM, Binary frames
|
||||
|
||||
## How It Works
|
||||
|
||||
Dograh AI automatically:
|
||||
1. Constructs webhook URLs based on your deployment
|
||||
2. Passes them to the telephony provider when initiating calls
|
||||
3. Verifies webhook signatures for security
|
||||
3. Verifies webhook signatures for security:
|
||||
- **Twilio**: HMAC-SHA1 signature validation
|
||||
- **Vonage**: JWT token verification
|
||||
4. Processes status updates to track call lifecycle
|
||||
5. Manages WebSocket connections for audio streaming
|
||||
6. Handles provider-specific audio formats and protocols
|
||||
|
||||
## Local Development
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue