Alert when emergency number is dialled

Hi all

I currently have a need for our system to send an email when particular numbers are dialled.

I am trying to get the below code to work but can’t get it to match. I need to match if someone dials 999, 9999, 911, 9911, 112 or 9112

Can anyone advise on what I have to change for it to check the above numbers?

[macro-dialout-predial-hook]
exten => s,1,GotoIf($["${OUTNUM}" = “999”]?email:noemail)
exten => s,n(email),System(echo “Message body!” | mail -s “Message subject” [email protected])
exten => s,n(noemail),MacroExit()

Thanks

I have just realised I have the macro defined earlier in the file however this was put in to get a2billing to work.

I’m not sure how to add my original code with this as I’m not 100% what the A2billing code is actually doing?

[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${OUT_${DIAL_TRUNK}:4:4}" = “A2B/”]?custom-freepbx-a2billing,${OUTNUM},1:2)
exten => s,2,MacroExit

Would this work?

[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${OUT_${DIAL_TRUNK}:4:4}" = “A2B/”]?custom-freepbx-a2billing,${OUTNUM},1:2)
exten => s,2,GotoIf($["${OUTNUM}" = “999”]?email:noemail)
exten => s,3(email),System(echo “Message body!” | mail -s “Message subject” [email protected])
exten => s,4(noemail),MacroExit()

Small note… if you mark your outbound route as an “Emergency Route” you can

exten => s,2,GotoIf($["${EMERGENCYROUTE}" = "YES"]?email:noemail)

Also if 1 matches you will never reach 2

I am trying the below but finding that the first line in the macro is no longer being activated.

WHat happens with the A2B is that a trunk is setup that has a custom dial string of A2B/ and a number at the end which corresponds with the conf file in the billing. Normal setup is

[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${OUT_${DIAL_TRUNK}:4:4}" = “A2B/”]?custom-freepbx-a2billing,${OUTNUM},1:2)
exten => s,2,MacroExit

This works fine, I can see the macro running and the custom-freepbx line in the logs. If a call goes through a trunk with A2B defined it passes it through the billing.

The numbers I am trying to match are in their own emergency outbound route using a trunk that does not go near the billing so I would have thought the below would have worked as I assume that with 1:2 a the end means it jumps to 2 if it can’t find A2B/

This doesnt seem to be the case. When running the below it exist the macro without doing anything, it doesn’t run the first line.

[macro-dialout-predial-hook]
exten => s,1,GotoIf($["${OUT_${DIAL_TRUNK}:4:4}" = “A2B/”]?custom-freepbx-a2billing,${OUTNUM},1:2)
exten => s,2,GotoIf($["${EMERGENCYROUTE}" = “YES”]?email:noemail)
exten => s,3(email),System(/scripts/notifyemail.sh “${STRFTIME(,%c)}” “${CallerIDName}” “${AMPUSER}” “${OUTNUM}” ${EPOCH})
exten => s,4(noemail),MacroExit()