How to Build an OpenClaw FreePBX VoIP Agent on Raspberry Pi
A Raspberry Pi 4 can run both FreePBX (the open-source Asterisk management GUI) and the OpenClaw AI agent gateway, giving you a sub-$100 phone system with AI-powered call handling. This guide covers installing Asterisk and FreePBX on ARM64 Linux, connecting SIP trunks through Twilio or Telnyx, configuring the OpenClaw voice-call plugin for AI-driven conversations, and using Fastio workspaces to store call logs, voicemail transcripts, and telephony config files.
Why Run a PBX and an AI Agent on the Same Pi
A Raspberry Pi running FreePBX handles the same call routing, voicemail, and extension management as a commercial PBX appliance that costs $500 to $2,000. Add OpenClaw to the same board and you get an AI agent that can place outbound calls, transcribe voicemail, and respond to callers with natural language, all for under $100 in hardware and a few dollars per month in electricity and SIP provider fees.
The architecture splits cleanly. FreePBX (built on Asterisk) manages SIP registration, dial plans, inbound routing, and voicemail. OpenClaw runs as a separate gateway process that connects to cloud LLMs for reasoning. The two systems share a SIP trunk provider like Twilio or Telnyx as the bridge between traditional telephony and AI-powered conversation.
This setup works because the Pi is not doing the heavy compute for either system. Asterisk handles SIP signaling and lightweight audio transcoding. OpenClaw routes voice data to cloud APIs for speech-to-text, language model processing, and text-to-speech. A Pi 4 with 4GB RAM comfortably handles both workloads running side by side.
Existing Pi FreePBX guides cover the installation, but they stop there. None of them address how to add an AI layer for call monitoring, automated responses, or voicemail transcription. That is the gap this guide fills.
What You Need Before Starting
The hardware list is short and inexpensive. Here is what you need:
Hardware:
- Raspberry Pi 4 (4GB RAM) or Pi 5 (4GB or 8GB). The Pi 4 handles 10 to 20 concurrent SIP calls without transcoding. The Pi 5 gives you more headroom for running both services
- USB SSD (32GB minimum, 64GB recommended). SD cards wear out faster under the constant write load from call detail records and voicemail storage
- Ethernet cable and a stable internet connection. Wi-Fi adds latency and jitter to VoIP calls
- USB-C power supply rated for your Pi model (15W for Pi 4, 27W for Pi 5)
Software:
- Raspberry Pi OS Lite (64-bit, Bookworm). Use the headless image since you will not need a desktop environment
- Asterisk 22 and FreePBX 17 (installed from the Sangoma install script or the RasPBX project)
- Node.js 24 (required by the OpenClaw gateway)
- OpenClaw (installed via the official install script)
Accounts you need:
- A SIP trunk provider account (Twilio Elastic SIP Trunking, Telnyx, or another provider that supports SIP registration)
- At least one DID (phone number) from your trunk provider
- An API key for a cloud LLM (Anthropic, OpenAI, or Google)
- An OpenClaw account for gateway licensing
Total cost breakdown:
- Pi 4 (4GB) board: roughly $55
- Case, power supply, and SSD: roughly $30 to $40
- SIP trunk: pay-per-minute with no monthly minimums on most providers (Telnyx and VoIP.ms start under $0.01 per minute)
- Cloud LLM API: usage-based, typically $0.50 to $5 per month for light telephony workloads
- Electricity: under $5 per year at typical residential rates
Compare that to a commercial PBX appliance at $500 to $2,000, plus per-seat licensing fees.
Install Asterisk and FreePBX on the Pi
Start with a fresh Raspberry Pi OS Lite (64-bit) image flashed via Raspberry Pi Imager. Enable SSH during the imaging process so you can work headlessly from another machine.
After first boot, update the system and install dependencies. The FreePBX community maintains installation scripts that handle the Asterisk compilation and FreePBX package setup on ARM64 Debian. The RasPBX project on GitHub (playfultechnology/RasPBX) provides a step-by-step guide specifically for Raspberry Pi hardware, including dependency resolution for the ARM64 architecture.
The installation compiles Asterisk from source, which takes 30 to 60 minutes on a Pi 4. Once complete, FreePBX runs as a web interface on port 80, giving you a browser-based GUI for managing extensions, trunks, inbound routes, and outbound routes.
Key configuration steps after installation:
- Create SIP extensions for your phones (softphones like Zoiper or Linphone work well for testing)
- Set up your SIP trunk. If you are using Twilio Elastic SIP Trunking, note that Twilio does not support SIP REGISTER. You will need to configure IP-based authentication by adding your Pi's public IP to Twilio's trusted IP list. Telnyx supports standard SIP registration, which is simpler to configure in FreePBX
- Configure inbound routes to direct incoming calls to specific extensions or an IVR
- Configure outbound routes to send calls through your SIP trunk, making sure phone numbers use E.164 format
- Test a call end to end: dial from a softphone to an external number and verify audio flows in both directions
FreePBX supports the G.711 (ulaw/alaw) and G.722 codecs without transcoding overhead. Avoid enabling codecs like G.729 that require CPU-intensive transcoding, since that is where Pi performance limits become noticeable. With passthrough codecs, a Pi 4 comfortably handles 10 to 20 simultaneous calls.
Performance note: Research from the Electronics journal testing Asterisk on Raspberry Pi 3 hardware found that CPU utilization stayed under 15% for most codecs at 100 concurrent calls, but memory usage climbed past 95% and caused instability. The Pi 4's 4GB RAM gives you more headroom, but plan for 10 to 20 concurrent calls as a practical ceiling for stable operation.
Give Your Telephony Agent Persistent File Storage
Upload call recordings, voicemail transcripts, and PBX configs to a workspace your whole team can search. generous storage, no credit card, MCP-ready API for your OpenClaw agent.
Install and Configure the OpenClaw Gateway
With FreePBX handling traditional PBX duties, OpenClaw adds the AI layer. The OpenClaw gateway is a Node.js process that routes messages between communication channels (including voice calls) and cloud LLMs.
Install OpenClaw on the same Pi using the official install script. The gateway runs as a systemd service alongside Asterisk, and the two processes do not conflict since they listen on different ports. Asterisk uses SIP ports (5060/5061), while the OpenClaw gateway dashboard listens on port 18789.
After running the onboard command, configure your LLM provider. OpenClaw supports Anthropic Claude, OpenAI GPT, Google Gemini, and other providers. For telephony workloads where response latency matters, models with fast output speeds work best.
Optimizations for running both services on one Pi:
- Allocate GPU memory to the minimum (16MB) in the Pi's boot config since neither Asterisk nor OpenClaw uses the GPU
- Use a USB SSD instead of an SD card. Both Asterisk CDR logging and OpenClaw workspace writes benefit from faster I/O
- Disable services you do not need: Bluetooth, CUPS (printing), and Avahi (mDNS) all consume memory that Asterisk and OpenClaw can use instead
- Monitor memory usage with
htoporfree -m. If the combined footprint pushes past 3GB on a 4GB Pi, consider upgrading to a Pi 5 with 8GB
The gateway architecture is lightweight by design. OpenClaw's official documentation describes the Pi as "just the gateway" since models run in the cloud via API. That is why both OpenClaw and Asterisk fit comfortably on the same board.
Configure the OpenClaw Voice-Call Plugin
The voice-call plugin is what turns OpenClaw from a text-only agent into one that can handle phone conversations. It supports outbound notification calls and multi-turn conversations with live transcription, and the agent can execute tools mid-call (checking calendars, searching documents, posting to messaging channels).
The voice-call plugin runs inside the OpenClaw gateway process. It connects to your SIP trunk provider's API, not directly to Asterisk's SIP stack. This means your architecture uses the trunk provider as a shared bridge: FreePBX routes traditional PBX calls through the same trunk, while OpenClaw's voice-call plugin handles AI-driven calls through the provider's programmable voice API.
Supported providers for the voice-call plugin:
- Twilio (Programmable Voice and Media Streams)
- Telnyx (Call Control v2)
- Plivo (Voice API with XML transfer)
The plugin needs a publicly reachable webhook URL so the provider can send call events back to your Pi. You have three options: configure a publicUrl if your Pi has a static IP and open port, use the built-in tunnel option, or set up Tailscale for a private mesh network approach.
Inbound call handling: By default, the voice-call plugin rejects inbound calls. Enable them by setting the inbound policy to allowlist mode and specifying which phone numbers can reach the AI agent. You can configure per-number routing so different incoming numbers get different greetings, system prompts, and TTS voices.
Outbound calls: The plugin supports two modes. Notify mode places one-way calls to deliver a message (useful for alerts and reminders). Conversation mode enables full multi-turn dialogue where the AI agent speaks, listens, processes the response through an LLM, and replies.
Audio processing options:
- Realtime voice mode for full-duplex conversation using Google Gemini Live or OpenAI's realtime API
- Streaming transcription mode using Deepgram, ElevenLabs, or OpenAI for speech-to-text paired with separate TTS
These two modes are mutually exclusive. Realtime voice gives the most natural conversational experience but requires a realtime-capable provider. Streaming transcription works with a wider range of TTS and STT services.
How the FreePBX and OpenClaw pieces fit together: Your SIP trunk provider (say, Telnyx) holds your phone numbers. In FreePBX, you create a SIP trunk pointing to Telnyx for handling regular extension-to-extension calls, IVR menus, and voicemail. In OpenClaw, you configure the voice-call plugin with the same Telnyx account credentials. FreePBX handles the PBX routing layer. OpenClaw handles the AI conversation layer. Both use the same provider, same numbers, and run on the same Pi.
Store Call Data and Transcripts with Fastio
A telephony system generates files: call recordings, voicemail audio, CDR exports, transcription text, and configuration backups. On a Pi with limited local storage, you need a reliable place to send those files for long-term access and team collaboration.
Local storage works for small deployments, but it ties your data to a single SD card or SSD. A network share (NFS, SMB) adds complexity and another device to maintain. Cloud storage like S3 requires CLI tooling and IAM configuration. Fastio offers a middle path: a workspace where you upload files through the API or MCP server, and your team (or other agents) can access them through a web interface or their own API calls.
What to store in a Fastio workspace:
- Call recordings and voicemail files, organized by date or extension
- Transcription output from the OpenClaw voice-call plugin's STT processing
- FreePBX configuration backups (exported from the Admin module)
- CDR exports for call analytics and billing reconciliation
- SIP trunk configuration notes and change logs
The Business Trial gives you 50GB of storage, 5 workspaces, and included credits with no credit card required. For a small office PBX generating a few hundred calls per month, that is more than enough capacity.
Fastio's Intelligence Mode auto-indexes uploaded files for semantic search. Once enabled on a workspace, you can search your call transcripts by meaning rather than exact keywords. Ask "find all calls where the customer asked about refund policy" and get results across hundreds of transcript files.
If you are running OpenClaw with the Fastio MCP server, the agent can upload files directly to a workspace as part of its post-call workflow. The MCP server exposes tools for workspace management, file upload, and AI queries, all accessible from the same agent that is handling your voice calls.
For teams, Fastio's sharing features let you create branded file shares for specific call archives. A branded share with receive permissions lets team members upload voicemail files from other systems into the same workspace. Ownership transfer means an agent can set up the entire workspace structure and then hand administrative control to a human manager.
How to Troubleshoot Common VoIP and Agent Issues
Here are three concrete ways to use this setup, followed by common problems and their fixes.
Scenario 1: After-hours AI receptionist. Configure FreePBX time conditions to route calls to a ring group during business hours and to the OpenClaw voice-call plugin after hours. The AI agent answers, takes a message, transcribes it, and uploads the transcript to a Fastio workspace where your team can review it the next morning.
Scenario 2: Voicemail transcription and alerting. FreePBX stores voicemail as WAV files on disk. A cron job or OpenClaw automation watches the voicemail spool directory, picks up new files, runs them through a speech-to-text API, and posts the transcript to a Telegram channel or Slack workspace. The audio file and transcript both get uploaded to Fastio for archival.
Scenario 3: Outbound appointment reminders. The OpenClaw agent reads an appointment list (from a CSV in a Fastio workspace or a calendar API), then uses the voice-call plugin in notify mode to call each person with a spoken reminder. Call outcomes (answered, voicemail, no answer) get logged back to the workspace.
Common issues and fixes:
No audio on calls: This almost always comes down to NAT traversal. Check that your FreePBX SIP settings include your Pi's external IP address and local network range. If you are behind a router, configure port forwarding for UDP ports 10000 to 20000 (RTP media) and 5060 (SIP signaling). Twilio users should also verify that their Elastic SIP Trunk is configured for the correct codec.
OpenClaw webhook unreachable: The voice-call plugin requires a publicly accessible URL for your trunk provider to send call events. If your Pi is behind NAT without port forwarding, use the plugin's tunnel option or set up Tailscale and expose a funnel. Test the webhook by curling the URL from an external machine before trying to place a call.
High latency on AI responses during calls: If there is a noticeable delay between the caller speaking and the AI responding, check two things. First, verify your STT provider is using a streaming endpoint rather than batch processing. Second, confirm your LLM provider has acceptable response times. Models optimized for speed rather than maximum capability often work better for real-time telephony.
Memory pressure with both services running: Monitor with free -m and htop. If Asterisk and OpenClaw combined push past 3.5GB on a 4GB Pi, reduce Asterisk's maximum concurrent call limit in the SIP settings and consider moving to a Pi 5 with 8GB RAM.
Frequently Asked Questions
Can a Raspberry Pi run FreePBX?
Yes. FreePBX runs on Raspberry Pi OS (64-bit) with Asterisk compiled from source for the ARM64 architecture. The Pi 4 with 4GB RAM handles 10 to 20 concurrent calls using passthrough codecs like G.711. The RasPBX project and FreePBX community forums provide installation guides specific to Pi hardware.
How many calls can a Raspberry Pi PBX handle?
A Pi 4 with 4GB RAM reliably handles 10 to 20 concurrent calls when using passthrough codecs (G.711 ulaw/alaw or G.722). Enabling CPU-intensive transcoding codecs like G.729 reduces that number. Memory is the bottleneck rather than CPU. Performance testing on earlier Pi hardware showed instability above 50 concurrent calls due to memory exhaustion.
Is FreePBX free to use?
FreePBX is open-source software released under the GPL license. You can download, install, and use it without paying licensing fees. Sangoma (the company behind FreePBX) offers paid commercial modules for features like endpoint management and SIPStation trunking, but the core PBX functionality, including SIP trunking, extensions, IVR, voicemail, and call routing, is free.
How does the OpenClaw voice-call plugin connect to FreePBX?
The two systems share a SIP trunk provider rather than connecting directly. FreePBX uses the provider's SIP trunk for traditional call routing. OpenClaw's voice-call plugin uses the same provider's programmable voice API for AI-driven calls. Twilio, Telnyx, and Plivo are supported by the voice-call plugin and all offer SIP trunking for FreePBX.
What does it cost to run a Pi-based PBX with AI calling?
Hardware costs run $85 to $100 for the Pi, case, power supply, and storage. SIP trunk providers charge per minute with no monthly minimums, typically under $0.01 per minute for domestic calls. Cloud LLM API costs for telephony workloads range from $0.50 to $5 per month depending on call volume. Electricity adds under $5 per year. Total ongoing costs are usually under $10 per month for a small office.
Can OpenClaw make and receive phone calls on its own?
Yes, through the voice-call plugin. It supports outbound calls in notify mode (one-way messages) and conversation mode (multi-turn dialogue). Inbound calls require setting an allowlist of permitted caller numbers. The agent can execute tools mid-call, like searching files, checking calendars, or posting to messaging channels. Audio processing uses either realtime voice (Google Gemini Live, OpenAI) or streaming transcription (Deepgram, ElevenLabs).
Related Resources
Give Your Telephony Agent Persistent File Storage
Upload call recordings, voicemail transcripts, and PBX configs to a workspace your whole team can search. generous storage, no credit card, MCP-ready API for your OpenClaw agent.