Matching dialled numbers help

Hi

I am trying to get my system to send an email when particular numbers are dialled however I can’t figure out how to get it to match properly

I am trying to get it to match 9999, 999, 911, 9911, 112 and 9112

exten => s,2,GotoIf($["${OUTNUM}" = “999”]?email:noemail)

I can get a single match to work but not sure how to get it to match the above

any help appreciated

thanks

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($["${OUTNUM}" = “123”]?email:)
exten => s,3,GotoIf($["${OUTNUM}" = “9123”]?email:)
exten => s,4,GotoIf($["${OUTNUM}" = “999”]?email:)
exten => s,5,GotoIf($["${OUTNUM}" = “9999”]?email:noemail)
exten => s,6(email),System(/scripts/notifyemail.sh “${STRFTIME(,%c)}” “${CallerIDName}” “${AMPUSER}” “${OUTNUM}” ${EPOCH})
exten => s,7(noemail),MacroExit()

You should be able to use the Regex function for this.

GotoIf($[${REGEX("^9999|^999|^911|^9911|^112|^9112" ${OUTNUM})]?email)

1 Like

On plain Asterisk, the easiest way of pattern matching dialled digits is to gosub into a custom context, using them as the extension, and use the extension matching logic. However, that may be incompatible with A2B.