Dynamic Outbound VoIP Configuration
Dynamic Outbound VoIP Configuration
Overview
When working with VoIP integrations in Dasha, you can configure outbound calls dynamically without creating new configurations for each client. This guide explains how to implement dynamic VoIP configuration and troubleshoot common issues.
Dynamic Configuration Methods
Using DashaScript Functions
Instead of creating static configurations, you can pass VoIP settings directly through DashaScript's built-in functions:
// Configure connection options and establish connection #connectSafe($phone, { sip_fromUser: "YOUR_DID", // Phone number/DID to use as caller ID sip_authUser: "TWILIO_AUTH_USER", // Authentication username sip_authPassword: "TWILIO_AUTH_PASSWORD", // Authentication password sip_server: "your-trunk.pstn.twilio.com" // SIP server address });
The dynamic configuration approach works with any SIP-compliant carrier or PBX system. While we use Twilio in the example below, you can apply the same pattern with other providers like Avaya, Five9, Genesys, RingCentral, or any custom SIP server - just adjust the server address and credentials accordingly.
Twilio Integration Example
For Twilio integration:
- Create a single SIP trunk in Twilio
- Configure multiple phone numbers under this trunk
- Use
sip_fromUser
to specify which number to use for outbound calls - Extract call information using
#getConnectOptions()
:
// Get Twilio Call SID for billing information var result = #getConnectOptions(); var sid = result.options.sip_X_Twilio_CallSid;
Troubleshooting
Config Deletion (409 Error)
If you receive a 409 error when trying to delete a configuration:
{ "reason": "Config is currently in use. Id: 5da85f7f-b5a0-4d3e-9b24-7c95db478ab3." }
This occurs because there is a running application using the configuration. To resolve:
- Stop all running applications using the configuration
- Wait for any active calls to complete
- Try deleting the configuration again
Best Practices
- Use a single trunk configuration for multiple DIDs when possible
- Implement proper error handling for dynamic configuration
- Store sensitive credentials securely
- Monitor active configurations and clean up unused ones
- Use logging to track configuration usage and troubleshoot issues