Play recording when dialing SOME outbound numbers

I have a strange problem/requirement.

My client had 3 digit internal extensions due to a historical mistake. When the PBX blew up we decided the time was right to switch to 4 digit extensions.

The reason 3 digit extensions (at least as they set them up) was a historical mistake is here in Israel there are a slew of 3 digit numbers you can dial INCLUDING emergency services (100 is Police, 101 is ambulance, 102 is Fire etc). They were using ALL of these extensions internally.

Therefore switching to 4 digits made perfect sense. BUT finger memory is powerul and people keep on calling emergency numbers by accident that now work AS expected (you used to need to dial 9 to dial any of those numbers).

I would like to setup a recording when you dial a 3 digit 1xx number. The recording will say something like the number you have dialed is an emergency number, If this is your intention please stay on the line, if you meant to dial an internal extension please hang up and dial the new 4 digit extension.

Obviously if say the user dialed 101 after say 3 seconds it should then connect them to 101 or they can hang up (most likely scenario).

Is there any way to accomplish this?

Not too hard with custom code. You would need to a Misc Application with a Dial String of “_1XX” that goes to an Announcement. From there to a Custom Destination that references your dialplan that inserts a Wait then does a Goto for the outbound dial. The hard part is the Goto pararms which would be:

Goto(outbound-allroutes,${CALLERID(dnid)},1)

Not overly difficult, something we can assist with in Support if you need it.

dt;sw - didn’t test; should work

1 Like

FreePBX doesn’t let you do this out of the box yet (as of Aug 2017) but you can write a TINY bit of custom code and make this work.

This isn’t limited to emergency messages, you could have this on any outbound route you want a pre-recorded message to be played prior to the trunk being utilized.

Here’s what i did
A> Made an outbound route in FreePBX that have the emergency numbers that one would dial.

B> Created a custom recording in the FreePBX with a quick message along the lines of “You are being connected to an emergency number”

C> Modified the Outbound route to include the playback of this message in the FreePBX dialplan

D> DONE.

##DETAIL INSTRUCTIONS

== Test this with non-emergency numbers. Dont mess with emergency personelle. In my example i pointed it to some dummy extension numbers.

1> Created an outbound route in FreePBX, call it “emergencyroute”. The dialplan would have the 3 digit number that are for emergency in your country, and point it to the trunk that emergency calls would go through.

2> In FreePBX -> SYSTEM RECORDINGS, create the recording that you would want to be played to callers who dial this number “You are being connected to an emergency number”. Make it short, you don’t want this to be very long. I named mine “emergency-message”.

3> Now you want to edit your asterisk dialplan.

open up the file /etc/asterisk/extensions_additional.conf

Find your outbound route in this dialplan. Below is an EXAMPLE of what mine looked like. Yours will be similar, but the

"[OUTRT-XX] will be different as will some of the phone numbers.

My example shows the numbers 77100 and 77101 being used as my test numbers

------ example ---------------

[outrt-27] ; emergencyroute
include => outrt-27-custom
exten => 77100,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => 77100,n,Gosub(sub-record-check,s,1(out,${EXTEN},dontcare))
exten => 77100,n,ExecIf($[ “${CALLEE_ACCOUNCODE}” != “” ] ?Set(CDR(accountcode)=${CALLEE_ACCOUNCODE}))
exten => 77100,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => 77100,n,Set(_NODEST=)
exten => 77100,n,Macro(dialout-trunk,1,${EXTEN:2},on)
exten => 77100,n,Macro(outisbusy,)

exten => 77101,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => 77101,n,Gosub(sub-record-check,s,1(out,${EXTEN},dontcare))
exten => 77101,n,ExecIf($[ “${CALLEE_ACCOUNCODE}” != “” ] ?Set(CDR(accountcode)=${CALLEE_ACCOUNCODE}))
exten => 77101,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => 77101,n,Set(_NODEST=)
exten => 77101,n,Macro(dialout-trunk,1,${EXTEN:2},on)
exten => 77101,n,Macro(outisbusy,)

;–== end of [outrt-27] ==–;

----- END EXAMPLE ---------------

4> SELECT and COPY the code from your dialplan. Make sure you copy the entire section of code for that context.

5> OPEN /etc/asterisk/extensions_override_freepbx.conf
(if anyone uses FOP2, you may need to put this in /etc/asterisk/extensions_override_fop2.conf instead)

PASTE the code into the bottom of this file.

6> Now you want to make a small edit to this file.
In my dialplan, I have 2 test numbers. You will need to insert a custom code in to each number you have in this route to play the recorded message.

After the first line of the two phone emergency numbers i added in the following:
exten => XXXXXX,n,Playback(./custom/emergency-message)

You must make sure your XXXXX value matches your current dialplan.
Also you recording name (no file extensions) would be inserted here.

exten => 77100,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => 77100,n,Playback(./custom/emergency-message) ;insert this line to play your message
exten => 77100,n,Gosub(sub-record-check,s,1(out,${EXTEN},dontcare))

exten => 77101,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => 77101,n,Playback(./custom/emergency-message) ;insert this line to play your message
exten => 77101,n,Gosub(sub-record-check,s,1(out,${EXTEN},dontcare))

In my two instances, my emergency numbers were 77100 and 77101 so i made sure that the code matches

Save your changes

7> reload the config in asterisk CLI ( asterisk -cvvr then core reload)

TEST!

What will happen is, when asterisk goes to dial the code, it will run this custom code, play the message then continue the dialing.

If you put it in override, future changes to FreePBX wont’ over ride this module.

##PLEASE NOTE!
####That if you make changes to the numbers contained in this outbound route, you absolutely have to remember to manually update the custom code. Meaning, if you have configured 3 numbers, then you do the above work and remove or add another number, you MUST repeat the above steps, first removing the custom code and replacing it with the one FreePBX generates. The custom override code will supersede and negate any changes you do in FreePBX for that route. This is very important.