Dear all,
Please, help me to solve this problem as I really don’t know how to solve it.
I created two dialplans for two different offices: account (extensions _1XX) and sales (extensions _2XX).
I want that all outgoing calls from both offices ( _X.) be redirected to another context, that is called “outgoing_calls_filter”, which should check if call was placed during working time and if it is an intern of outbound call.
As per bellow configuration is working perfectly. It can successfully detect if call was placed during working time (if not it drops the call) and if it is an inter or outbound call (applying different rules if was dialed a national or international call).
[account]
exten => 101,1,NoOp()
same => n,Dial(SIP/acc01,60,tT)
same => n,Playtones(congestion)
same => n,Hangup()
exten => 102,1,NoOp()
same => n,Dial(SIP/amm02,60,tT)
same => n,Playtones(congestion)
same => n,Hangup()
exten => _X.,1,NoOp()
same => n,GoTo(outgoing_calls_filter,${EXTEN},1)
same => n,Hangup()
[sales]
exten => 201,1,NoOp()
same => n,Dial(SIP/sal01,60,tT)
same => n,Playtones(congestion)
same => n,Hangup()
exten => 202,1,NoOp()
same => n,Dial(SIP/com02,60,tT)
same => n,Playtones(congestion)
same => n,Hangup()
exten => _X.,1,NoOp()
same => n,GoTo(outgoing_calls_filter,${EXTEN},1)
same => n,Hangup()
[outgoing_calls_filter]
exten => _1XX,1,Set(INTERN_ACCOUNT=1)
same => n,GoSub(outgoing_time_check,s,1)
same => n,GoToIf($[${INTERN_ACCOUNT}=1]?account,${EXTEN},1)
same => n,Hangup()
exten => _2XX,1,Set(INTERN_SALES=1)
same => n,GoSub(outgoing_time_check,s,1)
same => n,GoToIf($[${INTERN_SALES}=1]?sales,${EXTEN},1)
same => n,Hangup()
exten => _0X.,1,Set(NATIONAL=1)
same => n,GoSub(outgoing_time_check,s,1)
same => n,GoToIf($[${NATIONAL}=1]?outgoing,${EXTEN},1)
same => n,Hangup()
exten => _3X.,1,Set(NATIONAL_MOBILE=1)
same => n,GoSub(outgoing_time_check,s,1)
same => n,GoToIf($[${NATIONAL_MOBILE}=1]?outgoing,${EXTEN},1)
same => n,Hangup()
exten => _00X.,1,Set(INTERNATIONAL_00=1)
same => n,GoSub(outgoing_time_check,s,1)
same => n,GoSub(outgoing_simultaneous_calls_check,s,1)
same => n,GoToIf($[${INTERNATIONAL_00}=1]?outgoing,${EXTEN},1)
same => n,Hangup()
exten => _+X.,1,Set(INTERNATIONAL_+=1)
same => n,GoSub(outgoing_time_check,s,1)
same => n,GoSub(outgoing_simultaneous_calls_check,s,1)
same => n,GoToIf($[${INTERNATIONAL_+}=1]?outgoing,${EXTEN},1)
same => n,Hangup()
[outgoing_time_check]
exten => s,1,NoOp()
same => n,GoToIfTime(8:00-17:00,mon-fri,*,*?working_hours,1)
same => n,GoToIfTime(8:00-12:00,sat-sat,*,*?working_hours,1)
same => n,Playtones(no_working_hours)
same => n,Hangup()
exten => working_hours,1,NoOp()
same => n,Return
[outgoing_simultaneous_calls_check]
exten => s,1,NoOp()
same => n,Set(GROUP()=INTL_CALL)
same => n,GoToIf($[{GROUP_COUNT()}<3]?ok,1)
same => n,Playtones(over_the_limit_retry_later)
same => n,Hangup()
exten => ok,1,(NoOp()
same => n,Return
[outgoing]
exten => _X.,1,NoOp()
same => n,Dial(SIP/${EXTEN}@fritzboxbs)
same => n,Playtones(congestion)
same => n,Hangup()
The problem is when I (sal01 extension) dial an invalid extension. For example I dial extension 187 which does not exists (only 101 and 102 exists into the account context). The “outgoing_calls_filter” detects that dialed number 187 matches the _1XX pattern and so call is forwarded to the “account” context. Since there is no 187 extension, _X. catches the call and sends it back to the “outgoing_calls_filter” causing an infinite loop. In this scenario the asterisk CLI is flooded with following log and doesn’t stop since I hangup
== Using SIP RTP CoS mark 5
-- Executing [187@sales:1] NoOp("SIP/sal01-00000040", "") in new stack
-- Executing [187@sales:2] Goto("SIP/sal01-00000040", "outgoing_calls_filter,187,1") in new stack
-- Goto (outgoing_calls_filter,187,1)
-- Executing [187@outgoing_calls_filter:1] Set("SIP/sal01-00000040", "INTERN_ACCOUNT=1") in new stack
-- Executing [187@outgoing_calls_filter:2] Gosub("SIP/sal01-00000040", "outgoing_time_check,s,1") in new stack
-- Executing [s@outgoing_time_check:1] NoOp("SIP/sal01-00000040", "") in new stack
-- Executing [s@outgoing_time_check:2] GotoIfTime("SIP/sal01-00000040", "8:00-17:00,mon-fri,*,*?working_hours,1") in new stack
-- Goto (outgoing_time_check,working_hours,1)
-- Executing [working_hours@outgoing_time_check:1] NoOp("SIP/sal01-00000040", "orario di lavoro") in new stack
-- Executing [working_hours@outgoing_time_check:2] Return("SIP/sal01-00000040", "") in new stack
-- Executing [187@outgoing_calls_filter:3] GotoIf("SIP/sal01-00000040", "1?account,187,1") in new stack
-- Goto (account,187,1)
-- Executing [187@account:1] NoOp("SIP/sal01-00000040", "") in new stack
-- Executing [187@account:2] Goto("SIP/sal01-00000040", "outgoing_calls_filter,187,1") in new stack
-- Goto (outgoing_calls_filter,187,1)
-- Executing [187@outgoing_calls_filter:1] Set("SIP/sal01-00000040", "INTERN_ACCOUNT=1") in new stack
-- Executing [187@outgoing_calls_filter:2] Gosub("SIP/sal01-00000040", "outgoing_time_check,s,1") in new stack
-- Executing [s@outgoing_time_check:1] NoOp("SIP/sal01-00000040", "") in new stack
-- Executing [s@outgoing_time_check:2] GotoIfTime("SIP/sal01-00000040", "8:00-17:00,mon-fri,*,*?working_hours,1") in new stack
-- Goto (outgoing_time_check,working_hours,1)
-- Executing [working_hours@outgoing_time_check:1] NoOp("SIP/sal01-00000040", "orario di lavoro") in new stack
-- Executing [working_hours@outgoing_time_check:2] Return("SIP/sal01-00000040", "") in new stack
-- Executing [187@outgoing_calls_filter:3] GotoIf("SIP/sal01-00000040", "1?account,187,1") in new stack
-- Goto (account,187,1)
-- Executing [187@account:1] NoOp("SIP/sal01-00000040", "") in new stack
-- Executing [187@account:2] Goto("SIP/sal01-00000040", "outgoing_calls_filter,187,1") in new stack
-- Goto (outgoing_calls_filter,187,1)
-- Executing [187@outgoing_calls_filter:1] Set("SIP/sal01-00000040", "INTERN_ACCOUNT=1") in new stack
-- Executing [187@outgoing_calls_filter:2] Gosub("SIP/sal01-00000040", "outgoing_time_check,s,1") in new stack
-- Executing [s@outgoing_time_check:1] NoOp("SIP/sal01-00000040", "") in new stack
-- Executing [s@outgoing_time_check:2] GotoIfTime("SIP/sal01-00000040", "8:00-17:00,mon-fri,*,*?working_hours,1") in new stack
-- Goto (outgoing_time_check,working_hours,1)
-- Executing [working_hours@outgoing_time_check:1] NoOp("SIP/sal01-00000040", "orario di lavoro") in new stack
-- Executing [working_hours@outgoing_time_check:2] Return("SIP/sal01-00000040", "") in new stack
-- Executing [187@outgoing_calls_filter:3] GotoIf("SIP/sal01-00000040", "1?account,187,1") in new stack
-- Goto (account,187,1)
Now, how can I tell “outgoig_calls_filter” to check if the dialed extension really exists into the “account” context and if it doesn’t exists to just Playback (congestion) and Hangup()?
Thank you!