Help with custom dial plan for internal ring tone

Arch = x86_64
OS = CentOS-6.4 (freepbx)
Asterisk = 11.4.0
FreePBX = 2.11.0.2

I am trying to implement a distinctive ringtone for internal calls and I am following the guide provided below.

http://www.freepbx.org/support/documentation/howtos/how-to-enable-distinctive-ringing-alert-info-for-calls-from-particular-

The code of interest is this:

ALERTINTEXT => alert-internal ;You can use the following comparison operators in these lines: = != < > <= >= ;To use pattern matching preface the target extension values with _ exten => _417XX,1,GotoIf($["${CALLERID(num)}" > 41799]?notfromlocal) exten => _417XX,n,GotoIf($["${CALLERID(num)}" < 41700]?notfromlocal) ;If we reach here then the caller is within the upper and lower bounds exten => _417XX,n,Set(__ALERT_INFO=${ALERTINTEXT}) exten => _417XX,n(notfromlocal),Goto(from-internal-original,${EXTEN},1) ;The following three lines must not be changed! exten => _.,1,Goto(from-internal-original,${EXTEN},1) exten => s,1,Goto(from-internal-original,s,1) exten => h,1,Macro(hangupcall)

This does not seem to work in Asterisk 11. When I put this code in /etc/asterisk/extensions_override_freepbx.conf, modified for my own situation, I see this when an extension is called internally.

-- Executing [41712@from-internal:1] GotoIf("SIP/41714-00000003", "0?notfromlocal") in new stack -- Executing [41712@from-internal:2] GotoIf("SIP/41714-00000003", "1?notfromlocal") in new stack -- Goto (from-internal,41712,4) -- Executing [41712@from-internal:4] Goto("SIP/41714-00000003", "from-internal-original,41712,1") in new stack -- Goto (from-internal-original,41712,1) -- Executing [41712@from-internal-original:1] Set("SIP/41714-00000003", "__RINGTIMER=20") in new stack -- Executing [41712@from-internal-original:2] Macro("SIP/41714-00000003", "exten-vm,41712,41712,0,0,0") in new stack

Now, I have zero experience programming asterisk configs however, it seems to me that:

-- Executing [41712@from-internal:1] GotoIf("SIP/41714-00000003", "0?notfromlocal") in new stack

is this line:

exten => _417XX,1,GotoIf($["${CALLERID(num)}" > 41799]?notfromlocal)

and

-- Executing [41712@from-internal:2] GotoIf("SIP/41714-00000003", "1?notfromlocal") in new stack -- Goto (from-internal,41712,4)

is this line

exten => _417XX,n,GotoIf($["${CALLERID(num)}" < 41700]?notfromlocal)

And it appears that this

-- Executing [41712@from-internal:4] Goto("SIP/41714-00000003", "from-internal-original,41712,1") in new stack

is this line:

exten => _417XX,n(notfromlocal),Goto(from-internal-original,${EXTEN},1)

it is readily apparent that “SIP/41714-00000003” is not comparing well with either 41700 or 41799 and so we branching to this line:

exten => _417XX,n(notfromlocal),Goto(from-internal-original,${EXTEN},1)

The questions are: How should I construct the comparison values to work in this situation. How much of “SIP/41714-00000003” changes besides the extension number?

Why don’t you just set the alert-info field in the extension or inbound route modules of FreePBX

Because when I googled how to do this what came up was a number of variants of what I refer to above. The general sense of the accompanying discussions was that there was no other way. Given my ignorance of how dial plans work I was not in a position to argue the point.

The incoming route module provides an alert-info field, but I could never find the exact string that would make our snom870 phones ring with the Ringer tone selected so I inferred that I was missing some critical bit of information to make proper use of the snom user guide information. I tried ‘Ringer3’, ‘http:/127.0.0.1/Ringer3’, ‘http://127.0.0.1/?info=alert-internal’ but nothing made any difference, the phones all used Ringer1 for everything no matter what I did. I set the alert_info_ring_sound to Ringer3 in the snom template basefile and then tried alert-internal but that did not work for me either. It is entirely probable that some of the things I did should work and that I was encountering different sorts of errors along the way, but the end result is that I cannot get internal calls to use a different ring tone.

I cannot find anywhere in the device or user applications in FreePBX that provides an alert-info field input box and nothing I have encountered with respect to this field is evidently tied to internal ringing. If you could point me to somewhere that explains this I would be most grateful.

We went live on FreePBX/Asterisk this past Monday and we removed the old phone system yesterday (Thursday). Everything is running well. Our users would like a distinctive ring for internal transfers but this is a nice-to-have rather than a necessity.

With some kind help from the Asterisk mailing list I eventually got this sorted out. I made so many changes in the course of resolving this that I cannot be sure what my original error or difficulty was (ignorance of AEL2 syntax mostly). However, I rather suspect that this was the culprit:

