Calling Forwarding + Voice Mail


#1

Dear All,

I have a strange call flow logic here to see if anyone can assist me. Currently I am use RealTime Extensions aka CVS-Head. And in the table I have a record that will ring a SIP phone and if not pick up it will go to voicemail. Now to the call flow:

If Unconditional Foward = On
1. Call to fowarded number
2. HangUp
Else If No Pick Up foward = On
1. Call SIP Phone until time out
2. Call to fowarded Number til time out
3. HangUp

If none of the call fowarding is on. Please use the Realtime Extensions so that the call would go to User agent, then voicemail according to the dial-plan I set in the realtime extensions table.

That is basically the call flow that I would like to see if it is possible. But my problem is that I can control the dialplan to let the call fall into the Realtime Extensions aka ‘switch=>Realtime@context’ statement.

An interesting note: What is the users want to forward to PSTN or SIP, how would you set the variable dial statement as you don’t know if you should use Zap or SIP for the call forwarding.

Here is my version of the call flow, but it doesn’t work properly:

;User SQL to check if call is for SIP or Outbound
exten => _X.,1,MYSQL(Connect connid localhost asterisk asterisk asterisk)
exten => _X.,2,MYSQL(Query resultid ${connid} SELECT\ name\ from\ sip_buddies\ where\ regexten=${EXTEN})
exten => _X.,3,MYSQL(Fetch fetchid ${resultid})
exten => _X.,4,MYSQL(Clear ${resultid})
exten => _X.,5,MYSQL(Disconnect ${connid})
exten => _X.,6,Gotoif(${fetchid}?11:13)
exten => _X.,7,SetVar(CallType=SIP/)
exten => _X.,8,Goto(10)
exten => _X.,9,SetVar(CallType=Zap/g1/)
exten => _X.,10,DBget(CFIM_Num=CFIM/${EXTEN})
exten => _X.,11,DBget(CFBS_Num=CFBS/${EXTEN})
exten => _X.,12,NoOp(${LEN(${CFIM_Num})} ${CFIM_Num})
exten => _X.,13,NoOp(${LEN(${CFBS_Num})} ${CFBS_Num})
exten => _X.,14,GotoIf($[${LEN(${CFIM_Num})}>0]:15?17)
exten => _X.,15,Dial(Zap/g1/${CFIM_Num}|20)
exten => _X.,16,HangUp
exten => _X.,17,GotoIf($[${LEN(${CFBS_Num})}>0]:18?20)
exten => _X.,18,Dial(Zap/g1/${CFBS_Num}|20)
exten => _X.,19,HangUp
exten => _X.,20,SoftHangup(${CallType}${CallerID})
;Realtime Routing from MySQL
switch => Realtime/default@extensions

It seems like the append doens’t work properly in Asterisk.

Many thanks!

Regards,
Kengie