Skip to main content

Overview

Iqra AI supports SIP trunking for enterprise-grade telephony deployment. Connect your existing phone infrastructure or use cloud telephony providers to route calls through Iqra AI’s conversational agents. The platform implements a two-tier SIP architecture:
  • Proxy layer - Load balances incoming SIP INVITE requests across backend servers
  • Backend layer - Handles media processing and AI conversation orchestration

Supported providers

Iqra AI integrates with multiple telephony providers:

Twilio configuration

Twilio uses TwiML and WebSocket streaming for real-time audio.Authentication: Basic auth with Account SID and Auth TokenKey features:
  • Voice URL webhook configuration
  • Status callback for call lifecycle events
  • Media streaming via WebSocket
  • Support for both inbound and outbound calls
Implementation: See IqraInfrastructure/Managers/Telephony/TwilioManager.cs:136
Twilio requires VoiceReceiveMode set to “voice” for full-duplex audio streaming.

Architecture

SIP proxy service

The proxy service handles initial call routing and load balancing:
1

Receive SIP INVITE

Proxy listens on configurable port (UDP/TCP) for incoming INVITE requests.
2

Validate business and number

Extract business ID and phone ID from SIP URI parameters:
Validates:
  • Business exists and is active
  • Number is configured for the business
  • Number provider matches (SIP, Twilio, etc.)
  • Route ID is configured
3

Check plan limits

Validates call concurrency limits based on subscription tier before accepting the call.
4

Apply ACL rules

For SIP numbers with IP restrictions, validates source IP against AllowedSourceIps list.
5

Select backend server

Chooses optimal backend server based on:
  • Region affinity
  • Current capacity
  • Admin bypass rules
6

Redirect to backend

Returns 302 Moved Temporarily with Contact header pointing to selected backend:
Source: IqraInfrastructure/Managers/SIP/SipProxyService.cs:134

SIP backend listener

The backend service handles actual media processing:
1

Accept redirected call

Backend listener receives the redirected INVITE with call queue ID parameter.
2

Validate queue entry

Retrieves call queue entry and verifies:
  • Queue exists and is in ProcessedProxy state
  • Region and server ID match
  • Not already processing
3

Create conversation session

Hands off to BackendCallProcessorManager to:
  • Initialize conversation orchestrator
  • Create AI agent
  • Setup telephony client
  • Configure audio pipeline
4

Answer call

Sends SIP 200 OK response with SDP to establish media session.
Source: IqraInfrastructure/Managers/SIP/SipBackendListenerService.cs:99

Deployment patterns

Provider-based routing

Route calls through cloud telephony providers: Use cases:
  • Quick deployment without infrastructure
  • Global phone number provisioning
  • Built-in redundancy and failover

Direct SIP trunking

Connect enterprise PBX directly to Iqra AI: Use cases:
  • Existing telephony infrastructure
  • Regulatory compliance requirements
  • Cost optimization for high call volumes

Hybrid deployment

Combine provider and direct SIP:
  • Use Twilio for US/Canada numbers
  • Use direct SIP for internal extensions
  • Use Telnyx for international markets

Configuration

Number registration

Register phone numbers in the Iqra AI platform:

Provider credentials

Store provider credentials securely:

Audio codecs

Supported audio formats for SIP:

Call lifecycle

Inbound call flow

1

Call initiated

Customer calls your phone number. Provider sends SIP INVITE or webhook to Iqra AI.
2

Proxy routing

SIP proxy validates and routes to available backend server.
3

Session creation

Backend creates conversation session with AI agent and telephony client.
4

Call answered

SIP 200 OK sent, media session established, AI greeting plays.
5

Conversation

Real-time bidirectional audio between customer and AI agent.
6

Call termination

Either party hangs up. Session cleanup, billing recorded, webhooks fired.

Outbound call flow

1

API trigger

Application calls Iqra AI API to initiate outbound call.
2

Provider API call

Backend calls Twilio/Telnyx/Vonage API to dial customer number.
3

Call connects

Provider establishes call, sends audio stream to Iqra AI backend.
4

AI conversation

Same bidirectional conversation flow as inbound calls.

Monitoring and troubleshooting

Call queue tracking

Each call creates an entry in the InboundCallQueue collection:

Common issues

SIP 503 Service Unavailable: No backend servers available in the region. Check server health and capacity limits.
SIP 403 Forbidden: Source IP not in ACL. Add caller IP to AllowedSourceIps for the number.
SIP 404 Not Found: Number or route not configured. Verify number registration and route ID.

Status codes

Best practices

Use regional backends: Deploy backend servers in the same region as your customers to minimize latency.
Configure failover: Set up multiple providers for redundancy. If Twilio fails, route to Telnyx.
Monitor concurrency: Track CallConcurrency metrics to avoid hitting subscription limits during peak hours.
Secure SIP trunks: Always use IP whitelisting for direct SIP connections. Consider TLS for encryption.

Next steps