Back to articles
Technology Insight

Building a Multi-Language AI Voice Agent: Integrating Vapi and Asterisk PBX on a VPS for Automated Telesales

May 30, 2026

Introduction: The Evolution of Customer Outreach

The landscape of outbound sales and customer service is undergoing a profound paradigm shift. Traditional telesales operations have long been constrained by high overhead costs, agent fatigue, and the inherent challenges of scaling multi-language support. However, the convergence of Generative Artificial Intelligence (AI) and modern Voice over IP (VoIP) technologies has unlocked a new frontier: automated AI Voice Agents capable of conducting natural, real-time, bi-directional conversations.

By self-hosting your own AI conversational infrastructure, your enterprise can achieve unprecedented scalability while maintaining strict control over data privacy and system configurations. This technical guide provides a comprehensive, step-by-step blueprint for building a multi-language AI Voice Agent for telesales. We will achieve this by integrating Vapi, a cutting-edge voice AI orchestration platform, with Asterisk, the open-source industry standard for private branch exchange (PBX) systems, all deployed on a cost-effective Virtual Private Server (VPS).

Understanding the Architectural Components

Before diving into the implementation phase, it is crucial to understand how the components interact within our automated telecommunication stack. Each layer serves a specific purpose to ensure ultra-low latency and natural conversation flow:

  • Virtual Private Server (VPS): Acts as the hosting bedrock, providing a dedicated environment with a public IP address to run our communication server.
  • Asterisk PBX: Handles the core telecommunication routing, Session Initiation Protocol (SIP) trunking, and connections to local telecom providers.
  • Vapi (Voice AI Platform): Orchestrates the conversational intelligence. It coordinates Speech-to-Text (STT) transcription, Large Language Model (LLM) reasoning, and Text-to-Speech (TTS) synthesis seamlessly.
  • SIP Trunk Provider: Connects our Asterisk server to the Public Switched Telephone Network (PSTN), allowing the system to make and receive real-world phone calls.
Architectural Note: Low latency is the single most critical factor for human-like conversations. The delay between a human finishing a sentence and the AI responding must ideally remain under 1.5 seconds. Strategic deployment of your VPS geographically close to your target audience and Vapi endpoints is essential.

Step 1: Setting Up and Hardening Your VPS

To ensure high availability and clear audio quality, your VPS should meet minimum system requirements: at least 2 vCPUs, 4GB of RAM, and a clean installation of Ubuntu 22.04 LTS. Because this server will be exposed to the public internet with a SIP port, robust security configuration is non-negotiable.

Initial System Update and Firewall Configuration

First, connect to your VPS via SSH and update the core package repositories:

sudo apt update && sudo apt upgrade -y

Next, configure the Uncomplicated Firewall (UFW) to allow standard SSH, along with the specific ports required for SIP signaling and Real-time Transport Protocol (RTP) audio streams:sudo ufw allow 22/tcp sudo ufw allow 5060/udp sudo ufw allow 10000:20000/udp sudo ufw enable

Port 5060 handles the initiation of SIP calls, while the UDP range 10000-20000 facilitates the actual voice data transmission. Implementing an intrusion prevention framework like Fail2ban is highly recommended to mitigate brute-force registration attempts from malicious actors.

Step 2: Installing and Configuring Asterisk PBX

Asterisk will serve as our intelligent media gateway. Install Asterisk directly from the official Ubuntu repositories:

sudo apt install asterisk -y

Once installed, verify that the service is active and running using sudo systemctl status asterisk. Now, we must configure Asterisk to communicate with both our external SIP trunk provider and Vapi.

Configuring PJSIP Channels

Modern Asterisk implementations utilize the chan_pjsip module. Navigate to your configuration directory and open /etc/asterisk/pjsip.conf. You will need to define three critical entities: a transport layer, an endpoint registration for your telecom provider, and an endpoint for Vapi.

Add the following foundational configuration skeleton to establish your network transport:

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060

