Failover to a mobile phone if extension is offline

Hi erveryone,

I have the following dialplan :

exten => 222222222,1,Answer
exten => 222222222,2,Set(CALLFILENAME=${STRFTIME(,%d-%m-%y_%H-%M-%S)}${EXTEN:1}${UNIQUEID})
exten => 222222222,3,Monitor(wav,/var/www/mipa_callmanagement/recordedcalls/${CALLFILENAME},m)
exten => 222222222,4,Ringing
exten => 222222222,5,Dial(SIP/102,15)
exten => 222222222,6,Wait(1)
exten => 222222222,7,Dial(SIP/103,15)
exten => 222222222,8,Wait(1)
exten => 222222222,9,Dial(SIP/101,15)
exten => 222222222,10,Wait(1)
exten => 222222222,11,Goto(222222222,4)

What I need if to failober to mobile ONLY if the extension 101 if offline. What should I add to this plan ?

Thank you very much,

Regards

Can this do the trick ?

same => n,Set(NETWORKSTATUS=${SIPPEER(sip_trunkA-out,status)})
same => n,Gotoif($[NETWORKSTATUS=UNREACHABLE]?101:)
same => n,Dial(SIP/sip_trunkA-out/${EXTEN:1})
same => 101,Dial(SIP/sip_trunkB-out/${EXTEN:1})

This appears to be a Support question, not a General observation.

The function you are using is new to me. It may well work.

However, trying to dial an unregistered SIP device, should produce a dial status of channel unavailable and a hangup cause of 20. You would need to experiment to see what a qualify failure would do. It may produce the same dial status, but the hangup cause may or may not differ.

Try to check the sip peer status with DEVICE_STATE(SIP/peer).

Here is my solution. I can’t test it actually, but somebody will this afternoon :

exten => 222222222,1,Answer
exten => 222222222,n,Ringing
exten => 222222222,n,GotoIf($["${DEVICE_STATE(101)}" = “UNAVAILABLE”] & $["${DEVICE_STATE(102)}" = “UNAVAILABLE”] & $["${DEVICE_STATE(103)}" = “UNAVAILABLE”]?1000)
exten => 222222222,n,Dial(SIP/102,15)
exten => 222222222,n,Wait(1)
exten => 222222222,n,Dial(SIP/103,15)
exten => 222222222,n,Wait(1)
exten => 222222222,n,Dial(SIP/101,15)
exten => 222222222,n,Wait(1)
exten => 222222222,1000,Dial(${GLOBAL(TRUNK)}/07891206607)

Do you think it’s going to work ? I am not sure if the UNAVAILABLE state is the right one. I saw that it also exists : UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING | RINGINUSE | ONHOLD
What is the right one for a phone that is not registred ?

Thank you ! Cheers

The $[…] should be around the whole logical expression.

Device names are of the form technology/address, not just addresss.

Answer, followed by Ringing forces the use of inband ringback tone. Do you really intend that? The caller will get charged even if the call fails.

is this better ? :

exten => 222222222,1,GotoIf($["${DEVICE_STATE(SIP/101)}" = “UNAVAILABLE”] & $["${DEVICE_STATE(SIP/102)}" = “UNAVAILABLE”] & $["${DEVICE_STATE(SIP/103)}" = “UNAVAILABLE”]?1000)
exten => 222222222,n,Answer
exten => 222222222,n,Ringing
exten => 222222222,n,Dial(SIP/102,15)
exten => 222222222,n,Wait(1)
exten => 222222222,n,Dial(SIP/103,15)
exten => 222222222,n,Wait(1)
exten => 222222222,n,Dial(SIP/101,15)
exten => 222222222,n,Wait(1)
exten => 222222222,1000,Dial(${GLOBAL(TRUNK)}/07891206607)

What do you mean by “The $[…] should be around the whole logical expression.” ? Do I have to surrong the whole expression by one more $[ … ] ? like :

GotoIf( $[ $["${DEVICE_STATE(SIP/101)}" … = “UNAVAILABLE”] ] ?1000)

You only have one $[ and one ]. If you need to bracket internally, you use (…).

like that ?

exten => 222222222,1,GotoIf($[$["${DEVICE_STATE(SIP/101)}" = “UNAVAILABLE”] & $["${DEVICE_STATE(SIP/102)}" = “UNAVAILABLE”] & $["${DEVICE_STATE(SIP/103)}" = “UNAVAILABLE”]]?1000)

I took this one as a model :

exten => _011X.,2,GotoIf($[$["${ENUM:0:3}" = “SIP”] | $["${ENUM:0:3}" = “IAX”]]?3:4)

No.

I don’t think the model is correct, but I suppose it might work.