How to Connect a SIP Trunk to an AI Voice Agent

anil
November 14, 2026
SIP trunk cable linking an IP phone and server through a gateway to an AI voice agent

You have built a voice bot that works beautifully in the browser. Now it needs a phone number. For most businesses in India, that means a SIP trunk AI agent set-up: calls arrive on a SIP trunk from your telecom operator or PBX, and something has to carry that audio to the AI and the AI’s voice back again.

This guide explains the two common ways to connect a SIP trunk to an AI voice agent, what to ask your trunk provider, the settings that matter (NAT, RTP ports, codecs, allowed IPs), how outbound calls are routed, and how to fix the problems almost everyone hits on day one.

What a SIP trunk does in an AI calling set-up

A SIP trunk is a virtual phone line delivered over IP. It carries two things:

  • Signalling (SIP): messages that set up, answer, transfer and end calls, usually on UDP port 5060 or similar.
  • Media (RTP): the actual audio, sent as small packets on a range of UDP ports, commonly encoded as G.711 (PCMU or PCMA) at 8 kHz.

An AI voice agent cannot speak SIP on its own. A gateway sits between the trunk and the AI: it answers the SIP call, receives the RTP audio, streams it to speech recognition, sends the text to the language model, turns the reply into speech and plays it back as RTP. If you want the full architecture, our post on AI voice gateways for PSTN, SIP and legacy systems covers it.

Getting a SIP trunk for AI calling in India

In India, enterprise SIP trunks are typically supplied by licensed operators such as Tata Tele Business Services, Airtel, Jio and Vodafone Idea, often delivered to a PBX on your premises. Indian telecom rules around connecting internet VoIP to the public phone network are stricter than in many countries, so the trunk usually terminates on your PBX or a server your operator approves. Talk to your provider about how they deliver the trunk and what they allow before you design the set-up.

Questions to ask your provider:

  1. Does the trunk use IP authentication (they send calls to your fixed IP) or registration (your system logs in with a username and password)?
  2. Which signalling IP addresses will calls come from? You will whitelist these.
  3. Which codecs are offered? G.711 A-law (PCMA) is common in India.
  4. How many concurrent channels are included?
  5. Which caller IDs can you send on outbound calls?
  6. Is the trunk delivered to your PBX, or can it reach a separate server?

Two ways to connect: direct bridge or PBX in front

There are two common patterns. Both are documented in the SIP trunk chapter of our gateway docs.

Direct to the gateway Asterisk or PBX in front
Path Trunk or PBX sends calls straight to the AI gateway Trunk lands on Asterisk/FreePBX, which passes chosen calls to the gateway
Codecs G.711 (mu-law, A-law) Opus with FEC, AMR-WB, G.711
IVR, queues, recording Not available Handled in the PBX
Transfer to a human SIP REFER Inside the PBX, or REFER
Best for Simple bot-only numbers Mixed human and AI call flows, existing PBX estates

If the AI agent only answers a dedicated number and nothing else, the direct bridge is simpler. If you already run Asterisk or FreePBX, or need queues, recording or a fallback to human extensions, put the PBX in front. Our guides on the FreePBX AI receptionist and Asterisk AI voice agents cover that route, including the AudioSocket dialplan and SIP trunk configuration in Asterisk.

Step by step: SIP trunk configuration for the AI gateway

1. Set the gateway’s SIP side

On the VEXYL Voice Gateway, the direct bridge is switched on with TELEPHONY_MODE=sip_bridge. The key settings:

  • SIP_PORT: the UDP port for signalling, for example 5080 so it does not clash with a PBX on 5060.
  • RTP_PORT_MIN / RTP_PORT_MAX: the audio port range, for example 20002 to 30000.
  • SIP_PUBLIC_ADDRESS: the public IP written into the call’s audio description. Behind NAT, this must be the public address, or audio goes one way only.
  • SIP_ALLOWED_IPS: the exact IP addresses of your PBX or carrier. Leave this empty on an internet-facing server and anyone can place calls that spend your AI budget.
  • SIP_CODEC: 0 for PCMU (mu-law) or 8 for PCMA (A-law).

