An AI voice agent needs a bridge to the outside world to make or receive phone calls. That bridge is typically built with sip trunking ai technology, a method for connecting an internet-based voice system to the traditional phone network. Understanding how this works is key to building reliable, conversational AI that can interact with anyone on a standard phone line.

Key takeaways

  • An AI agent places a call through a multi-step process: an application triggers a call, SIP signaling establishes it, a carrier routes it to the phone network, and a real-time audio (RTP) stream is processed by the AI.
  • SIP (Session Initiation Protocol) and RTP (Real-time Transport Protocol) are two separate protocols. SIP is the control system that sets up and tears down calls, while RTP is the transport that carries the actual voice audio (RFC 3261: SIP—Session Initiation Protocol).
  • Connecting an AI to the phone network requires careful technical setup. You must configure codecs (like G.711), DTMF tones for menus, and network firewalls to avoid common issues like one-way audio (SIP Trunking for AI Voice Agents).
  • While SIP is the standard for telephony carriers, browser-based AI agents use WebRTC. To connect a browser-based agent to a phone number, a gateway is needed to translate between the two protocols.
  • Security and compliance are critical. You must protect against toll fraud, secure credentials and media streams, and follow regulations on caller ID, call recording consent, and AI disclosure.

How Does an AI Agent Place a Phone Call?

An AI agent makes a phone call by using a telephony platform to manage signaling and media. The platform uses SIP to connect the call through a carrier to the phone network. Meanwhile, it coordinates a real-time loop of receiving audio, converting it to text for the AI, getting a text response, and converting that back to audio for the listener.

Here is the end-to-end process, broken down into nine steps.

  1. Initiation: An application sends a request to a telephony platform. This request includes the destination phone number, the caller ID to display, and instructions for which AI agent to use.

  2. Signaling (SIP): The telephony platform creates a SIP INVITE message (RFC 3261: SIP—Session Initiation Protocol). This message is a formal request to start a call, containing details like the caller and destination numbers and a proposal for how to handle the audio using a format called Session Description Protocol (SDP).

  3. Routing (PSTN): The INVITE message is sent to a telecommunications carrier, which acts as a bridge. The carrier routes the call from the IP network to the Public Switched Telephone Network (PSTN), the global system connecting landlines and mobile phones (PSTN Connectivity with Programmable Voice).

  4. Connection: The recipient's phone rings. The destination endpoint returns SIP status messages—such as a provisional 180 Ringing—which are routed back through the carrier to the platform. When the person answers, a final 200 OK message is sent, establishing the call.

  5. Media (RTP): A separate connection for the audio is established using the Real-time Transport Protocol (RTP). This RTP stream is the path the actual conversation audio travels on, completely separate from the SIP control signals (Overview: Real-Time Protocols for Browser-Based Applications).

  6. AI Processing (Input): The platform's media gateway takes the incoming audio from the RTP stream and sends it to a Speech-to-Text (STT) service. The STT service transcribes the audio into text in near real-time. This text is then fed to the AI agent, often a Large Language Model (LLM).

  7. Response Generation: The AI agent processes the text and decides how to respond. It generates a text response, which is then sent to a Text-to-Speech (TTS) service. The TTS service synthesizes the text into human-sounding audio.

  8. AI Processing (Output): The synthesized audio from the TTS service is encoded and sent back into the RTP stream for the person on the other end to hear. This entire loop, from hearing to speaking, must happen very quickly to maintain a natural conversation flow and manage voice agent latency.

  9. Termination: When one party hangs up, a SIP BYE message is sent. This message formally ends the session, and all network resources are released.

What Are SIP, RTP, and PSTN?

The three core components of an AI call are SIP, RTP, and the PSTN. SIP is the control protocol that sets up and manages the call. RTP is the media protocol that carries the voice audio. The PSTN is the global phone network that connects your AI to any standard phone number. Confusing them is a common mistake.

