Registering an Event Sink is JavaScript code the CTI app loads when the agent opens Salesforce. The CTI app calls Salesforce''s Open CTI subscribe method with the event name and handler function.
- Load the Open CTI library
Include the Open CTI JavaScript library in your CTI app''s HTML. The library is hosted by Salesforce: /support/console/49.0/integration.js (or current API version). Include it via script tag.
- Subscribe to the event
Call sforce.opencti.subscribe({ eventType: onClickToDial, listener: myHandler }). The eventType is the event you want to receive; the listener is your JavaScript function. Salesforce confirms the subscription was registered.
- Implement the handler function
The handler function takes a payload argument with event-specific data: function myHandler(payload) { console.log(payload.number); }. Handlers should be quick: process the event, dispatch any expensive work to async functions, return.
- Test the integration
Trigger the event in Salesforce: click a click-to-dial phone number on a Contact record. Confirm the handler fires with the expected payload. Use browser developer tools to debug.
- Handle multi-tab scenarios
In Service Cloud Console, use the Console API to track which tab is active. An Event Sink that fires on tab navigation should check whether the current tab is the call-active tab before reacting.
- Unsubscribe when needed
To remove a handler, call sforce.opencti.unsubscribe({ eventType: onClickToDial }). The CTI app should unsubscribe before the agent closes Salesforce or switches CTI implementations to avoid orphaned handlers.
The Salesforce framework for custom telephony integration. Supports Event Sinks via subscribe/unsubscribe API.
Modern alternative to Open CTI for Amazon Connect-backed telephony. Different event model.
Fires when a user clicks a phone number. Used to initiate a call from the CTI softphone.
Fires when the user navigates to or updates a record. Used to track agent context.
Fires when the agent''s softphone status changes. Used for state synchronization.
- Synchronous handlers block the Salesforce UI. Heavy work in Event Sinks creates visible lag for the agent.
- Multi-tab Console apps complicate Event Sinks. Handlers must check the current tab context before reacting to events; otherwise events fire in the wrong context.
- Open CTI is legacy for new Amazon Connect-backed deployments. Service Cloud Voice''s native integration is the modern path; Open CTI exists for backward compatibility and non-Amazon-Connect providers.
- Event Sinks do not retry on errors. If the handler throws an exception, the event is lost. Wrap handlers in try/catch and log errors deliberately.