Eric Wieling
2004-May-29 00:49 UTC
[Asterisk-Users] Example: Caller*ID Fixup Macro for use with DIDs
Here is a macro I wrote to deal with sites that have a mixture of extensions with DID numbers and extensions without DID numbers. This macro is USA/Canada specific but could be adapted for the dial plans in other countries. This macro uses features that are not in CVS -stable. You must use CVS -head for this macro to work. [default] exten => _91NXXNXXXXXX,1,Macro(callerid-fixup,5045551212) exten => _91NXXNXXXXXX,2,Dial(Zap/g1/${EXTEN:1}) exten => 2101,1,Macro(callerid-fixup) exten => 2101,2,Dial(SIP/2101) [macro-callerid-fixup] ; ; This macro assumes the following: ; Extensions without a DID number have a CallerID number that is 4 digits ; Extensions with a DID number have their CallerID number set to their 10 digit DID ; The last 4 digits of a DID number is the same as the extension number ; ; This macro does the following if it is called without any parameters: ; If the Caller*ID number is 4 digits, do nothing ; If the Caller*ID number is not 4 digits, strip off the first 6 digits ; ; This macro does the following if it is called with a parameter ; If the Caller*ID number is 4 digits, reset the Caller*ID number to be the value of the parameter ; If the Caller*ID number is not 4 digits, do nothing ; exten => s,1,NoOp(Entering Macro "callerid-fixup") exten => s,2,NoOp(Variable CALLERIDNUM is equal to ${CALLERIDNUM}) exten => s,3,GoToIf($["${ARG1}" != ""]?external,1) exten => s,4,GoToIf($["${ARG1}" = ""]?internal,1) exten => internal,1,GoToIf($[${LEN(${CALLERIDNUM})} = 4]?f,1) exten => internal,2,SetCIDNum(${CALLERIDNUM:6}) exten => internal,3,GoTo(f,1) exten => external,1,GoToIf($[${LEN(${CALLERIDNUM})} = 4]?f,1) exten => external,2,SetCIDNum(${ARG1},a) exten => external,3,GoTo(f,1) exten => f,1,NoOp(Variable CALLERIDNUM is equal to ${CALLERIDNUM}) exten => f,2,NoOp(Leaving Macro "callerid-fixup") -- Eric Wieling * BTEL Consulting * 504-899-1387 x2111 "In a related story, the IRS has recently ruled that the cost of Windows upgrades can NOT be deducted as a gambling loss."
Eric Wieling
2004-May-29 03:03 UTC
[Asterisk-Users] Example: Caller*ID Fixup Macro for use with DIDs
Fixed an error in the macro The line: exten => external,1,GoToIf($[${LEN(${CALLERIDNUM})} = 4]?f,1) should be changed to exten => external,1,GoToIf($[${LEN(${CALLERIDNUM})} != 4]?f,1) --Eric On Sat, 2004-05-29 at 02:49, Eric Wieling wrote:> Here is a macro I wrote to deal with sites that have a mixture of > extensions with DID numbers and extensions without DID numbers. This > macro is USA/Canada specific but could be adapted for the dial plans in > other countries. This macro uses features that are not in CVS -stable. > You must use CVS -head for this macro to work. > > [default] > exten => _91NXXNXXXXXX,1,Macro(callerid-fixup,5045551212) > exten => _91NXXNXXXXXX,2,Dial(Zap/g1/${EXTEN:1}) > > exten => 2101,1,Macro(callerid-fixup) > exten => 2101,2,Dial(SIP/2101) > > [macro-callerid-fixup] > ; > ; This macro assumes the following: > ; Extensions without a DID number have a CallerID number that is 4 digits > ; Extensions with a DID number have their CallerID number set to their 10 digit DID > ; The last 4 digits of a DID number is the same as the extension number > ; > ; This macro does the following if it is called without any parameters: > ; If the Caller*ID number is 4 digits, do nothing > ; If the Caller*ID number is not 4 digits, strip off the first 6 digits > ; > ; This macro does the following if it is called with a parameter > ; If the Caller*ID number is 4 digits, reset the Caller*ID number to be the value of the parameter > ; If the Caller*ID number is not 4 digits, do nothing > ; > exten => s,1,NoOp(Entering Macro "callerid-fixup") > exten => s,2,NoOp(Variable CALLERIDNUM is equal to ${CALLERIDNUM}) > exten => s,3,GoToIf($["${ARG1}" != ""]?external,1) > exten => s,4,GoToIf($["${ARG1}" = ""]?internal,1) > > exten => internal,1,GoToIf($[${LEN(${CALLERIDNUM})} = 4]?f,1) > exten => internal,2,SetCIDNum(${CALLERIDNUM:6}) > exten => internal,3,GoTo(f,1) > > exten => external,1,GoToIf($[${LEN(${CALLERIDNUM})} = 4]?f,1) > exten => external,2,SetCIDNum(${ARG1},a) > exten => external,3,GoTo(f,1) > > exten => f,1,NoOp(Variable CALLERIDNUM is equal to ${CALLERIDNUM}) > exten => f,2,NoOp(Leaving Macro "callerid-fixup")-- Eric Wieling * BTEL Consulting * 504-899-1387 x2111 "In a related story, the IRS has recently ruled that the cost of Windows upgrades can NOT be deducted as a gambling loss."