Asterisk .NET & global variables

I’m currently working on an application that uses Asterisk 1.4.
I use an instance of the AgentCallbackLoginAction class for logging a given agent onto the phone system. I’ve noticed that if I log in by using the phone directly, a global variable AGENTBYCALLERID is set, which is not the case if I use my AgentCallbackLoginAction object. I solved this problem by executing another action – SetVarAction, which sets the variable’s value.
Now my problem is that when I log off by executing AgentLogoffAction, this global variable is not removed (which happens if I use the phone directly). I cannot find any “clear variablesâ€

AgentCallbackLogin is deprecated. The current preferred method is to use a Local channel as the queue member, in which case you can manipulate the variable using dialplan logic.

@david55

Thank you for your response.
Unfortunately this is my first Asterisk project and I’m not that experienced with Asterisk API. Could you please point me in the right direction by naming some of the classes/functions I must use in order to implement the logics you mention above?

You don’t need to use any AMI actions to implement agents, so the answer would depend on the details of your application, and its reasons for using AMI. However, I imagine that you would need to use QueueAdd.

Somewhere in the Asterisk sources, at least for 1.4, is sample dialplan coding for replacing AgentCallBackLogin.

However, if your login is only done from AMI, you could even make the agent’s phone, itself, be the queue member. You’d need a local channel to set global variables, but you should, at least, consider retrieving the caller ID from first principles, or capture it from the CALLERCONNECT event.

@david55

As I can see in the code, the system already uses QueueAddAction when assigning the agents to the different queues:

Asterisk.NET.Manager.Action.CommandAction _commandAction = new Asterisk.NET.Manager.Action.CommandAction(string.Format(“queue add member Agent/{0} to {1} penalty {2}”, phone, queue, penalty));
asteriskManger.Connection.SendAction(_commandAction);

This makes them available, but they do not appear as ‘logged in’ when I run ‘agent show’ CLI command. That’s why I was using AgentCallbackLoginAction which did the trick:

AgentCallbackLoginAction _logInAction = new AgentCallbackLoginAction(agent, _extension, “from-internal”);
_response = asteriskManger.Connection.SendAction(_logInAction);

It’s also important that I can modify the value of _extension variable dynamically, so I’m not bound to a specific phone. Any suggestions are welcome.
Again, thanks for the help.