2. Register, or receive calls by IP

If your carrier needs registration, set SIP_REGISTER_URI, SIP_AUTH_USER and SIP_AUTH_PASSWORD. The log shows a successful registration on boot. If the carrier sends calls to a fixed IP, skip this and give them the gateway address and port instead.

3. Configure the PBX trunk (if a PBX is in the path)

In FreePBX or Asterisk with PJSIP, create a trunk pointing at the gateway with: no registration, direct media off, RTP symmetric on, force rport on, rewrite contact on, and codecs ulaw and alaw. Send only the bot’s numbers to this trunk through a dedicated inbound route, not every call on the PBX.

4. Open the firewall correctly

Open the SIP port and the full RTP range in both directions, only from your carrier and PBX addresses. If Asterisk and the gateway share a host, make sure their RTP ranges do not overlap.

5. Test and read the logs

Place a test call. Check that the call connects, that both sides hear audio, that the bot’s hang-up actually ends the call on the PBX side, and that a transfer reaches the right extension.

Outbound calls over the SIP trunk

For outbound AI calls, the gateway needs to know where to send the INVITE. It can dial a full SIP address (number@pbx-ip), send a bare number to the registrar it is registered with, or use an outbound proxy such as your PBX. Set the caller ID your carrier has assigned to you; many carriers reject others. The outbound and per-call settings docs show each option with examples.

Troubleshooting common SIP trunk problems

Symptom Likely cause Fix
Call connects, nobody hears anything RTP blocked, or a private IP in the SDP Set the public address; open the RTP range both ways
Caller hears the bot, bot never hears caller Inbound RTP closed by NAT or firewall; codec mismatch Check firewall and that both ends offer the same codec
No calls reach the gateway Wrong port, or the sender’s IP is not in the allowed list Check SIP port and allowed IPs (exact IPs, not CIDR ranges)
Bot hangs up but the caller stays on the line BYE lost at NAT on long calls With a PBX in front, enable qualify (OPTIONS keep-alive) on the trunk
Calls rejected under load Concurrent call limit reached Check trunk channels and the gateway’s call limit

How VEXYL fits

The VEXYL Voice Gateway is the piece that sits between your SIP trunk and the AI. It accepts calls directly over SIP, through Asterisk AudioSocket, or from FreePBX and IP-PBXs such as Panasonic, Avaya, Grandstream and Bitvoice. Each call can pick its own bot, language, recogniser and voice through session metadata or SIP headers, so one trunk can serve several AI agents. It runs as a single binary, in Docker or on Kubernetes, on your own server, which suits Indian trunks that terminate on premises. The hosted option connects over a SIP trunk by static IP.

FAQ

Do I need a PBX to connect a SIP trunk to an AI agent?

No. A gateway with a SIP bridge can accept calls directly. A PBX helps if you need IVR menus, queues, recording or transfers to human extensions.

Which codec should I use for AI calling?

G.711 (PCMU or PCMA) is the safe default, since nearly every trunk supports it. If calls cross lossy links, running Asterisk in front lets you use Opus with forward error correction.

Why do I get one-way audio?

Almost always NAT or firewall. The public IP must appear in the call’s audio description, and the RTP port range must be open in both directions.

Can I use my existing Airtel, Tata or Jio SIP trunk?

Usually, yes, if the trunk is delivered to your PBX or a server you control. Check your provider’s terms and how they deliver the trunk.

How many AI calls can one SIP trunk carry?

As many as its channel count, and your gateway licence and server capacity, allow. Match campaign concurrency to the number of trunk channels.

Ready to put your AI agent on a real phone line? Download the free self-hosted Developer edition, or contact us for help connecting your trunk.