Blog
February 10, 2025

IVR Without Asterisk Config Files

How Trunx lets you build interactive voice response trees through an API — with TTS, DTMF routing, transfers, and AI agent handoff.

Jordan Reeves
Jordan Reeves
4 mins read

IVR Without Asterisk Config Files

Traditional IVR systems require editing Asterisk dialplan files, managing audio recordings, and deploying configuration changes to a PBX. Every change is a deployment. Every new menu option is a config file edit.

Trunx takes a different approach: IVR definitions are JSON trees stored in Postgres, cached in Redis, and executed at call time — no config files, no deployments.

How It Works

An IVR in Trunx is a tree of nodes. Each node is a step in the call flow:

  • Play Audio — Play a TTS-generated or uploaded audio file
  • Gather Input — Listen for DTMF tones (keypad presses) and route based on the digit
  • Transfer — Bridge the caller to another number
  • AI Agent — Hand off the call to a voice AI agent
  • Hangup — End the call

Nodes connect to form a tree. The entry node plays a greeting. Gather nodes branch based on input. Each branch leads to the next node.

Creating an IVR

You can build IVRs through the dashboard's visual editor or the API:

curl -X POST https://api.trunx.io/v1/ivr \
  -H "Authorization: Bearer tk_live_..." \
  -d '{
    "name": "Main Menu",
    "definition": {
      "entryNode": "greeting",
      "nodes": {
        "greeting": {
          "type": "gather",
          "prompt": "Welcome to Acme Corp. Press 1 for sales, 2 for support, or 3 to speak with an AI assistant.",
          "routes": {
            "1": "sales_transfer",
            "2": "support_transfer",
            "3": "ai_agent"
          }
        },
        "sales_transfer": {
          "type": "transfer",
          "destination": "+14155550100"
        },
        "support_transfer": {
          "type": "transfer",
          "destination": "+14155550200"
        },
        "ai_agent": {
          "type": "agent",
          "agentId": "agent_abc123"
        }
      }
    }
  }'

Then assign a DID to the IVR:

curl -X PATCH https://api.trunx.io/v1/dids/{id} \
  -d '{"ivrId": "ivr_xyz789"}'

That's it. Inbound calls to that number now follow the IVR tree.

The Cache Strategy

IVR definitions are small (typically under 10KB) and change rarely. Trunx uses a cache-on-write strategy:

  1. When you create or update an IVR, the definition is written to Postgres and simultaneously cached in Redis
  2. DID-to-IVR mappings are also cached: ivr:did:{number}ivr:def:{id}
  3. At call time, the ARI handler reads from Redis — zero database queries in the call path

The Trunx hub is never in the inbound call critical path for lookups. Asterisk reads IVR definitions directly from Redis.

Two Execution Paths

Depending on the DID's provider, IVRs execute differently:

Twilio DIDs use stateless TwiML. The IVR tree position is encoded in a query parameter (?node=greeting). Each Gather response generates new TwiML pointing to the next node. No server-side session state needed.

Asterisk/SIP DIDs use stateful ARI sessions. The ARI handler maintains a Redis session (ivr:session:{channelId}) that tracks the current node, input buffer, and call state. WebSocket events (DTMF, PlaybackFinished) drive node transitions.

Both paths resolve the IVR definition the same way: getIvrForDID(number) → Redis lookup → tree traversal.

Text-to-Speech

IVR prompts can be text strings or uploaded audio files. When you use text, Trunx generates audio via ElevenLabs TTS and stages the file to the Asterisk server automatically.

The TTS generation happens when you create the IVR, not at call time. Prompts are pre-rendered and cached, so inbound calls play audio with zero latency.

AI Agent Handoff

The most powerful IVR node type is agent. When a caller reaches an agent node, Trunx hands the call off to a voice AI agent that can:

  • Have a natural conversation
  • Use tools mid-call (CRM lookups, scheduling, payments)
  • Transfer to a human if needed

This lets you build IVRs where the simple paths (press 1 for hours, press 2 for address) are handled by static audio, and the complex paths (scheduling, troubleshooting, sales) are handled by AI.

Getting Started

Build your first IVR in the dashboard or through the IVR API. For the complete guide, see IVR Builder.

Wrap-up

Telecom infrastructure shouldn't slow you down. Trunx fits into your workflow — whether you're building voice AI agents, managing outbound campaigns, or scaling SMS at 2am.

If that sounds like the kind of tooling you want to use — try Trunx or join us on Discord.