Asterisk + AI via ARI: how to build a virtual voice assistant for business telephony
Artificial intelligence is no longer just a chatbot on a website. Today, it can be quite easily integrated with a PBX to create a voice assistant that answers calls, communicates with callers using natural speech, works with a knowledge base, and transfers the call to a human when needed.
If you use Asterisk, there are several ways to build such a solution. One of the most interesting is connecting through ARI (Asterisk REST Interface), which gives developers significantly more control over the call than a traditional dialplan. Combined with a Node.js application, you can create a modern AI voicebot solution without having to build the entire telephony logic from scratch.
Why connect Asterisk with AI at all
A typical business scenario today looks straightforward: a customer calls the main number, the AI assistant greets them, identifies the reason for the call, answers basic questions, and if needed, transfers the call to the right department or specific extension.
Such an assistant can, for example:
answer frequently asked questions
handle calls outside business hours
provide information from a knowledge base
collect information from the caller before transferring
route calls based on conversation content
help an overloaded call center
The advantage is that this is no longer the old rigid IVR of the “press 1” variety. A modern AI voice assistant can communicate naturally, understand context, and be tailored to a specific company, service, or industry.
What are the integration options
When integrating AI into Asterisk, there are two main approaches in practice.
1. Connecting via SIP trunk to an external AI platform
The first option is to use an external voice AI service that connects to Asterisk as a SIP peer. Typically, this could be a connection to a cloud platform that handles speech recognition, voice synthesis, and dialog logic.
The advantage is relatively quick deployment. The disadvantage is usually less control over the call flow, higher dependency on a specific provider, and often more complex customization to the company’s specific processes.
This model makes sense where the priority is a quick start with less need for deeper development.
2. ARI + custom Node.js application
The second, technically more interesting path, is to use ARI. In this case, Asterisk hands the call to your application, which controls it via REST and WebSocket interfaces. In the Node.js application, you can then handle your own logic, communication with the AI model, connections to databases, CRM, and knowledge bases.
This solution brings key advantages:
full control over the call lifecycle
ability to precisely define the assistant’s role
easy integration with internal systems
flexible handling of transfers, queues, and fallback scenarios
ability to combine multiple AI services as needed
This is where Asterisk becomes a very strong foundation for developing your own AI voicebot.
To make ARI work, you need to enable the REST interface in Asterisk and create a user:
iniari.conf
[general]
enabled = yes
pretty = yes
allowed_origins = *
[ai-demo-user]
type = user
password = tajne-heslo
read_only = no
And in the dialplan, hand the call over to the Stasis application:
iniextensions.conf
[ai-demo]
exten => _[+0-9A-Za-Z]!,1,NoOp(AI asistent)
same => n,Answer()
same => n,Wait(0.5)
same => n,Stasis(asterisk-ai)
same => n,Hangup()
How it works in practice
The architecture can be surprisingly straightforward.
A call arrives in Asterisk.
Asterisk hands the channel to the ARI application.
The Node.js application starts controlling the call.
Audio is sent to the AI layer based on the chosen design.
The AI returns a response, which is converted to speech and played to the caller.
Based on the result, the application can:
continue the dialog
look up information in the knowledge base
trigger an action
or transfer the call to an operator
From the business perspective, it’s important that the assistant doesn’t have to be just a “talking FAQ.” If you give it the right role and data, it can function as a receptionist, helpdesk operator, order assistant, or first-level customer support.
The following Node.js application shows a complete implementation — from accepting a call via ARI, creating an ExternalMedia channel for RTP audio, to connecting to the AI Realtime API via WebSocket:
The strength of an AI assistant doesn’t just lie in its ability to speak. What matters is what it knows and what role it has.
Every quality voice bot should have clearly defined:
how it should introduce itself
what communication style to use
what information it can provide
when to hand the call to a human
what it must never claim or promise
On top of that sits the knowledge base. It can contain, for example:
product and service information
business hours
price lists
internal procedures
answers to frequently asked questions
contact and routing rules
It’s precisely the combination of role + knowledge base + telephony logic that turns an ordinary AI model into a true virtual assistant.
Where ARI makes the most sense
The Asterisk dialplan is great for classic telecommunications scenarios. But when you want to conduct a dynamic dialog, work with context, or make real-time decisions based on AI responses, ARI becomes a much more natural choice.
A custom Node.js application also enables you to add features such as:
conversation history
caller intent evaluation
automatic transfer based on conversation content
integration with ticketing systems or CRM
logging and analytics
combining multiple models and services
This is exactly the moment when a PBX transforms into an intelligent communication platform.
It’s not complicated if you have the right foundation
At first glance, combining Asterisk, ARI, Node.js, and an AI model may seem complex. In reality, though, it’s nothing unachievable. Once you have a working Asterisk, a basic ARI application, and a well-designed call scenario, you can quite quickly create a first usable prototype.
And that’s exactly what makes this technology interesting: there’s no need to build a massive enterprise solution. Even a smaller company can today create its own voice AI assistant that answers calls, guides customers, and saves operators’ time.
Deployment as a systemd service
For production use, it’s advisable to run the application as a systemd service that automatically restarts on failure:
Configuration values are loaded from the .env file:
bash.env
# OpenAI API klíč
OPENAI_API_KEY=sk-proj-
# Asterisk ARI přihlašovací údaje
ARI_URL=http://127.0.0.1:8088
ARI_USER=ai-demo-user
ARI_PASS=tajne-heslo
# UDP port pro RTP audio příjem z Asterisku (libovolný volný port)
RTP_PORT=12000
# Adresa tohoto serveru (kde běží bridge) - viditelná pro Asterisk
BRIDGE_HOST=127.0.0.1
# Adresář pro ukládání transkriptů
TRANSCRIPT_DIR=/cesta-k-transkriptum
Connecting Asterisk with AI via ARI opens a very practical path to taking business telephony to the next level. Whether you choose a direct cloud SIP connection or a custom ARI application in Node.js, the result can be an intelligent voice assistant that understands the business, knows its data, and can lead a meaningful dialog with the customer.
AI in telephony is no longer a futuristic toy. It’s a tool that can be deployed today — and in many cases, surprisingly easily.