Call Forwarding
From Etel
Contents |
[edit]
Call Forward
Call Forward - CFW
[edit]
Problem
Provide a number in your dialplan, which can be dialed by any user to enable Call Forwarding. As with Do Not Disturb, also here i would recommend to use AstDB and a Macro to keep everything easier to maitain and understand.
As this Recipe is based on the CallerID(num) to store the CallForwardNumber on AstDB, just as an example we show your here a SIP account
[edit]
Solution
- sip.conf
[MoutaPT] type=friend secret=12345 qualify=no port=5060 nat=no host=dynamic dtmfmode=rfc2833 context=from-internal canreinvite=no callerid="MoutaPT"<2000> ; CallerID(name) and CallerID(number) that will be used later on in our dialplan
- extensions.conf
[macro-cfw-on]
;${ARG1} the number to dial on CFW
exten => s,1,GotoIf($[${CALLERID(num)}=${ARG1}]?invalid|1);Prevents call forward to your self, would take you into an Infinite Loop!
exten => s,n,Set(DB(CFW/${CALLERID(num)}=${ARG1})
exten => s,n,playback(call-forward)
exten => s,n,playback(is-set-to)
exten => s,n,saydigits(${ARG1})
exten => s,n,hangup
exten => invalid,1,Playback(invalid)
exten => invalid,n,hangup
exten => h,1,hangup
[macro-cfw-off]
exten => s,1,DBdel(CFW/${CALLERID(num)})
exten => s,n,playback(call-forward)
exten => s,n,playback(disabled)
exten => s,n,hangup
exten => h,1,hangup
;Users should dial 30*XXXXXXXX, where XXXXX is the number they want to set their Call Forwarding
;Users should dial 31 to Disable the CallForwarding
[internal-services]
exten => _30*.,1,Macro(cfw-on,${EXTEN:3})
exten => 31,1,Macro(cfw-off)
- Every time there is call to an extension on your PBX you need to check whether or not CFW is ON:
- Considering your internal extensions are SIP with pattern 2XXX
[from-internal]
exten => _2XXX,1,GotoIf(${DB_EXISTS(CFW/${EXTEN})}?CFW-ON,1);If entry exists on AstDB it means CFW is ON
exten => _2XXX,n,Dial(SIP/${EXTEN},20,t) ;
exten => _2XXX,n,hangup
exten => h,1,hangup
exten => CFW-ON,1,Set(cfwnumber=${DB(CFW/${MACRO_EXTEN})}) ; Retrieve from AstDB the number to forward the call
exten => CFW-ON,2,Goto(cfw-context,${cfwnumber},1) ; Inside cfw-context we could control and log the forward calls...
[edit]
Discussion
[edit]
See Also:
[edit]
Metadata
- By: Marco Mouta
- Outline reference (User Services - Call Forward); [1]
