Extensions.conf AGI stops the dialplain

Ok so I am having a small issue - Maybe I am going through is wrong. But I can get the call running the AGI but I am not able to continue running the extensions.conf dials plain while my perl script runs its loop.

So I need away to run this AGI in the background when the call is dialed.

The part of my AGI that is screwing up

my $linestatus = $agi->channel_status();

###THIS PART NEEDS TO LOOP UNTIL $linestatus == 6 But It is also stopping the number from dialling.###
until($linestatus == 6);
my $query = $collection->insert({ “caller” =>$num, “callername” => $name,“linestatus”=>$linestatus, “extension”=> $ext, “call_start”=>$time}, {safe => 1});
$agi->verbose(“ANSWERED\n”, 1);

My extensions.conf dial plain.

exten => _08.,1,AGI(bTel.agi) exten => _08.,n,Dial(SIP/61${EXTEN:1}@SIPINTERNAL,,tTor) exten => _08.,n,Hungup

Your approach is fundamentally flawed. You need to go back to the overall goal.

Could you please explain what you mean by flawed?

You have a poor undertanging of how Asterisk works and you have produced a design based on that mis-understanding.