Following this, define your SIP Trunk details provided by your wholesale telecommunications carrier. This ensures that outbound calls are directed to real phone lines. Ensure that you specify proper access controls so that only authenticated traffic from Vapi can utilize your outbound lines.

Step 3: Connecting Asterisk to Vapi via SIP

Vapi connects to external PBX systems using standard SIP URI routing. To allow Vapi to talk to your Asterisk instance, you must configure a dedicated inbound context in your Asterisk dialplan.

Modifying the Dialplan

Open /etc/asterisk/extensions.conf to manage your call routing logic. We will create a routing context that captures incoming calls from Vapi and forwards them out through our SIP trunk, and vice versa.

[from-vapi]
exten => _X.,1,NoOp(Receiving outbound call request from Vapi)
_X.,n,Dial(PJSIP/${EXTEN}@my-sip-trunk-provider)
_X.,n,Hangup()

[from-pstn]
exten => _X.,1,NoOp(Incoming customer call to AI Agent)
_X.,n,Dial(PJSIP/vapi-endpoint/sip:[email protected])
_X.,n,Hangup()

After saving your modifications, reload the Asterisk configuration engine to apply the changes without dropping active calls: asterisk -rx "core reload".

Step 4: Designing the Multi-Language AI Agent in Vapi

With the telecommunication plumbing established, you can now configure the conversational brain within the Vapi Dashboard or via the Vapi REST API.

1. LLM Prompting & System Instructions

The core behavior of your telesale agent depends on its system prompt. To create a highly adaptive, multi-language agent, use an explicit system instruction block within Vapi:

"You are an elite, professional outbound telesales representative for Enterprise Solutions. Your goal is to qualify leads regarding their cloud infrastructure needs. You must detect the speaker's language instantly (English, Vietnamese, or Spanish) and respond dynamically in the exact same language with native fluency. Be concise, persuasive, and professional."

2. Speech-to-Text (STT) and Text-to-Speech (TTS) Alignment

For high-fidelity, multilingual support, choosing the correct engine models within Vapi is vital:

  • Transcription (STT): Utilize Deepgram Nova-2 or OpenAI Whisper Large. Enable multi-language auto-detection to ensure the model adapts seamlessly without manual intervention.
  • Voice Synthesis (TTS): Select high-quality, emotionally intelligent neural voices from providers like ElevenLabs, OpenAI, or PlayHT. Ensure the selected voice model explicitly supports high-quality multilingual phonetic rendering.

Step 5: Testing, Optimization, and Monitoring

Before launching a production-scale telesales campaign, your system must undergo rigorous latency and functional testing. Execute a test call through the Vapi dashboard or by triggering an API call that commands your Asterisk server to dial your personal phone number.

Key Metrics to Monitor

To maintain an enterprise-grade operational standard, monitor the following metrics continuously:

  1. Round-Trip Time (RTT): Ensure network pings between your VPS, Asterisk, and Vapi remain stable under 100ms.
  2. Jitter and Packet Loss: High UDP packet loss degrades audio quality, causing the STT engine to misinterpret human speech. Keep packet loss strictly under 1%.
  3. Context Switching Latency: Assess how rapidly the LLM switches contexts when a customer interrupts mid-sentence. Adjust Vapi's Interruption Threshold settings to make transitions feel completely natural.

Conclusion: Scalable Customer Engagement

By marrying the robust, battle-tested routing capabilities of Asterisk with the advanced conversational intelligence of Vapi, you create a powerful, self-hosted telecommunications asset. This custom AI Voice Agent station operates 24/7, eliminates human fatigue, breaks down language barriers across global markets, and radically reduces traditional call center overhead.

As you scale, you can continuously optimize your system by connecting backend Customer Relationship Management (CRM) databases to your Asterisk dialplan, allowing your AI agent to fetch real-time customer histories during active phone calls. The future of business communication is autonomous, and your infrastructure is now fully equipped to lead the charge.

Building a Multi-Language AI Voice Agent: Integrating Vapi and Asterisk PBX on a VPS for Automated Telesales | DPTCloud