Connecting your PBX to a CRM enables call pop-ups showing caller information, automatic call logging against customer records, and click-to-dial functionality — streamlining sales and support workflows.
Common Integration Patterns
- Screen pop — automatically displaying the relevant customer record when a call comes in, based on caller ID matching
- Click-to-dial — initiating a call directly from within the CRM interface
- Automatic call logging — recording call duration, outcome, and notes against the associated customer record
Approach 1 — Using Asterisk's AMI (Asterisk Manager Interface)
AMI provides a way for external applications to monitor and control Asterisk in real time — the foundation most custom CRM integrations build on.
sudo nano /etc/asterisk/manager.conf
[integration-user]
secret = CHANGE_ME_STRONG_PASSWORD
read = call,cdr
write = call
permit = YOUR_APPLICATION_SERVER_IP/255.255.255.255
Restrict AMI access to only the specific server running your integration, never expose it broadly.
Approach 2 — Using Asterisk REST Interface (ARI)
ARI offers a more modern, REST/WebSocket-based way to interact with Asterisk programmatically — often a cleaner foundation for new custom integrations compared to the older AMI protocol.
Approach 3 — Pre-Built CRM Connectors
Many popular CRMs have existing FreePBX/Asterisk integration modules or marketplace apps — check whether your specific CRM already has a maintained connector before building a custom integration from scratch.
Building a Basic Screen-Pop Integration (Conceptual Example)
const AmiClient = require('asterisk-manager');
const ami = new AmiClient(5038, 'YOUR_SERVER_IP', 'integration-user', 'CHANGE_ME_STRONG_PASSWORD', true);
ami.on('managerevent', (evt) => {
if (evt.event === 'Newchannel' && evt.calleridnum) {
// Look up evt.calleridnum in your CRM
// Trigger a screen-pop notification to the relevant agent
}
});
Logging Call Data to Your CRM via CDR
Asterisk's Call Detail Records (CDR) can be configured to write directly to a database or trigger a webhook on call completion, letting you sync call outcomes and duration to CRM records automatically rather than manual entry.
[cdr]
enabled = yes
[csv]
usegmtime = yes
Handling Caller ID Matching
Screen-pop functionality depends on reliably matching the incoming caller ID number to an existing CRM contact — account for formatting differences (with/without country code, dashes/spaces) when implementing the lookup logic.
Security Considerations
Any integration touching AMI/ARI has significant control over your phone system — use dedicated, restricted credentials specifically for the integration (never your admin account), and restrict network access to only the specific application server needing it.
Common Errors
AMI connection refused — verify the permit IP restriction in manager.conf matches your actual application server's IP, and that the AMI port (5038) isn't blocked by the firewall for that specific source.
Continue Reading
- How to Configure Extensions and Voicemail in Asterisk
- How to Set Up Call Recording and Compliance Logging
- How to Build and Secure a REST API on a VPS
Browse more articles in VoIP & Communication Servers.