Overview
A Teler-powered AI calling setup where calls to your Teler virtual number are answered by an OpenAI Realtime voice agent, with natural, low-latency conversations.
Your Teler SIP trunk hands each incoming call directly to OpenAI’s SIP endpoint, and the call audio flows between Teler and OpenAI over an encrypted connection. A lightweight server from the FreJun GitHub repo handles call control: it receives OpenAI’s incoming-call webhook, answers the call with your agent’s instructions and voice, and follows the conversation in real time.
Note: This integration covers inbound calls. A caller dials your Teler virtual number and your OpenAI agent answers.
Key Features
- Direct SIP connection — Calls go straight from your Teler trunk to OpenAI. There’s no media server to host and no audio to resample; your server only handles call control.
- Encrypted end to end — Signaling runs over TLS and call audio over SRTP, as OpenAI requires.
- Ready-to-run reference server — Clone
teler-openai-sip-trunking, add two keys to your.env, and start answering calls. - Full control over your agent — Set the model, voice, instructions, and opening greeting through environment variables, and see live transcripts of both sides of the call in your logs.
How to Integrate
Prerequisite: Creating a SIP Trunk in Teler
A SIP Trunk connects Teler to your own SIP infrastructure — a PBX, SBC, softswitch, or an AI voice platform — over SIP. It defines how Teler authenticates and routes SIP calls to and from that infrastructure, in both directions: inbound origination and outbound termination. Trunks are created and managed from the Teler dashboard under SIP Trunks.
The Create SIP Trunk wizard has three parts: basic trunk configuration, outbound authentication, and inbound routing.
Step 1: Basic trunk configuration
| Field | Required | Description |
|---|---|---|
| SIP trunk name | Yes | Internal label shown in the dashboard, e.g. “OpenAI Realtime Trunk.” |
| Domain name | Yes | Unique subdomain assigned to the trunk (resolves as your-custom-domain.sip.frejun.ai). This is the Termination URL that all outbound calls route to. Alphanumeric and hyphens only. |
| Call status URL | No | HTTPS endpoint that receives call lifecycle webhooks. |
| Secret | No | Signing secret used for HMAC signatures on webhooks. Rotatable without downtime. |
| Channel limit | No | Maximum concurrent calls on the trunk. Defaults to 0 – increase as needed. |
| Recording | No | When enabled, all call audio is recorded and delivered via recording events. |
| Transport type | TLS/SRTP | Controls transport encryption – see below. Must be enabled for this integration. |
Transport type: SIP over TLS for signaling, SRTP for media.
OpenAI requires TLS and SRTP. OpenAI only accepts SIP over TLS on port 5061, with SRTP-encrypted audio. SIP over TCP or UDP calls won’t connect to OpenAI.
Step 2: Choose outbound authentication
Every trunk authenticates outbound calls one of two ways — pick whichever matches how your downstream SIP system identifies itself; you only need to configure one:
| Method | Best for | Description |
|---|---|---|
| IP authentication | Fixed, static source IPs | Create an IP ACL (Access Control List) – a list of source IPs allowed to send SIP INVITEs – and attach it to the trunk. Calls from an IP in the ACL are authenticated without credentials; anything outside it is rejected. |
| Credential authentication | Dynamic or cloud-based environments where the egress IP can change | Set a username and password on the trunk. Your SIP client presents them on every INVITE. |
IP authentication isn’t suitable for dynamic or cloud-based environments where your SIP client’s egress IP may change; prefer credential authentication in those cases.
- Option A — Create an IP ACL: Name the ACL so it’s identifiable later (e.g., “Test” or “Production Carrier”), add each source IP or CIDR block with Add IP address/CIDR, and label each entry for reference. Once saved, the ACL is reusable across multiple trunks — no need to re-enter the same IPs each time.
- Option B — Set up credential authentication: Set the username and password your SIP client will present on each INVITE.
For this inbound integration, outbound authentication isn’t used by OpenAI — the wizard requires one method, so credential authentication is the simplest choice.
Step 3: Configure inbound routing
Tells Teler where to deliver calls that arrive on the trunk:
| Field | Required | Description |
|---|---|---|
| Inbound routing name | Yes | Internal label for the route. |
| SIP URL | Yes | The SIP URL Teler forwards inbound calls to (the Origination URL). Set the value to: sip:sip.api.openai.com:5061. |
| SIP user | No | Copy your Project ID and paste it in the SIP user field. |
The exact OpenAI values for these fields are covered in the OpenAI setup below.
Step 4: Create the trunk
Review the details across all screens and click Create. The trunk is live immediately — outbound calls authenticate using the method chosen in Step 2, and inbound SIP INVITEs route per the configuration in Step 3.
Step 5: Assign a virtual number to the trunk
A trunk isn’t usable until at least one virtual number is assigned to it — this is a separate step, done from the Virtual numbers section rather than the trunk wizard itself.
- Go to Virtual numbers in the left nav and select the number(s) assigned to your account. If no number is assigned yet, contact the support team to get one provisioned.
- Click Actions → Assign.
- In the Assign virtual numbers dialog, set Assign to as Trunk, use Select trunk to find the trunk you created, and click Assign.
- Back in SIP trunks, open the trunk and check the Numbers tab — the assigned number should appear there, confirming the assignment worked.
Full field reference and API details: Teler Docs – SIP Trunking
To test before going live, create the trunk in sandbox mode and assign the sandbox reference number to it here.
OpenAI Realtime Setup
Note: The steps below set up inbound calls — callers dial your Teler virtual number and are answered by your OpenAI agent.
Prerequisites
- A Teler SIP trunk that is Active, with Transport type set to TLS/SRTP
- A virtual number already assigned to the Teler trunk
- An OpenAI account with a project, its API key, and its project ID (
proj_...), found under Settings → Project → General - Python 3.10+ and a public HTTPS URL for your server (ngrok works for testing)
Step 1: Set Teler’s inbound routing to OpenAI
OpenAI’s SIP address is fixed — each project is identified by its project ID. In your Teler trunk’s inbound routing, set:
| Field | Value |
|---|---|
| SIP URL | sip:sip.api.openai.com:5061 |
| SIP user | Your OpenAI project ID, e.g. proj_XXXXXXXX |
Together, these route calls to sip:proj_XXXXXXXX@sip.api.openai.com:5061. For EU data residency, use sip-eu.api.openai.com instead.
Set the SIP user explicitly — by default Teler presents the callee number, but OpenAI uses the project ID to identify which project should receive the call.
Step 2: Clone and install the reference server
git clone https://github.com/frejun-tech/teler-openai-sip-trunking.git
cd teler-openai-sip-trunking
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtStep 3: Start the server and expose it
uvicorn main:app --port 8000
ngrok http 8000Note the public HTTPS address ngrok gives you.
Step 4: Create the OpenAI webhook
In the OpenAI platform, go to Settings → Project → Webhooks and create a webhook:
- URL: your public address followed by
/openai-webhook, e.g.https://your-domain.ngrok-free.dev/openai-webhook - Event:
realtime.call.incoming(the only event this integration needs)
Copy the signing secret (whsec_...) — it’s only shown once.
Step 5: Configure your environment
Create a .env file in the project folder:
OPENAI_API_KEY=sk-...
OPENAI_WEBHOOK_SECRET=whsec_...
AI_INSTRUCTIONS=You are a helpful phone assistant.
AI_GREETING=Thank you for calling, how can I help you?Only the first two are required. You can also set AI_MODEL (default gpt-realtime-2.1) and AI_VOICE (default alloy). Restart the server after editing .env.
Step 6: Test the webhook
In the OpenAI webhook settings, click Send test event. Your server should respond with 200.
Step 7: Make a test call
Call your Teler virtual number. The call routes through Teler to OpenAI, your server answers it, and your agent greets you within a few seconds. Both sides of the conversation appear as transcripts in your server logs.
In sandbox, dial the sandbox virtual number from a verified number and enter the 4-digit PIN of the trunk when prompted.
Integration at a Glance
| Requirements | An active Teler SIP trunk with Transport type set to TLS/SRTP; a virtual number assigned to the trunk; an OpenAI project with its API key, project ID, and webhook secret; a public HTTPS URL for the reference server |
| Call direction | Inbound |
| Setup type | Dashboard trunk configuration plus a lightweight call control server from the GitHub repo — no media server required |
| Support | support@frejun.com, or file an issue on the GitHub repo |