Asterisk AI Voice Agent: Open-Source and Self-Hosted Options
If you already run Asterisk, you have most of what you need for an Asterisk AI voice agent. Your trunks, extensions, queues and dialplan stay where they are. What you add is a piece that takes the live call audio, turns it into text, asks an AI model what to say, and plays the reply back to the caller fast enough to feel like a conversation.
This guide explains the three common ways to connect Asterisk to AI, looks at the open-source projects people find when they search GitHub, and lists the questions that matter once real customers start calling. It is written for teams in India who care about Indian languages, telecom costs in rupees and keeping call data on their own servers.
How an Asterisk AI voice agent works
Every working setup has the same five parts, whatever the project calls them:
- Audio transport. Asterisk hands the call audio to an external process and accepts audio back.
- Speech-to-text (STT). The caller’s speech becomes text, ideally streamed while they talk.
- The AI brain. An LLM, a workflow tool or your own API decides the reply, often calling tools such as a booking system.
- Text-to-speech (TTS). The reply becomes audio in the right language and voice.
- Turn-taking. Voice activity detection, barge-in (the caller interrupting the bot) and silence handling.
The transport is the Asterisk-specific part. The other four are the same problems any voice agent has to solve, and they decide most of the quality you hear on a call.
Three ways to connect Asterisk to AI
1. AudioSocket
AudioSocket is an Asterisk application that opens a plain TCP connection for each call and streams raw audio both ways. You add a few lines to the dialplan and point it at your AI service. It is simple to reason about: one call, one socket, 8 kHz audio in and out.
A typical dialplan looks like this:
exten => _X.,1,Answer()same => n,Set(SESSION_UUID=${TRIM(${SHELL(uuidgen)})})same => n,AudioSocket(${SESSION_UUID},127.0.0.1:8080)same => n,Hangup()
The first argument must be a proper UUID, which is why the dialplan generates one instead of using ${UNIQUEID}. You can also post caller details (number, language, which bot to use) to the AI service before the AudioSocket line, so the agent knows who is calling from the first second. The full walkthrough is in the Asterisk AudioSocket setup docs.
2. ARI with external media
The Asterisk REST Interface (ARI) lets an external application control calls: answer, bridge, play, record and transfer. Combined with an external media channel, it streams audio over RTP to your app. ARI gives you more call control than AudioSocket, but you write and maintain more code, and you need to handle RTP timing and codecs yourself.
3. SIP trunk to an AI gateway
The third option treats the AI as another SIP endpoint. Asterisk routes a call over a SIP trunk to an AI gateway, exactly as it would to a branch office or a carrier. This keeps the dialplan change tiny and works well when the AI runs on a different server or when you also have non-Asterisk PBXs to connect.
| Method | Setup effort | Call control | Best when |
|---|---|---|---|
| AudioSocket | Low: a few dialplan lines | Dialplan plus HTTP hooks for transfers | AI runs on the same host or LAN as Asterisk |
| ARI + external media | High: custom app, RTP handling | Full, from your code | You want deep custom call logic and have developers for it |
| SIP trunk | Low to medium: trunk and route | SIP REFER for transfers | AI on another server, or mixed PBX estate |
Open-source Asterisk AI projects on GitHub
Search for “asterisk ai agent github” and a few names come up repeatedly. Projects move quickly, so check each repository’s current README, licence and last commit before you depend on it. As of late 2026, these are the ones worth knowing about:
- AVA (AI Voice Agent for Asterisk). An MIT-licensed project that integrates with Asterisk and FreePBX. Its README describes AudioSocket/RTP transport and ARI control, with pluggable providers.
- ictinnovations asterisk-ai-voice-agent. A self-hosted Python sidecar that bridges an AudioSocket call to an LLM, with barge-in and 20 ms frame pacing according to its listing. It describes itself as an early release.
- Agent Voice Response. A community-built, Docker-based stack that connects to Asterisk via AudioSocket, discussed on the Asterisk community forum.
- General frameworks. Pipecat and LiveKit Agents are open-source voice agent frameworks rather than Asterisk projects. You can connect them through SIP, but you assemble the telephony side yourself.
These projects are good for learning and for prototypes. The gap usually shows up later: Indian language support, per-call configuration, transfers to a human, cost tracking, and someone to call when a carrier changes something at 11 pm.
What to check before production
Whichever route you take, test these on real calls from real phones, not from a softphone on your office Wi-Fi.
Indian language recognition on 8 kHz audio
Phone audio is narrowband. A model that scores well on clean 16 kHz recordings can stumble on a caller in a moving auto-rickshaw. Test Hindi, your regional languages and Hinglish or Manglish code-mixing with your actual callers. Providers built for Indian languages, such as Sarvam, often do better here than English-first engines.
Streaming vs batch STT
Streaming recognisers return text while the caller is still speaking. Batch recognisers wait for silence, then send the whole utterance. Batch is simpler, but it adds a noticeable pause on every turn. The speech recognition provider guide lists which providers stream and which do not.
Barge-in and silence
Callers interrupt. If the bot keeps talking over them, the call feels robotic within seconds. Check that the agent stops speaking when the caller starts, and that it handles long silences without hanging up too early.
Transfers to a human
Decide how a call leaves the AI. With AudioSocket, a transfer usually means an HTTP call back to something that moves the Asterisk channel, so the agent needs the channel name. With SIP, a REFER to a queue or extension does the job.
Where the audio goes
Under India’s DPDP Act, a recording of a caller’s voice is personal data. Know which providers receive the audio and text, where they process it, and how long they keep it. Self-hosted STT and TTS remove most of that question.
How VEXYL fits
The VEXYL Voice Gateway sits between Asterisk and the AI. It accepts calls over AudioSocket (the default mode) or over a SIP trunk, and it also documents FreePBX and IP-PBX brands such as Panasonic, Avaya IP Office, Grandstream and Bitvoice.
What it adds over a DIY project:
- Provider choice. STT from Sarvam, Google, Deepgram, Groq, Gemini or the self-hosted VEXYL-STT. TTS from Sarvam, Google, Gemini, ElevenLabs, Smallest AI, Deepgram or Azure. You bring your own API keys.
- Per-call settings. Post the caller’s number, language and bot before the call starts, or override the voice and recogniser for a single call.
- Any brain. Connect LiteBot (which works with Groq, OpenAI, Gemini, Sarvam, Ollama and others), an n8n webhook, or your own HTTP endpoint. A realtime speech-to-speech mode is also supported.
- Transfers. AudioSocket calls are transferred through your webhook; SIP calls with a REFER.
- Self-hosting. It runs as a single binary or in Docker on your own server, so call audio does not have to leave your network if you also use self-hosted speech.
If you have already tried an open-source project and want a broader look at running everything on your own hardware, read our guide to a self-hosted AI voice agent. FreePBX users can follow the FreePBX AI receptionist walkthrough, and there is an older but still useful Asterisk gateway setup guide on this blog.
FAQ
Can Asterisk run an AI voice agent without a cloud platform?
Yes. Asterisk handles the call, and the AI pieces can all run on your own servers: a self-hosted STT model, a local LLM through something like Ollama, and a self-hosted TTS model. Expect to need decent hardware for the LLM, and test response times carefully.
Which Asterisk version do I need for AudioSocket?
AudioSocket is a module that ships with newer Asterisk releases. The VEXYL docs ask for Asterisk 16 or later with the AudioSocket application loaded. Run module show like audiosocket on your server to confirm it is available.
Is AudioSocket better than ARI for AI?
For most voice agents, AudioSocket is easier because the dialplan change is small and the audio format is fixed. ARI is better when your application needs to control the whole call itself, such as complex bridging or recording logic.
Does this work with FreePBX?
Yes. FreePBX is built on Asterisk, so you add the AudioSocket context to extensions_custom.conf and route an inbound number or IVR option to it.
How much does an Asterisk AI call cost in India?
It depends on your STT, TTS and LLM providers and how long callers talk. One live hospital deployment in India came to about ₹0.83 per minute of AI call time, which shows the order of magnitude when you pick providers carefully.
Try it on your own Asterisk
The Developer edition of the VEXYL Voice Gateway is free, self-hosted and handles 4 concurrent calls, which is enough to wire it to a test extension this week. If you want help sizing a larger rollout, talk to the VEXYL team.