asterisksippbx

how to choose and dial a random sip peer which is available in asterisk


I'm new to asterisk and I'd like to dial to a random & available sip peer. And here I tried some technique like choosing from a list of users with ChanIsAvail(SIP/user1&SIP/user2&SIP/user3,j). And I would like to choose the random users peer which is avail.

  exten => _XXXXXXX,1,ChanIsAvail(SIP/user1&SIP/user2&SIP/user3,j)
  exten => _XXXXXXX,n,Dial(${AVAILORIGCHAN})

and the sip users like

  [user1]
  type=peer
  username=user1
  secret=user1XX
  host=dynamic
  context=from-pstn

  [user2]
  type=peer
  username=user2
  secret=user2XX
  host=dynamic
  context=from-pstn

  [user3]
  type=peer
  username=user3
  secret=user3XX
  host=dynamic
  context=from-pstn

  .
  .
  .

How do I choose available(NOT BUSY) users from these..?


Solution

  • There are no implemented in asterisk way to do that.

    You have use GotoIf, Set, variables, simple loops and CUT with RAND function.

    So just organize random choose of channel, save in variables which channel already tested.

    If not tested, check if it availible and call. On fail try next based on DIALSTATUS.

    http://www.voip-info.org/wiki/view/Asterisk+cmd+GotoIf

    http://www.voip-info.org/wiki/view/Asterisk+cmd+Set

    http://www.voip-info.org/wiki/view/Asterisk+variables

    http://www.voip-info.org/wiki/view/Asterisk+func+cut

    http://www.voip-info.org/wiki/view/Asterisk+func+rand