# Call Monitoring (ChanSpy)

## Creating a dialplan

1. Go to the "**Modules**" - "**Dialplan Applications**". Create a new dialplan.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FNrOZjBErG4lnGPyR87Uu%2FNEWDialplan.png?alt=media&#x26;token=9dff900f-c127-4426-96c5-69abe9d4e74e" alt=""><figcaption><p>New Dialplan app</p></figcaption></figure>

2. Enter the name "Eavesdropping". Specify the "number to call the application", here we will use the template "911XXX" - XXX means all **three-digit** numeric numbers. In the "**Type of code**" field, specify "**Dialplan Asterisk**"

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FOJ15IwQHECfvNHTEYVYv%2FDataInDialplan.png?alt=media&#x26;token=b4c4716c-6fce-4bbf-a1e6-47f83e75e901" alt=""><figcaption><p>Template of parameters for dialplan</p></figcaption></figure>

## Templates

Further functionality you can choose from three options:

### 1. Eavesdrop on a conversation

It becomes possible to eavesdrop on someone else's conversation, so that neither the operator nor the client will suspect anything

In the tab "**Programme code**" insert the following code:

```php
1,Answer()
n,ChanSpy(${CHANNEL(channeltype)}/${EXTEN:3},qw)
n(hangup),Hangup();
```

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FFrpM7379GEV64EEsCQvN%2FfirstTemplate.png?alt=media&#x26;token=bb748f12-8b78-4161-8610-ab4d50be8fc2" alt=""><figcaption><p>The first implementation option</p></figcaption></figure>

{% hint style="info" %}
**ChanSpy(SIP/${EXTEN:3},qw)** - note that the application number will be passed as EXTEN. If you dial 911101, the internal number 101 will be dialed. The first three digits are cut off.&#x20;

If you change the length of the template, then you should adjust this line.&#x20;

When using PJSIP, the command will look like **ChanSpy(PJSIP/${EXTEN:3},qw)**
{% endhint %}

### 2. To intervene in the conversation

In the tab "**Programme code**" insert the following code:

```php
1,Answer()
n,ChanSpy(${CHANNEL(channeltype)}/${EXTEN:3},qBx)
n(hangup),Hangup();
```

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FgEuZMRH70ZloB1UfZ8WK%2FsecondTemplate.png?alt=media&#x26;token=0ca223cd-a30c-4b75-b708-bf042a8a2d63" alt=""><figcaption><p>The second implementation option</p></figcaption></figure>

{% hint style="info" %}
The differences are only in the parameters for **ChanSpy**
{% endhint %}

### 3. "Whisper'' to a colleague

In the tab "**Programme code**" insert the following code:

```php
1,Answer()
n,ChanSpy(${CHANNEL(channeltype)}/${EXTEN:3},wvq(4)x)
n(hangup),Hangup();
```

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FNzLfxL2A9tcFWNB5eLHX%2FtrirdTemplate.png?alt=media&#x26;token=49c0a17f-e29e-4509-b32d-905105e94ad7" alt=""><figcaption><p>The third implementation option</p></figcaption></figure>

{% hint style="info" %}
The differences are only in the parameters for **ChanSpy**
{% endhint %}
