Guide to Deploying an AI Auto-Attendant System with Asterisk and VapiRetell API on VPS
A detailed guide to deploying an AI auto-attendant system using Asterisk and VapiRetell API on a VPS, covering installation, configuration, testing, and performance optimization for...
Image credit: geralt · Pixabay Content License
Introduction to the AI Auto-Attendant System
An AI auto-attendant system enables businesses to automate calls, handle customer requests, and improve service experience. In this guide, we deploy an AI call system using Asterisk—a popular open-source PBX platform—combined with VapiRetell API for speech-to-text (STT) and text-to-speech (TTS) processing. The entire system runs on a VPS with sufficient resources to handle AI workloads.
Prerequisites Before Deployment
To successfully deploy the system, you need:
- A VPS (Cloud VPS) with at least 4GB RAM and 2 CPU cores.
- Access to a Linux operating system (Ubuntu 20.04 or 22.04).
- Familiarity with Linux command line and network configuration.
- A VapiRetell account to obtain an API key.
- Git, Node.js, and Python (version 3.8+) installed.
Deployment Steps
Step 1: Install and Configure Asterisk
Update the system and install Asterisk:
sudo apt update
sudo apt install -y asterisk
sudo systemctl enable asterisk
sudo systemctl start asterisk
Verify Asterisk is running:
sudo asterisk -rv
Run core show version to confirm the version. If details appear, Asterisk is operational.
Step 2: Install VapiRetell API Client
Create a new directory and install the VapiRetell library:
mkdir ai-voice-agent
cd ai-voice-agent
npm init -y
npm install axios
Create a file agent.js and add the following code:
const axios = require('axios');
const API_KEY = 'YOUR_VAPI_RETLL_API_KEY';
const BASE_URL = 'https://api.vapi.ai';
async function callVoiceAgent(text) {
const response = await axios.post(`${BASE_URL}/voice`, {
text: text,
model: 'vapi-voice',
apiKey: API_KEY
});
return response.data;
}
callVoiceAgent('Hello, you are calling the AI auto-attendant system.');
Replace YOUR_VAPI_RETLL_API_KEY with your actual API key.
Step 3: Connect Asterisk with VapiRetell API
In Asterisk, create the configuration file extensions.conf in /etc/asterisk/:
[default]
exten => 100,1,Dial(SIP/agent)
exten => 100,n,Answer()
exten => 100,n,Playback(greeting)
exten => 100,n,Set(VoiceAgentText=Welcome to the AI auto-attendant system)
exten => 100,n,Exec(/usr/bin/node /home/ai-voice-agent/agent.js ${VoiceAgentText})
exten => 100,n,Hangup()
This script triggers the VapiRetell API to process speech when a caller dials 100.
Testing the System
To verify the system:
- Run
sudo systemctl restart asteriskto restart the service. - Call extension 100 from a phone or computer.
- Listen to the AI response generated via VapiRetell API.
Performance Optimization
To ensure stable operation:
- Use
htopto monitor CPU and RAM usage. - Optimize Asterisk configuration in
asterisk.conf. - Set up logging with
loggerto detect errors.
Troubleshooting
If issues arise:
- API not responding: Check network connectivity and API key.
- Asterisk not answering calls: Verify
extensions.confandsip.conf. - Speech errors: Review VapiRetell configuration and model settings.
References
- Asterisk Official Documentation
- VapiRetell API Documentation
- High-RAM Cloud VPS for Self-Hosted LLMs & API Gateways
Related infrastructure & engineering guides: Building an Uptime Kuma Cluster: Mutual Monitoring Solution Between VPS for Enterprises
High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-4E
10% VAT included
- CPU: 4 vCPU
- RAM: 8 GB
- SSD: 50 GB NVMe
