Ringgroup from AGI

Hi. I have a question about freepbx scenario -
I am trying to do the use a ringgroup from AGI:

  1. agi script accepts call
  2. $AGI->exec(“Dial”,“Local/[email protected]|55”); -to ring a group
  3. $AGI->get_variable(‘DIALSTATUS’);
  4. if answered do XXX else do YYY

Problem is that ringgroup does not really return processing back to agi.
How can I get the control back to AGI?