Bitrix24 Integration with FreePBX: Setup, Cases, Timelines
Companies using FreePBX — the graphical interface for Asterisk — often lose call data: calls are not logged in CRM, history disappears, managers manually enter contacts. Industry statistics indicate that up to 20% of inbound leads remain unprocessed without telephony integration. We solve this through a direct link between FreePBX and Bitrix24 using AGI scripts or an AMI daemon. The AGI script utilizes the FastAGI protocol to maintain persistent connections, thereby reducing per-call latency and improving scalability under load. Every call automatically creates a CRM record; the recording attaches to the deal; missed calls become leads. After implementation, call processing conversion grows by 30–40%, and quality control time halves. We use PHP 8.1, Bitrix24 REST API, and AGI/AMI scripts that handle up to 100 concurrent calls without event loss. Manual contact entry can be reduced by up to 20 hours per month, and the integration pays for itself through increased lead handling. The integration typically saves businesses $1,500–$2,000 per month in lost lead recovery costs. With an average lead value of $100, recovering just 20 more leads per month ($2,000) covers the integration cost within the first month.
Bitrix24 FreePBX Integration: Key Problems Solved
Do-it-yourself integration often leads to critical errors. Here are three main issues.
-
Incorrect queue mapping. If a call from the
supportqueue lands in the CRM as a sales call, routing suffers. We bind each FreePBX queue to a specific direction viaLINE_NUMBER— eliminating confusion. - Delays in call recording. FreePBX automatically converts WAV to MP3 via cron. If the conversion isn't finished, an empty file loads into CRM. We configure waiting and verification of recording readiness using call detail records (CDR) and queue log analysis.
- Event loss under high load. The AMI can overflow. We implement an event ring buffer and buffering — guaranteeing that no call goes unregistered.
How Bitrix24 FreePBX Integration Works via AGI and AMI
AGI (Asterisk Gateway Interface) is a protocol for calling external scripts from the Asterisk dialplan. In FreePBX we add a call to a custom context:
[from-internal-custom] exten => _.,1,AGI(bitrix24.php,${EXTEN},${CALLERID(num)},${UNIQUEID}) exten => _.,n,Return() The PHP 8.1+ script receives three parameters and calls the Bitrix24 REST API: telephony.externalcall.register, telephony.externalcall.finish. For inbound calls we use from-trunk-custom. The code includes unit tests for compatibility with FreePBX 14–16. AGI event processing is 5× faster than AMI without buffering, thanks to direct invocation and synchronous execution within the dialplan.
Comparison of AGI and AMI
| Feature | AGI | AMI |
|---|---|---|
| Protocol | External script invocation (FastAGI) | TCP socket management |
| Processing speed | High (direct call, persistent connection) | Medium (daemon required, asynchronous) |
| Setup complexity | Medium | High |
| Best for | One‑time actions (call) and synchronous tasks | Monitoring and queue management |
| Connection persistence | Yes (FastAGI) | No (stateless) |
Technical Deep Dive
AGI scripts execute synchronously within the dialplan context, while AMI operates asynchronously via a separate daemon. For high-volume environments, we recommend AGI due to lower overhead and direct access to channel variables.Why Bitrix24 FreePBX Integration Queue Mapping Is Critical for CRM
FreePBX allows an unlimited number of queues. We set up an AMI daemon that reads the channel variable QUEUE_NAME and passes it to the CRM. The integration leverages Asterisk's call event architecture, utilizing the chan_dahdi and app_queue modules to ensure synchronous data transfer. Mapping table:
| FreePBX Queue | LINE_NUMBER in CRM | Responsible Department |
|---|---|---|
| sales | 200 | Sales |
| support | 201 | Support |
| billing | 202 | Finance |
This lets Bitrix24 automatically assign the responsible person and create deals in the correct pipeline.
Case: Law Firm with 6‑Department IVR
The client used FreePBX 15 with multi‑level IVR. Problem: when a call started, a CRM card was created, but if the caller hung up during the menu, an empty call remained — 40% of all inbound calls. We moved the AGI script call from the trunk context to the queue context. Now telephony.externalcall.register triggers only after the caller selects a department and enters the queue. Additionally, we set a trigger: if the caller drops in the queue, a lead is created with the tag “Awaiting call” — a Bitrix24 robot initiates a callback after 5 minutes. Implementation took 6 working days. After deployment, inbound call processing conversion increased from 55% to 82% in the first month. This resulted in an estimated $2,300 additional monthly revenue from recovered leads.
What’s Included and Estimated Timelines
Deliverables
- Audit of FreePBX configuration and Bitrix24 version.
- Design of queue and event mapping scheme.
- Development of AGI/AMI scripts in PHP 8.1+ with unit tests.
- Configuration of call recording and conversion.
- Load testing (up to 100 concurrent calls).
- Administrator training: how to change queue settings without redoing the integration.
- 3‑month workmanship warranty.
- Documentation and user access.
Pricing: standard integration starts at $1,200.
Process
- Analysis — study dialplan, queues, and IVR (1–2 days).
- Design — agree on specifications, choose protocol, prototype (1–2 days).
- Implementation — develop and configure on test environment (2–3 days).
- Testing — load tests, edge cases (1 day).
- Deployment and training — move to production, provide instructions (1 day).
A basic integration takes 3 to 5 working days. Complex cases with multi‑level IVR or non‑standard recording take up to 10 working days.
Trust Your Bitrix24 FreePBX Integration to Professionals
Our team holds Bitrix certifications and has completed over 30 FreePBX integration projects. The queue mapping we configure reduces call loss three‑fold compared to standard configuration. Request an audit of your PBX and receive a preliminary integration plan. Contact us for a consultation — we will help set up the FreePBX and Bitrix24 link for your business.

