[Asterisk-Users] Re: AgentCallBacklogin (logout continued...)

alan alan at pair.com
Thu Jun 9 08:35:01 MST 2005


1 2 <vortex_0_o at yahoo.com> wrote:

> Anyone know if
>
> - it is possible to limit 1 agent per extension where
> the last agent to log in overrides any previous agents
>
> or
>
> - a Command/application to clear all agents logged in
> on extension
>
>
> Does this look like it would require a custom mod to
> do it?

In Asterisk v1, the biggest stumbling block to implementing this in the
dial plan is the fact that logging out of an extension requires you to
enter your agent password. This is really silly, and an unnecessary
security risk (imagine if you left yourself logged into a unix shell,
and it was impossible to log out without a password- it's begging for
others to use your account instead of being a good samaritan and
logging you out).

I implemented a solution to the problem you describe, using only the
dial plan. This is possible, though a bit awkward, only if you don't use
agent passwords. Entering an extension of "#" (no extension) in the
AgentCallbackLogin application logs you out.

The basic solution I implemented is: before logging an agent in, check
to see if any other agent is logged in to the same extension. If they
are, log that agent out instead of logging the new one in.
Unfortunately, logging out an agent automatically hangs up, so the agent
needs to call back again if they want to log back in.

I'm not fully happy with this solution! I would prefer a better one if
any exists, but I haven't found anything better suited to my needs on
the wiki or elsewhere yet, which works for Asterisk v1.

This is only deployed in our test environment, and hasn't been stress
tested with actual people yet. (And now that I look back on it, there
are some obvious optimizations I could make which were apparently not
obvious at the time...)


Here is a macro I set up to log an agent out of whatever extension
they're logged into. The agent is an agent channel name, not an
extension number. The "dial # automatically" hack came from the wiki;
just specifying an agent extension of "#" doesn't work.

[macro-agent_logout]

; Agent logout.
;
; Log out the specified agent.
;
; On a logged-in agent phone, caller ID is set to the agent's caller
; ID automatically, so we don't need to look up the agent ID for this
; caller ID.


exten => s, 1, setglobalvar(agent=${ARG1})
exten => s, 2, noop(agent ${agent})
exten => s, 3, dial(local/logout at macro-agent_logout/n,,D(w#))

exten => logout, 1, noop(agent logout ${agent})
exten => logout, 2, wait(1)
exten => logout, 3, agentcallbacklogin(${agent}, at shared_phones)



This macro logs an agent off of a specified extension. Note that the
AGENTBYCALLERID variable is only accurate if exactly ONE agent logs into
an extension. If more than one logs in, this will only log out the last
agent who logged in.  This makes the later agent login hack necessary...
(macro-answer_wait just does an answer() and wait(1).)


[macro-agent_logout_ext]
exten => s, 1, setvar(agent=${AGENTBYCALLERID_${ARG1}})
exten => s, 2, gotoif(${agent}?3:101)
exten => s, 3, macro(agent_logout,${agent})
exten => s, 101, macro(answer_wait)
exten => s, 102, playback(agent-loggedoff)
exten => s, 103, hangup()




For agent logins, I use this macro.

[macro-agent_login]

; Agent login.

; If someone is already logged in to this extension, then turn this
; into an agent logout.  Otherwise, log in: we only prompt for agent
; ID, and we don't use passwords.
;
; ${ARG1} is the full caller ID of the extension the agent will be
; logged in to.
;
; ${ARG2} is the CALLERIDNUM of the extension the agent will be logged
; in to.

; If there's an agent set for this callerid, then log it out;
; otherwise, log in.
exten => s, 1, setvar(agent=${AGENTBYCALLERID_${ARG1}})
exten => s, 2, gotoif(${agent}]?104:9)

exten => s, 9, noop(logging in ${ARG2})
exten => s, 10, agentcallbacklogin(,${ARG2}@shared_phones)

; Agent is logged in, log them out. Unfortunately we can't then log back
; in because it hangs up.
exten => s, 104, goto(agent_logged_in,s,1)

[agent_logged_in]

; "An agent is already logged in. Press 1 to log out, or any other
; button to cancel."
exten => s, 1, macro(answer_wait)
exten => s, 2, background(agent_logged_in)

; this hangs up when it's finished.
exten => 1, 1, macro(agent_logout,${agent})

exten => _[2-9#*], 1, playback(goodbye)
exten => _[2-9#*], 2, hangup



And finally, the actual agent service extensions:


exten => 212, 1, macro(agent_login,${CALLERID},${CALLERIDNUM})
exten => 213, 1, macro(agent_logout_ext,${CALLERID})


I hope this helps.  Please feel free to forward any questions you may have.


Alan Ferrency
pair Networks, Inc.
alan at pair.com



More information about the asterisk-users mailing list