exten => _417XX,1,GotoIf($["${CALLERID(num)}" > 41799]?notfromlocal) exten => _417XX,n,GotoIf($["${CALLERID(num)}" < 41700]?notfromlocal)

Because the values 41799 and 41700 are not enclosed in quotes but should be.

What follows is what I eventually came up with and it works for us.

An important note; the alter-info strings used below work with Snom firmware 8.7.3 but may not for earlier or later versions and certainly not for phones of any other manufacture. I say this because experience has shown that even the Snom documentation respecting alert-info headers is not entirely correct. Specifically, the information that says one can use “http://127.0.0.1/Ringer[0-9]” as an alert-info string to select a specific ringer from the 9 built into Snom phones I could never get to work.

I am excessively wordy in the comments but I am unlikely to develop any great familiarity with AEL2 and so must record in situ what little knowledge I currently possess against future need when doing maintenance.

cat /etc/asterisk/extensions_override_freepbx.conf

;See URL:http://www.freepbx.org/support/documentation/howtos/how-to-enable-distinctive-ringing-alert-info-for-calls-from-particular-

[from-internal]
include => set-alert-if-local

[from-internal-original]
include => from-internal-xfer
include => bad-number

[set-alert-if-local]
;Note that letter-case is NOT significant in user defined variables
; ${foo} == ${F00} == ${FOO}
; However, Asterisk defined variables are letter-case sensitive
; ${EXTEN} works whereas ${exten} does not work.
;
;Also note that referencing the value of a variable requires ${VARNAME}
;
;Finally note that variables do not have a type. If a string is enclosed
; in “” when assigned then the “” become part of the variable’s value.
; i.o.w. v=“myvalue” ; v != myvalue (true) ; v = “myvalue” (true)

;To use pattern matching preface the target extension values with ‘_’.
;
; This is a convenient Noop to set the initial priority to one so that
; the rest of the plan can use ‘n’ for priority auto-assignment.
exten => _417XX,1,Noop(CALLERIDNUM=${CALLERID(num)})

;This is the text string to send to the phone to trigger a
; distinctive ring. Check the phone manufacturer’s api for recognized values.
; Bellcore-r[1-4] or Bellcore-dr[1-4] should work in most cases.
; However, Snom phones provide for an alert-text which is related
; to the actual telephone ringer assignment at the phone. This
; relationship between the ring-tone and alert-text must be set in
; the provisioning files or manually on the phones themselves.

; These strings are specific to phones using Snom 8.6+ firmware.
exten => _417XX,n,Set(AlertSnom=http://www.notused.com;info=)

; alert-external, alert-group and alert-internal are Snom predefined values.
exten => _417XX,n,Set(AlertExternalCall=alert-external)

; alert_internal and alert_internal_transfer are customized alert-info-text
; values related to specific alert-info-files (Ringer[0-9]) and set in
’ phone provisioning files. (pay attention to - vice _ in strings)
exten => _417XX,n,Set(AlertInternalCall=alert_internal_call)
exten => _417XX,n,Set(AlertInternalTransfer=alert_internal_transfer)

; You can use the following comparison operators in these lines:
; = != < > <= >=
; Note that “” surround both the items in the comparison and are
; considered part of both the values compared. If either (|) condition
; is true then we branch to notfromlocal. Otherwise we fall through.
; A GOTO !!! Oh the memories. . .
exten => _417XX,n,GotoIf(
$[$[“${CALLERID(num)}” > “41799”] |
$[“${CALLERID(num)}” < “41700”]]?notfromlocal:)

; If we reach here then the caller is within the upper and lower bounds
; so we set the alert-info header to our custom ring-tone
exten => _417XX,n,Set(__ALERT_INFO=${AlertSnom}${AlertInternalCall})

;This is the (notfromlocal) entry point.
exten => _417XX,n(notfromlocal),Goto(from-internal-original,${EXTEN},1)

;The following three lines must not be changed!
exten => _.,1,Goto(from-internal-original,${EXTEN},1)
exten => s,1,Goto(from-internal-original,s,1)
exten => h,1,Macro(hangupcall)

I don’t have a Snom locally to play with but if you look in the basefile edit in the Commercial EPM you have two settings:

alert_external_ring_sound

and

alert_internal_ring_sound

both are set to Ringer1 by default, did you try changing one of them to Ringer3?

Setting this to any value in the snom basefile does indeed reconfigure the phone to use that value to select the ring-tone. However, no dial plan is generated to make use of it as far as I could determine. So one is still left with writing custom code either in extensions_override_freepbx.conf or in extensions_custom.conf.

I just decided that it would be cleaner and provide more flexibility if I used my own custom info strings instead of depending on those implemented by a particular manufacturer.