Extension logical grouping and automatic forwarding


I wonder if someone cal help me to find the right way to implement the below described TO-BE scenario (basically automatic forwarding of incoming calls and queue management).

*** Background:

  • a VoIP/PSTN gateway (a Mediatrix 1104) registers on Asterisk@Home as UAs from 301 to 304. This Mediatrix is the gateway (4 FXS ports) between a SIP/VoIP domain and a legacy PBX Nortel Meridian 1.
  • others UA (SIP/VoIP terminals extension from 100 to 140) also register into Asterisk@home
  • FXO ports on Nortel Meridian have been configured with DISA (two step calling)

*** AS-IS situation

  1. UA 100 dial let’s say 301 and get a PSTN line from the Meridian PBX my mean of Mediatrix. UA then calls the desired number
  2. If another UA, let’s say 101 wants to have a PSTN line, it should now that 301 is busy because of 100 in progress call and therefore it shall call any other Mediatrix registered extension, that is from 302 to 304 until a free one is found.
  3. And so on…

*** TO-BE scenario (to be achieved)

  1. UA 301 to 304 (Mediatrix VoIP gateway registered UA) are logically grouped in Aterisk and referred by a virtual extesion, let’s say 999

  2. any UA from VoIP domain calls 999 and Asterisk automatically route the incoming call on the first available line of Mediatrix (that is the first avalable extension in the range 301-304). If none is available, asterisk put the incoming call on hold. Something like:
    IF port 301 is busy THEN reroute call on 302
    IF port 302 is busy THEN reroute call on 303
    IF port 303 is busy THEN reroute call on 303
    IF port 304 is busy THEN put on hold for x minutes

Thanks in advance for your help