Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
DictionaryEEvent Sink, CTI
Core CRMBeginner

Event Sink, CTI

An Event Sink in Salesforce Open CTI is a JavaScript handler registered by a CTI implementation to receive events from Salesforce.

§ 01

Definition

An Event Sink in Salesforce Open CTI is a JavaScript handler registered by a CTI implementation to receive events from Salesforce. The Open CTI framework lets external telephony providers (and modern Service Cloud Voice integrations) hook into platform events: when an agent changes status, when a softphone receives a call, when a click-to-dial button is pressed, when the user navigates to a different record. The Event Sink is the JavaScript function the CTI app provides; Salesforce calls it when the relevant event happens.

Open CTI is the framework that lets custom telephony integrations live inside Salesforce without requiring server-side communication for every UI event. The Event Sink is the callback registration mechanism: the CTI app calls sforce.opencti.subscribe() (or the Lightning equivalent) with an event name and a handler function. From that point on, Salesforce invokes the handler whenever the event fires. This is how CTI implementations stay in sync with the Salesforce UI: agent status changes in the softphone reflect on the agent''s Salesforce page, and vice versa.

§ 02

How Event Sinks work in Open CTI

Open CTI as the integration framework

Open CTI is the JavaScript framework Salesforce provides for custom telephony integration with Salesforce Classic and Lightning Experience. CTI vendors (Five9, NICE inContact, Genesys, Salesforce''s own Service Cloud Voice in some configurations) implement Open CTI to display their softphone inside Salesforce. Open CTI defines what the softphone can do (popup screens, dial numbers, update status) and how Salesforce communicates events back (agent status changed, call received, button clicked).

The Event Sink pattern

An Event Sink is a JavaScript function the CTI implementation registers as a callback for a specific event. The CTI app calls sforce.opencti.subscribe({ eventType: onClickToDial, listener: myClickHandler }) and from that point Salesforce calls myClickHandler whenever a user clicks a click-to-dial-enabled phone number. The Event Sink is the bridge between Salesforce-internal events and the CTI app''s custom logic.

Common events that have Event Sinks

Frequently subscribed-to events: onClickToDial (user clicked a phone number), onObjectUpdate (the agent navigated to or updated a record), onAgentStateChange (the agent''s softphone status changed), onCallStarted and onCallEnded (a call connected or disconnected). Each event has a specific payload the Event Sink receives: phone number, record Id, status code.

The Lightning Open CTI API versus Classic

Salesforce Classic and Lightning Experience have separate Open CTI APIs. Classic uses sforce.opencti namespace; Lightning uses sforce.opencti as well but with different event names and payloads in some cases. CTI vendors typically support both, with feature detection picking the right API. Lightning Open CTI is more modern and recommended for new integrations.

Multi-tab and console-app considerations

In Service Cloud Console apps, agents have multiple tabs open. Event Sinks must handle this: an Event Sink subscribing to onObjectUpdate will fire as the user navigates between tabs. CTI apps need to track which tab the call belongs to and which tab the user is currently viewing. Lightning Console APIs help here, but the integration logic still needs to handle multi-tab cases explicitly.

Performance considerations

Event Sinks fire synchronously in many cases. A long-running handler blocks the Salesforce UI. The pattern is to do as little work as possible in the Event Sink itself, then dispatch any heavy work to a background async function. This keeps the agent UI responsive even when the CTI logic is busy.

Service Cloud Voice and the modern alternative

Service Cloud Voice uses a different integration model than legacy Open CTI: native Amazon Connect integration with deeper Salesforce events. New CTI deployments often start with Service Cloud Voice rather than Open CTI. Open CTI is still relevant for legacy telephony providers and non-Amazon-Connect integrations; over time, Service Cloud Voice is the trend.

§ 03

How to register an Event Sink in an Open CTI implementation

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Key options
Open CTI (Classic and Lightning)remember

The Salesforce framework for custom telephony integration. Supports Event Sinks via subscribe/unsubscribe API.

Service Cloud Voiceremember

Modern alternative to Open CTI for Amazon Connect-backed telephony. Different event model.

onClickToDial eventremember

Fires when a user clicks a phone number. Used to initiate a call from the CTI softphone.

onObjectUpdate eventremember

Fires when the user navigates to or updates a record. Used to track agent context.

onAgentStateChange eventremember

Fires when the agent''s softphone status changes. Used for state synchronization.

Gotchas
  • 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.
§

Trust & references

Sources

Cross-checked against the following references.

Official documentation

Straight from the source - Salesforce's reference material on Event Sink, CTI.

Was this entry helpful?
Help us write better definitions. Quick reactions or detailed edit suggestions.

About the Author

Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.

§

Test your knowledge

Q1. What is an Event Sink in CTI?

Q2. What CTI framework do modern event sinks use?

Q3. Who typically writes event sink code?

§

Discussion

Loading…

Loading discussion…