Asterisk AsterNET How to move from parking to queue?

619 views Asked by At

Im using C# AsterNET to manage my Asterisk commands and events, and now I do have a new feature to work on.

This is simple (I think) but I'm stucked right now.

Scenario

I do have two queues, 8100 and 8300, and 2 extensions being 8101 and 8301. When I do have a call from PSTN it is driven to 8100 queue. When the 8101 extension become available I do add this extension to the 8100 queue, so the calling PSTN device will be redirected to this 8101 extension.

Everything is working fine till here.

Sometimes I do park the calling device and let 8301 knows it using my app, so 8301 user using the same app can send a command asking for that parked channel to be redirect to his SIP Phone. Also working fine.

Scope

Now I want to have some feature to let 8101 transfer this calling device to my other queue, the 8300. So I just tried to reuse my parked method and redirect method

internal void Park(string channel, int parkTimeout)
{
    ParkAction pa = new ParkAction(channel, channel, parkTimeout.ToString());

    ManagerResponse mr = manager.SendAction(pa);
}

internal void RedirectFromParking(string channel, string exten)
{
    RedirectAction ra = new RedirectAction
    {
        Priority = 1,
        Context = "default",
        Channel = channel,
        Exten = exten
    };

    ManagerResponse mr = manager.SendAction(ra);
}

Park("abc123456", 10000);

RedirectFromParking("abc123456", "8300")

Issue

I'm parking fine but when I try to redirect from parking to my queue the calling device is just disconnected and the connection is lost.

How can I transfer a parked call to my queue or transfer it directly to the queue (would be better) without needing to originate?

2

There are 2 answers

1
arheops On

Just do hold instead of parking and make your own list of such calls.

0
Andrew Paes On

To transfer to a queue I can do a blind transfer as documented on Asterisk website. Links below:

ManagerAction_BlindTransfer

ManagerEvent_BlindTransfer

To achieve this using AsterNET, I can use the same RedirectAction I was using but I do need to change the context. It can't be default for context, as default we are letting Asterisk manage it and somehow it can't handle as I expetected. So it need to be clearly specified as internar transfer. The event raised after this context transfer is the Manager_BlindTransfer.

Manager_Action_RedirectAction

So using my SIP Phone I manage to transfer a call while I was debugging that raised event method, so I could catch the context used in. Using the correct context

ManagerConnection manager = new ManagerConnection(address, port, user, password);

manager.BlindTransfer += Manager_BlindTransfer;

private void Manager_BlindTransfer(object sender, BlindTransferEvent e)
{

}

After this I created another method to transfer to directly to a queue using the correct context.

internal void TransferToQueue(string channel, string queue)
{
    RedirectAction ma = new RedirectAction
    {
        Priority = priority,
        Context = "from-internal-xfer",
        Channel = channel,
        Exten = queue
    };

    ManagerResponse mr = manager.SendAction(ma);
}

TransferToQueue("abc123456", "8300")

Summary

Was just a matter of the correct context to be used in.

from-internal-xfer