# Setting up click-to-call features

Bitrix24 supports the click-to-call function, when a call is made by clicking on a phone number in the portal. Technically it looks like this:

* After the user clicks on the phone in the portal, the command goes to the module;
* The module sends the originate command to Asterisk (parameters can be adjusted in the config file and customizer);
* Asterisk dials first to the operator. When he picks up the phone, Asterisk will send an external call to the client.

{% hint style="warning" %}
When using IAX2 peers, the click-to-call function will not work.
{% endhint %}

## Configuring click-to-call in the module admin panel

There are two options for enabling:

1. Open port 8077 on the router to receive external requests from Bitrix24;
2. Or use our click-to-call server to send requests.

**For the first option:**

1. **Specify your external (!) IP address** in the “Address for requests from Bitrix” field in the admin panel section Settings → Module (see figure) – use the url address format (indicating the protocol);
2. **Forward port 8077 on the router** - a request from B24 will be sent to it, transmitted to the module, and the module will send a "call" command to Asterisk.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2F8PEkmL3SObiIt2MlTWHS%2Fc2cenip.jpg?alt=media&#x26;token=f4e66731-0171-4420-ae00-7e10f8939e02" alt=""><figcaption></figcaption></figure>

**Second option**

If you don't want to open the port, then you can use an external click-to-call server.

To do this, enable the option in the admin panel section **Settings → Bitrix24** (see figure).

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FGzWzUFozT8EiBoFOgG0w%2Fc2cen.jpg?alt=media&#x26;token=8b54c757-a60f-4e7a-9920-4ade2b4a7aec" alt=""><figcaption></figcaption></figure>

In order for click-to-call to work, you need to define the format of the callto links in the portal and set the Asterisk Integration application to process these links.

### 1.  Define callto link format

Path to settings: CRM → Settings → Other → Other settings → Formatting (see figure).

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FMSYa2qnbrIMUl3bJOIb4%2FotherSettings.jpg?alt=media&#x26;token=88d57fa5-13e2-49b1-a6e7-998dea8f6001" alt=""><figcaption><p>Path to settings: CRM → Settings → Other → Other settings → Formatting (see figure).</p></figcaption></figure>

There, for the "callto" link output format, select "Call via Bitrix24 telephony"

### 2. Set default app for outgoing calls

Telephony → Telephony settings → General settings (see figure)

In the field “Number for outgoing calls by default” select the item: “Application: Integration with Asterisk”.

If the application is not in the list, then most likely the connection with the server part has not been established: either the module is not running, or the module has not been authorized in the portal and needs to be checked through the admin panel.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FbVM9XLOmh4pIxUI17Y91%2FdefaultCallApp.jpg?alt=media&#x26;token=b8e4c503-afd4-4e1a-927b-e3c08e24ae75" alt=""><figcaption><p>In the field “Number for outgoing calls by default” select the item: “Application: Integration with Asterisk”.</p></figcaption></figure>

### 4. Setting up Bitrix24 user profiles

For the module to work correctly, users must have an internal phone number on the portal. Internal phone number from user profile will be used to determine whom to show the card and whom to assign as responsible for lead or contact.

{% hint style="info" %}
Important: If the user does not have an internal number, then calls and leads of this user will not be sent to the portal
{% endhint %}

**The first quick** way to specify extension numbers is through the list of telephony users:

**Telephony → Telephony settings → Telephony users.**

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FMUOEiY5wfDHBIflCQUnM%2FinnerPhones.jpg?alt=media&#x26;token=3224f429-e5b0-449c-a618-3c523cb19c76" alt=""><figcaption><p><strong>Telephony → Telephony settings → Telephony users.</strong></p></figcaption></figure>

The user only needs to specify an extension number. The application is used by default. Leave the phone unconnected.

**The second way** is to add an extension number directly through the employee profile.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FQeExDHpVql229SmMj3XU%2FprofileInnerPhone.jpg?alt=media&#x26;token=5eac23b0-9436-44dc-bad9-78ffa94ffa59" alt=""><figcaption><p><strong>The second way</strong> is to add an extension number directly through the employee profile.</p></figcaption></figure>

{% hint style="info" %}
Important: If you use the FollowMe function (transferring an incoming call to a cell phone), then this cell phone must be specified in the profile.
{% endhint %}

### 5. Features of setting up click-to-call in the boxed version of 1C-Bitrix24 in a closed network

To be able to make calls (click-to-call) from the boxed version of Bitrix24 in a closed network, you need to make changes to the file

/home/bitrix/www/bitrix/php\_interface/dbconn.php`,`

which can be found through the 1C-Bitrix24 administrative interface in the section&#x20;

**Content → Site structure → Files and folders → bitrix → php\_interface → dbconn.php**

Add the following code to the file:

{% code overflow="wrap" %}

```
if($_REQUEST['COMMAND'] === 'startCallViaRest' || $_SERVER['REQUEST_URI'] === '/rest/voximplant.call.startViaRest.json') {define('BITRIXREST_URL', '<Asterisk IP>:8077');}
```

{% endcode %}

where instead of :8077 enter the internal address of your server with the integration module installed.

{% hint style="warning" %}
If you do not use the code above, then the Asterisk server should allow incoming requests from the address <https://oauth.bitrix.info>
{% endhint %}
