Philippe’s suggestion is solid. Here’s a more concrete breakdown of the two main paths since I’ve done this a few times.
**Path 1: AMI + Open CTI (simplest)**
This is the fastest way if you just need click-to-call and screen pops. The flow:
1. Salesforce Open CTI adapter (JavaScript in a Visualforce page or Lightning component) talks to your middleware
2. Middleware is a small Node.js or Python service that holds a persistent AMI connection to Asterisk
3. Click-to-call sends an Originate action through AMI:
```
Action: Originate
Channel: PJSIP/agent-extension
Context: from-internal
Exten: 15551234567
Priority: 1
CallerID: “Salesforce” <15559876543>
Variable: SF_CASE_ID=500ABC123
```
4. For screen pops, your middleware listens for Newchannel/Newstate events on AMI, matches the CallerID against Salesforce via the REST API, and pushes the contact record URL back to the Open CTI adapter via WebSocket
The key thing people get wrong: don’t open a new AMI connection per call. Keep 2-3 persistent connections and multiplex. Asterisk dispatches every channel event to every AMI session, so 50+ connections will choke the Stasis message bus.
**Path 2: ARI + WebRTC (more control, more work)**
If you need a softphone embedded in Salesforce (no desk phone), you’re looking at ARI + WebRTC like Philippe mentioned. The moving parts:
- ARI controls the call flow (answer, bridge, hold, transfer)
- WebRTC handles the actual media in the browser
- SRTP + WSS between the browser and Asterisk
- Salesforce Lightning Web Component wraps the softphone UI
This gives you call recording, whisper coaching, conference — everything. But it’s a real project, not a weekend hack.
**Which to pick?**
If your agents already have SIP phones: Path 1. You can have click-to-call and screen pops working in a day.
If you want a browser-only softphone inside Salesforce: Path 2, budget 2-3 weeks.
I wrote up the full AMI action reference with working code for Originate, Events, and connection pooling here: [Asterisk AMI Commands Guide]( Asterisk AMI Commands Guide | ViciStack Blog ) — covers the exact patterns you’d need for the middleware layer.