A simple analogy is sending a package.

  • SIP (Session Initiation Protocol) is the mail carrier. The mail carrier arranges the delivery, confirms the address, agrees on a delivery time, and gets a signature when the package arrives. They handle the logistics and control of the delivery, but they don't transport the package itself. In a phone call, SIP sends messages like INVITE to start the call and BYE to end it.

  • RTP (Real-time Transport Protocol) is the delivery truck. Its only job is to transport the goods—the actual audio of the conversation—from one place to another. The truck follows the route arranged by the mail carrier. For security, the audio is often encrypted using SRTP (Secure Real-time Transport Protocol).

  • PSTN (Public Switched Telephone Network) is the global system of roads and addresses. It's the infrastructure that lets the delivery truck get to any house in the world. A SIP trunking provider gives your internet-based AI system an on-ramp to this global network, allowing it to reach any phone number.

Understanding this separation is crucial for troubleshooting. When a call fails to connect, the problem is likely in the SIP signaling. When a call connects but has no audio, the problem is almost always with the RTP media stream.

SIP vs. WebRTC: What's the Difference for AI Agents?

SIP and WebRTC are both used for real-time communication, but they are designed for different environments. SIP is the standard for traditional telephony and carrier networks. WebRTC is the native standard for real-time audio and video in web browsers. An AI voice system might use both: WebRTC for a user in a browser and SIP to connect that call to the phone network.

The main differences come down to their primary use case, network handling, and security model.

Feature SIP (Session Initiation Protocol) WebRTC (Web Real-Time Communication)
Domain Telephony, VoIP, Carrier Interconnect Web Browsers, Mobile Apps
Signaling Defined by the SIP protocol (INVITE, BYE) Not specified; often uses WebSockets
Security Optional (TLS for signaling, SRTP for media) Mandatory (DTLS-SRTP for media)
NAT Traversal Not built-in; often requires an SBC Built-in (ICE, STUN, TURN)
AI Use Case Backend connection to PSTN carriers Frontend connection for browser-based agents or users

A key distinction is interoperability. An AI agent running in a customer support dashboard in a browser uses WebRTC. If that agent needs to dial a customer's mobile number, the system can't send WebRTC directly to the phone network. Instead, it connects to a gateway that translates the WebRTC session into a SIP session, which is then sent to a carrier (WebRTC SIP Integration Architecture Guide).

What's on a Checklist for Your First AI Call?

Connecting your AI platform to a SIP trunk provider requires precise configuration. A single mismatch can cause calls to fail or create audio problems. This checklist covers the essential steps for setting up a reliable connection for your first outbound and inbound calls.

  • [ ] Provision a Number: Start by renting a phone number from your SIP trunking provider. This number will be your caller ID for outbound calls and the number people can call to reach your AI agent.
  • [ ] Configure Authentication: Your provider needs to know that call traffic is legitimately from you. This is usually done by adding your platform's IP addresses to an access control list (ACL) or by using SIP registration with a username and password.
  • [ ] Set URIs: Configure your URIs (Uniform Resource Identifiers). Your platform needs to know the provider's origination URI to send calls to, and the provider needs your termination URI to know where to send calls from.
  • [ ] Select Codecs: A codec is an algorithm for compressing and decompressing audio. Both your platform and your provider must support a common codec. For maximum compatibility, start with G.711 PCMU (also called µ-law), the standard for the North American phone system (SIP Trunking for AI Voice Agents).
  • [ ] Verify DTMF Method: DTMF tones are the sounds a keypad makes, used for navigating phone menus. The modern standard for sending these reliably over RTP is defined in RFC 4733 (RFC 4733: RTP Payload for DTMF Digits). Confirm both your system and your provider are configured to use this method.
  • [ ] Set Caller ID: Configure the From and P-Asserted-Identity headers in your SIP messages. These should contain the phone number you provisioned. Using a number you don't own can cause carriers to reject your calls.
  • [ ] Open Firewall Ports: Ensure your firewall allows traffic on the correct ports. SIP signaling typically uses UDP or TCP port 5060, or TLS port 5061 for encrypted signaling. You must also open a wide range of UDP ports (e.g., 10000-20000) for the RTP audio streams.
  • [ ] Test Inbound & Outbound: Place a test call from your platform to an external phone to check outbound calling and caller ID. Then, call into your new number from an external phone to verify inbound routing and two-way audio.

