# Outgoing with internal number dialing

Let's say there is a certain number **+371 (2) 637‑23‑33**, by calling to which and dialing an extension you can get to a specific employee. This can be extremely convenient, especially if the extension number is longer than 3 characters. Next, we describe an example of the implementation of the task.

1. To solve the problem, additional contexts should be described through the [Customization of System Files](https://docs.mikopbx.com/mikopbx/english/manual/system/custom-files) menu.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2Fn06cIfMIqk6wJhcxD3gW%2FSystemFileCustomization.png?alt=media&#x26;token=4edfbfbf-6903-46c5-b1b5-d2a62131f59e" alt=""><figcaption><p>System file customization </p></figcaption></figure>

2. We will edit the **extensions.conf** file.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FNuELWVzuFh5rThr08jvu%2FEditExtensions.conf.png?alt=media&#x26;token=567dc075-00ed-45a7-bc10-915ccc1dc97f" alt=""><figcaption><p>Extensions.conf</p></figcaption></figure>

3. Add the following text to the end of the file:

```php
[z-outgoing]
exten => _X!,1,Ringing()
  same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)
  same => n,Dial(PJSIP/${EXTEN}@${ZPROVIDERID},600,${DOPTIONS}TKU(z-dial-answer)b(dial_create_chan,s,1))
  same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))
  same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})
  same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))
  same => n,Hangup()

[z-dial-answer]
exten => s,1,NoOp(Answered send DTMF...)
  same => n,Gosub(dial_answer,${EXTEN},1)
  same => n,SendDTMF(${ZDTMF})
  same => n,return
```

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2F0108yDq0jzytZ7ZXcEeF%2FCodeForExtensions.png?alt=media&#x26;token=9c5d69c2-8705-4c3e-98d7-226a9243841f" alt=""><figcaption><p>Code for extensions,conf</p></figcaption></figure>

4. Next, it is necessary to describe the [Applications of dialplans](https://docs.mikopbx.com/mikopbx/english/manual/modules/dialplan-applications)

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FS6mZS39XCPs3O2iIsUi2%2FNewDialplan.png?alt=media&#x26;token=0b3add55-158e-4821-bb01-d894d59cf0e7" alt=""><figcaption><p>New dialplan</p></figcaption></figure>

5. Select "**Type of code**" - "**Asterisk Dialplan**"

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2F2uh3jDFOIzCCD7xxPjNV%2FtypeOfCodeAsterisk.png?alt=media&#x26;token=716b87d3-a802-4e81-a426-a580c52a0968" alt=""><figcaption><p>Type of code for dialplan</p></figcaption></figure>

6. Let's say you need to "dial" the number 3542331, set this value to "**Number to call the application"**

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FVINOSdCaVrZ2Bgb2jvnJ%2FnumberForDialplan.png?alt=media&#x26;token=bc5c8fc6-ce2e-416d-92d1-bd9382197280" alt=""><figcaption><p>Number to call the application</p></figcaption></figure>

7. Go to the "**Programme Code**" tab and insert the template:

```php
1,Set(_ZDTMF=${EXTEN})
n,Set(_ZDST=37126372333)
n,Set(_ZPROVIDERID=SIP-1601534775)
n,Goto(z-outgoing,${ZDST},1)
```

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FtJFXDNv1vxBwDrHZ3ZqY%2FcodeForDialplan.png?alt=media&#x26;token=03448fdf-c2a5-4ece-a06b-3f13cf6011e8" alt=""><figcaption><p>Code for dialplan</p></figcaption></figure>

* If you specify the **9XXXX** template in the "**Application call number**" field, it will be possible to "dial" any five-digit numbers starting with the digit "**9**"&#x20;
* In the application, assign the variable "ZDST" the number to which the call should be made In the "**ZDTMF**" variable, specify the number for the additional set&#x20;
* In the "**ZPROVIDERID**" variable, specify the ID of the provider through which the outgoing call should be made. ID can be peeped in the browser address bar when editing the provider
