Search code examples
ubuntuasteriskpbx

Asterisk Transfer call to next extension if previous INUSE


I am trying to transfer call to next extension if previous is using (INUSE) or call is in progress. I tried to use EXTENSION_STATE(extension[@context]) to find the status as follow:

[sales]
exten => s,1,Dial(SIP/123)
exten => s,n,GotoIf($["${EXTENSION_STATE(123)}"="INUSE"]?passed:failed)
exten => s,n(passed),Dial(SIP/124)
exten => s,n(failed),Hangup();if other

But wasn't successful. How can I do that?


Solution

  • Try this:

    [sales]
    exten => s,1,Set(GROUP()=OUTBOUND_GROUP)
    exten => s,2,GotoIf($[ ${GROUP_COUNT()} > 1 ]?try1:try2)
    exten => s,3(try1),Dial(SIP/124)
    exten => s,4(try2),Dial(SIP/123)
    

    Use GROUP_COUNT() instead of EXTENSION_STATE()