How Do You Troubleshoot Common SIP Trunking Issues?

Even with a perfect setup, issues can arise. Most problems fall into a few common categories related to network configuration, media negotiation, or carrier rules.

One-Way or No Audio

This is the most frequent issue. A call connects, but one or both parties can't hear anything.

  • Cause: The SIP signaling worked, but the RTP audio stream is blocked or lost. This is almost always a network issue.
  • Solution:
    1. Check Firewalls: Ensure the RTP port range (e.g., UDP 10000-20000) is open on your firewall for traffic from your provider's IP addresses.
    2. Verify NAT Configuration: Network Address Translation (NAT) can rewrite the IP address in the SDP payload to a private, unreachable address. A Session Border Controller (SBC) or a STUN server is often used to fix this.
    3. Confirm Codec Match: If a codec mismatch occurs after the call starts, it can also lead to silence.

Call Fails to Connect

The call is immediately rejected, often with a 4xx, 5xx, or 6xx SIP error code.

  • Cause: This usually points to a problem with signaling, authentication, or routing.
  • Solution:
    1. Check SIP Logs: Look at the SIP response code. A 403 Forbidden or 401 Unauthorized suggests an authentication problem (wrong IP in ACL, bad password). A 404 Not Found means the carrier doesn't recognize the number you're dialing.
    2. Verify Caller ID: Many carriers will reject calls that use an invalid or unverified caller ID to prevent spoofing. Ensure you are using a number you own.
    3. Check URI and Dialing Format: Make sure you are sending the call to the correct URI for your provider and that the destination number is in the expected format (e.g., E.164 format like +15551234567).

DTMF Tones Not Working

The AI agent tries to navigate a phone menu (e.g., "press 1 for sales"), but the system doesn't register the key presses.

  • Cause: The sender and receiver are using different methods to transmit DTMF tones.
  • Solution: Ensure both your platform and your provider are configured to use the same DTMF method, preferably RFC 4733. Avoid in-band DTMF, where tones are sent as audible sounds in the audio stream, as codecs can distort them.

What Are the Key Security and Compliance Risks?

Connecting any system to the public phone network introduces risks. For AI calling systems, these fall into two main categories: security threats and regulatory compliance.

Security

  • Toll Fraud: This is the most significant financial risk. If an attacker gains access to your SIP credentials, they can make unauthorized calls to expensive international numbers, leaving you with a massive bill. To prevent this, use strong, unique credentials, restrict access to your platform's IP addresses, and set rate limits and destination-country restrictions with your carrier.
  • Denial of Service (DoS): Attackers can flood your system with SIP requests, overwhelming its capacity and preventing legitimate calls. An SBC or a firewall can help mitigate these attacks.
  • Eavesdropping: Unencrypted calls can be intercepted. Use TLS to encrypt SIP signaling and SRTP to encrypt the RTP audio media. This ensures that both the call metadata and the conversation itself are private.

Compliance

  • Caller ID Regulations: Rules like STIR/SHAKEN in the United States are designed to combat illegal caller ID spoofing. Always use a phone number that your organization has the right to use. Failure to do so can result in your calls being labeled as "Spam Likely" or blocked entirely by carriers.
  • Recording Consent: Laws regarding call recording vary widely by location. Some jurisdictions require all parties to consent ("two-party consent"), while others only require one party's consent. Your AI agent may need to play a disclosure message like, "This call may be recorded for quality purposes."
  • AI Disclosure: A growing number of regulations require the disclosure that a caller is speaking to an AI rather than a human. For example, California's "B.O.T." law requires such disclosure in certain commercial contexts. Always be transparent about the use of AI.

What to learn next

Sources and further reading