# Itgrix for Kommo and Asterisk

The integration module has two components: a CRM application installed on the Kommo portal and a server-side application for Asterisk server.

{% embed url="<https://youtu.be/KfCxQcz9XtE>" %}

## 1. Installing a CRM application in Kommo

The installation should be done using an account with Administrator rights.

This step is mandatory for the proper functioning of the application.

Go to the Settings section in Kommo.

In the search bar, type in "**Itgrix**" or "Asterisk". Select the application "**Asterisk connector Itgrix**".

Alternatively, use this link: [https://company.kommo.com/settings/widgets#amo\_itgrix](https://company.amocrm.ru/settings/widgets#amo_itgrix) and replace "company.kommo.com" with the name of your Kommo account.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2Fj1gBx2rMTrfFVtV1DnJM%2Fkommo_vidget.jpg?alt=media&#x26;token=943509af-3e84-4c1f-bdf8-eda2af72c4a0" alt=""><figcaption></figcaption></figure>

Accept the Privacy Policy and install the application.

## 2. Setting up the click-to-call function and displaying call cards

Select "Use Click-to-Call server", or specify the IP address of the server with the module in order to receive click-to-call requests from CRM.

Choose whether to show the call card. [see description](https://docs.itgrix.com/setup/itgrix-setup-kommo-asterisk/call-card)

{% hint style="info" %}
To enable the call card, you need to tick the "Show call card" checkbox in the widget settings, configure and enable users to connect to the integration module using the WSS protocol.
{% endhint %}

**Remember to save your changes before closing the widget settings page.**

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FM7c49PoG868fQ0nPr6Xv%2FamoVidget.jpg?alt=media&#x26;token=21d81292-4161-44fc-9b1c-99430aa53b6f" alt=""><figcaption></figcaption></figure>

**Important: If you opt out of using the Click-to-Call server, you need to specify the external address of your network and forward port 8077 to the server where the server-side part of the connector is installed.**

{% hint style="warning" %}
**When using the C2C server, its address <https://apix.itgrix.ru> must be accessible from the server with the module.**
{% endhint %}

## 3. Installing the module on the server

#### 3.1 Installation

Use the automatic installation script.

Download the script from the link:

```
wget https://itgrix.ru/download/autoinstaller_kmo.sh
```

Run the script

```
bash autoinstaller_kmo.sh
```

At the conclusion of the installation, **set login/password** to enter the module's admin panel. In the future, these credentials can be changed at the bottom of the config file at */etc/itgrix\_kmo/config.json* in the "server" section.

#### 3.2 Launch the service

If the systemctl service is installed in the operating system, then the **module will start automatically**, or it can started **manually** using the following commands:

```
service itgrix_kmo start
service itgrix_kmo status
```

#### 3.3 Setting up the integration module

We recommend further configuration through the configuration wizard in the Admin panel of the module (the web interface is available at `http://<Asterisk IP>:8077/config/master`).

## 4. Setup wizard steps:

#### 1. Connection to the Database

The setup wizard will automatically configure access to the Asterisk database. The availability of tables CEL, CDR, and the latest entries in them will also be checked.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FeBRNdDMQ8yZwfUkZWzEn%2Fwizard_db.jpg?alt=media&#x26;token=45c5cc9e-1c8a-4dbf-9234-c836ec3df04a" alt=""><figcaption></figcaption></figure>

If the database connection credentials were not found automatically, they can be found as follows:

In the files */etc/asterisk/res\_odbc.conf* or */etc/asterisk/res\_odbc\_additional.conf* find a block:

```
[asteriskcdrdb]
username=>freepbxuser
password=>mysqlsecret
```

You can also create a separate user in MySQL with permissions to read tables with CDR and CEL data.

#### 2. Connection to Asterisk

Select an existing user or create a new one on behalf of which the module will send commands to the Asterisk AMI interface.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2F1171JuTuvXBYxD5q1cbn%2Fwizard_asterisk.jpg?alt=media&#x26;token=94690f2e-0d69-4a28-a99b-3cd4138e64e8" alt=""><figcaption></figcaption></figure>

If the module is not hosted directly on the Asterisk server, then you need to create a user manually:

1. make changes to the /etc/asterisk/manager\_custom.conf file (if not present, edit the /etc/asterisk/manager.conf file instead):

```
[kmo]
secret = asterisksecret (specify your own)
deny = 0.0.0.0/0.0.0.0
permit = 127.0.0.1/255.255.255.0
read = cdr,reporting,originate,call
write = reporting,originate
```

2. After adding a new user, you need to reload Asterisk to load new data with the command `asterisk -rx 'manager reload'`

#### 3. Recording files storage method

Specify the path to call recording files. Usually they are located at

`/var/spool/asterisk/monitor`

Choose how the directory structure is organized. For FreePBX, by default, directories are organized into Year/Month/Day subfolders.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2F6H4LAoNc7zYN02pYLWnD%2Fwizard_call_record.jpg?alt=media&#x26;token=efac5e28-cfed-45a1-a30d-faf8516492c0" alt=""><figcaption></figcaption></figure>

#### 4. Connecting to Kommo

Enter the portal address here by simply copying it from the address bar.

Click "Authenticate".

In the window that opens, log in to your CRM and confirm access permissions.

If any network connectivity issues prevent the authentication procedure from completing normally, you may be given an authenticaction code. Copy this code into the field in the admin panel and confirm.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FpAmrSdCpbeZnz0qnenot%2Fwizard_auth_kommo.jpg?alt=media&#x26;token=4c5b1d3e-e4dd-4945-8fff-cb8fbe973aa5" alt=""><figcaption></figcaption></figure>

#### 5. Finalizing initial setup

Complete the setup by clicking the "Finish" button at the end of the page and you will be automatically taken to the Business Logic page.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2F7dI8IpjQmJqvZnqo68DW%2Fwizard_finish.jpg?alt=media&#x26;token=2f0ca5e2-75f3-46ae-b567-c4a4be51c9a4" alt=""><figcaption></figcaption></figure>

## 5. Business-logic

If all previous steps are completed successfully, you will be redirected to the Business Logic settings section:

`http://<Asterisk IP>:8077/config/business_logic`,

where \<Asterisk IP> is the address of the Asterisk server on which the integration module is installed.

Set up the logic of the connector.

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2Fk8RE9seFbo7XMpvZslDE%2Fbusiness_logic.jpg?alt=media&#x26;token=501e9463-9350-4a62-bf4a-e4d382ad067c" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Be sure to specify the mapping of the internal numbers from telephony to users in CRM.

If a user has multiple internal numbers or has configured call redirection to a cell phone, to ensure correct logging of calls to additional numbers, all their phone numbers must be added in the admin panel or the settings config file:

```json
"kommo": {
    "users": {
        "101": "user_id_1",
        "102": "user_id_1",
        "14844731331": "user_id_1"
    }
}
```

{% endhint %}

{% hint style="warning" %}
To save the settings, click the “Save” button at the bottom of each modified page.
{% endhint %}

## 6. Configuring HTTPS links for listening to call recordings

In the admin panel, go to **Settings - Connector**

<figure><img src="https://1054546226-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M-rzZJr51tgvX7eVK8M%2Fuploads%2FuwUd33nXlkSu5b4Jn8q5%2FkommoHttpsport.png?alt=media&#x26;token=aedc9ad1-2534-4f20-a849-7ecebf1daa3a" alt=""><figcaption></figcaption></figure>

1. You need to **enable** the “Use HTTPS port” option.
2. The default port is 8078 (this can be changed). To make the entries accessible from outside the network, port **8078** **must be opened** for Asterisk.
3. **Add the path** to the certificate and key. These are usually located at `/etc/asterisk/keys/`. You will need the paths to the `<your domain>.pem` and `<your domain>.key` files. The easiest way to obtain a certificate is through the [Let's Encrypt service](https://letsencrypt.org/).
4. Save settings.

{% hint style="success" %}
Installation completed!
{% endhint %}
