---
schema_version: "1"
id: 56078dffb1594629a5b1718c814d10840802823c50f9b3e15d9188b61baa0ccb
title: onClickToDial() for Lightning Experience
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/api-cti/guides/sforce-api-cti-onclicktodial-lex.md
canonical_url: https://developer.salesforce.com/docs/service/api-cti/guide/sforce-api-cti-onclicktodial-lex.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f250855827391f8fb0bdd4067b4439a6d5b9aba455a0c43a40e433e2d34fa202
products:
  - Open CTI Developer Guide
  - Service Cloud Developer Content
---

# onClickToDial() for Lightning Experience

## Usage

Registers a function to call when a user clicks an enabled phone number. This method is available in API version 38.0 or later.

**note:** You can use this method with the Lightning web component `lightning-click-to-dial`. You can also use it with the Aura component `lightning:clickToDial`. Keep in mind that you can’t use either component in iFrames. This method can’t be used with the Visualforce component `support:clickToDial`.

## Syntax

```javascript
sforce.opencti.onClickToDial({
     listener: FUNCTION
})
```

## Arguments

|Name|Type|Description|
|------|------|-------------|
|`listener`|function|JavaScript method called when the user clicks an enabled phone number.|


## Sample Code–HTML and JavaScript

<!-- html set_clipboard -->
```html
<html>
  <head>
    <script type="text/javascript" src="https://domain:port/support/api//lightning/opencti_min.js"></script>
    <script type="text/javascript">
      var listener = function(payload) {
        console.log('Clicked phone number: ' + payload.number);
      };

      // Register the listener.
      window.addEventListener('load', function() {
        sforce.opencti.onClickToDial({listener: listener});
      });
   </script>
  </head>
</html>

```

## Payload

The payload object passed to each call to the listener method contains the following fields.

|Name|Type|Description|
|------|------|-------------|
|`number`|number|Provides the phone number clicked by the user.|
|`recordId`|string|Provides the ID of the record associated with the clicked phone number.|
|`recordName`|string|Provides the name of the record for the clicked phone number.|
|`objectType`|string|Provides the type of record associated with the clicked phone number.|
|`accountId` or `contactId`|string|If the clicked phone number belongs to a person account, the associated account or contact ID is provided.|
|`personAccount`|boolean|If the clicked phone number belongs to a person account, this property is `true`.If person accounts aren’t enabled in your org, this field isn’t included in the payload object.|
|`params`|string|Comma-separated list of parameters associated with the phone number passed into the component.|


