How frejun-tech/teler-openai-sip-trunking works
This is a compact FastAPI reference integration for inbound Teler-to-OpenAI voice calls. A caller reaches OpenAI through Teler’s SIP trunk; OpenAI notifies the server, which verifies and deduplicates the webhook, acknowledges it, then accepts the call in a background task. The server configures a control WebSocket for greetings, transcription, and optional human transfer; call audio stays directly between Teler and OpenAI. Components are concentrated in main.py, so several nodes represent distinct responsibilities within that file.
Main entry points: main.py Control WebSocket
Components 13
Webhook ingress
- Webhook endpoint
main.py - Verify and dedupe
main.py - Health endpoint
main.py
Call control
- Call handler
main.py - Accept call
main.py - Agent settings
main.py
Live session
- Control WebSocket
main.py - Session setup
main.py - Event handling
main.py - Human transfer
main.py
Other components
- Caller
- Teler SIP trunk
- OpenAI Realtime
Connections 18
- Caller → Teler SIP trunk: dials
- Teler SIP trunk → OpenAI Realtime: forwards SIP
- Teler SIP trunk → OpenAI Realtime: carries audio
- OpenAI Realtime → Webhook endpoint: incoming event
- Webhook endpoint → Verify and dedupe: verifies and dedupes
- Verify and dedupe → OpenAI Realtime: acknowledges
- Verify and dedupe → Call handler: dispatches background
- Call handler → Accept call: calls
- Accept call → Agent settings: reads
- Accept call → OpenAI Realtime: accepts call
- Call handler → Control WebSocket: opens after acceptance
- Control WebSocket → Session setup: sends session setup
- Session setup → Agent settings: reads
- Control WebSocket → OpenAI Realtime: sends greeting and settings
- OpenAI Realtime → Control WebSocket: streams events
- Control WebSocket → Event handling: dispatches events
- Event handling → Human transfer: dispatches tool call
- Human transfer → OpenAI Realtime: requests REFER