Asterisk Queue
From Luke Jackson
Revision as of 20:35, 30 December 2006 (edit) Ljackson (Talk | contribs) (→Asterisk 1.4) ← Previous diff |
Current revision (20:51, 17 May 2007) (edit) Ljackson (Talk | contribs) (→Dynamic Members Macros) |
||
Line 1: | Line 1: | ||
- | == Queue Log App == | + | == Queue Log Function == |
QueueLog(queuename,uniqueid,agent,event,params): | QueueLog(queuename,uniqueid,agent,event,params): | ||
Line 9: | Line 9: | ||
[http://bugs.digium.com/view.php?id=7368 http://bugs.digium.com/view.php?id=7368] | [http://bugs.digium.com/view.php?id=7368 http://bugs.digium.com/view.php?id=7368] | ||
- | == Dynamic Members == | + | == Dynamic Members Extension == |
- | Logs a dynamic member in or out of the queue. | + | Add the following line to enable the agent-manage macro for a queue into your extensions configuration file. |
+ | |||
+ | exten => 1234*,1,Macro(agent-manage,1234,) | ||
+ | |||
+ | == Dynamic Members Macros == | ||
+ | |||
+ | Add the appropriate macro for your needs and version of asterisk into your macros configuration file. | ||
+ | |||
+ | * '''Important:''' Ensure that your context for internal calls is the same as '''from-internal''' if not you will have to change this. | ||
+ | |||
+ | === Dynamically Manage Agents/Members and log Time-In-Queue (Asterisk 1.4) === | ||
+ | |||
+ | Adds or removes a dynamic member to the queue based on called ID information and logs the time in queue in seconds to /var/log/asterisk/queue_log. | ||
<pre> | <pre> | ||
- | ; Adds a dynamic agent/member to a Queue | + | ; Adds or removes a dynamic agent/member for a queue and logs Time-In-Queue |
- | ; arg1 = trunk number, arg2 = number | + | ; arg1 = queue number, arg2 = number |
- | [macro-agent-add] | + | [macro-agent-manage] |
exten => s,1,Wait(1) | exten => s,1,Wait(1) | ||
exten => s,2,Macro(user-callerid) | exten => s,2,Macro(user-callerid) | ||
exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) | exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) | ||
exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?116)) ; if no number, jump to fail. | exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?116)) ; if no number, jump to fail. | ||
- | exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) ; using chan_local allows us to have agents over trunks | + | exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n||j) ; using chan_local allows us to have agents over trunks |
exten => s,6,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGIN,0) | exten => s,6,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGIN,0) | ||
exten => s,7,Set(DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})=${EPOCH}) | exten => s,7,Set(DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})=${EPOCH}) | ||
Line 38: | Line 50: | ||
exten => s,114,Playback(agent-loggedoff) | exten => s,114,Playback(agent-loggedoff) | ||
exten => s,115,Hangup() | exten => s,115,Hangup() | ||
- | exten => s,116,Playback(sorry-cant-let-you-do-that) | + | exten => s,116,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. |
exten => s,117,Hangup() | exten => s,117,Hangup() | ||
</pre> | </pre> | ||
+ | |||
+ | === Dynamically Manage Agents/Members and log Time-In-Queue (Asterisk 1.2) === | ||
+ | |||
+ | Adds or removes a dynamic member to the queue based on called ID information and logs the time in queue in seconds to /var/log/asterisk/queue_log. | ||
+ | |||
+ | * Requires Queue_Log patch see [[#Queue Log Function|Queue Log Function]] | ||
<pre> | <pre> | ||
- | ; Removes a dynamic agent/member from a Queue | + | ; Adds or removes a dynamic agent/member for a queue and logs Time-In-Queue |
- | ; arg1 = trunk number, arg2 = number | + | ; arg1 = queue number, arg2 = number |
- | [macro-agent-del] | + | [macro-agent-manage] |
exten => s,1,Wait(1) | exten => s,1,Wait(1) | ||
- | exten => s,2,Playback(sorry-cant-let-you-do-that) | + | exten => s,2,Macro(user-callerid) |
- | exten => s,3,Hangup() | + | exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) |
+ | exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?116)) ; if no number, jump to fail. | ||
+ | exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) ; using chan_local allows us to have agents over trunks | ||
+ | exten => s,6,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGIN,0) | ||
+ | exten => s,7,Set(DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})=${EPOCH}) | ||
+ | exten => s,8,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) | ||
+ | exten => s,9,Wait(1) | ||
+ | exten => s,10,Playback(agent-loginok) | ||
+ | exten => s,11,Hangup() | ||
+ | exten => s,106,RemoveQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) | ||
+ | exten => s,107,UserEvent(RefreshQueue) | ||
+ | exten => s,108,Set(ORGEPOCH=${DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})}) | ||
+ | exten => s,109,Set(LGNT=$[${EPOCH} - ${ORGEPOCH}]) | ||
+ | exten => s,110,GotoIf($["${LGNT}" = "0"]?116:111) | ||
+ | exten => s,111,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGOFF,${LGNT}) | ||
+ | exten => s,112,DBdel(agentlogin/q_${ARG1}_a_${CALLBACKNUM}) | ||
+ | exten => s,113,Wait(1) | ||
+ | exten => s,114,Playback(agent-loggedoff) | ||
+ | exten => s,115,Hangup() | ||
+ | exten => s,116,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. | ||
+ | exten => s,117,Hangup() | ||
</pre> | </pre> | ||
- | === Asterisk 1.4 === | + | === Dynamically Manage Agents/Members (Asterisk 1.4) === |
+ | |||
+ | Adds or removes a dynamic member to the queue based on called ID information. | ||
<pre> | <pre> | ||
- | ; Adds a dynamic agent/member to a Queue | + | ; Adds or removes a dynamic agent/member for a queue |
- | ; arg1 = trunk number, arg2 = number | + | ; arg1 = queue number, arg2 = number |
- | [macro-agent-add] | + | [macro-agent-manage] |
exten => s,1,Wait(1) | exten => s,1,Wait(1) | ||
exten => s,2,Macro(user-callerid) | exten => s,2,Macro(user-callerid) | ||
exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) | exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) | ||
- | exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?116)) ; if no number, jump to fail. | + | exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?111)) ; if no number, jump to fail. |
exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n||j) ; using chan_local allows us to have agents over trunks | exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n||j) ; using chan_local allows us to have agents over trunks | ||
exten => s,6,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) | exten => s,6,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) | ||
Line 71: | Line 111: | ||
exten => s,109,Playback(agent-loggedoff) | exten => s,109,Playback(agent-loggedoff) | ||
exten => s,110,Hangup() | exten => s,110,Hangup() | ||
- | exten => s,111,Playback(sorry-cant-let-you-do-that) | + | exten => s,111,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. |
- | exten => s,118,Hangup() | + | exten => s,112,Hangup() |
</pre> | </pre> | ||
+ | |||
+ | === Dynamically Manage Agents/Members (Asterisk 1.2) === | ||
+ | |||
+ | Adds or removes a dynamic member to the queue based on called ID information. | ||
+ | |||
+ | <pre> | ||
+ | ; Adds or removes a dynamic agent/member for a queue | ||
+ | ; arg1 = queue number, arg2 = number | ||
+ | [macro-agent-manage] | ||
+ | exten => s,1,Wait(1) | ||
+ | exten => s,2,Macro(user-callerid) | ||
+ | exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) | ||
+ | exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?111)) ; if no number, jump to fail. | ||
+ | exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) ; using chan_local allows us to have agents over trunks | ||
+ | exten => s,6,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) | ||
+ | exten => s,7,Wait(1) | ||
+ | exten => s,8,Playback(agent-loginok) | ||
+ | exten => s,9,Hangup() | ||
+ | exten => s,106,RemoveQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) | ||
+ | exten => s,107,UserEvent(RefreshQueue) | ||
+ | exten => s,108,Wait(1) | ||
+ | exten => s,109,Playback(agent-loggedoff) | ||
+ | exten => s,110,Hangup() | ||
+ | exten => s,111,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. | ||
+ | exten => s,112,Hangup() | ||
+ | </pre> | ||
+ | |||
+ | === FreePBX === | ||
+ | |||
+ | The above macros are based on macros from the FreePBX front-end to Asterisk. If you choose to implement any of the above macros and are using FreePBX I recommend doing some additional cleanup. | ||
+ | |||
+ | * Remove all references to agent-add and agent-del in extensions_additional.conf as agent-manage will now facilitate this. | ||
+ | exten => 1234*,1,Macro(agent-add,1234,) | ||
+ | exten => 1234**,1,Macro(agent-del,1234,1234) | ||
+ | |||
+ | * Remove agent-add and agent-del from extension.conf as agent-manage will now facilitate this. | ||
+ | [macro-agent-add] | ||
+ | [macro-agent-del] | ||
+ | |||
[[Category:VoIP]] | [[Category:VoIP]] | ||
[[Category:Linux]] | [[Category:Linux]] | ||
[[Category:Mac OS X]] | [[Category:Mac OS X]] |
Current revision
Contents |
Queue Log Function
QueueLog(queuename,uniqueid,agent,event,params):
Allows you to write your own events into the queue log:
QueueLog(101,${UNIQUEID},${AGENT},WENTONBREAK,600)
http://bugs.digium.com/view.php?id=7368
Dynamic Members Extension
Add the following line to enable the agent-manage macro for a queue into your extensions configuration file.
exten => 1234*,1,Macro(agent-manage,1234,)
Dynamic Members Macros
Add the appropriate macro for your needs and version of asterisk into your macros configuration file.
- Important: Ensure that your context for internal calls is the same as from-internal if not you will have to change this.
Dynamically Manage Agents/Members and log Time-In-Queue (Asterisk 1.4)
Adds or removes a dynamic member to the queue based on called ID information and logs the time in queue in seconds to /var/log/asterisk/queue_log.
; Adds or removes a dynamic agent/member for a queue and logs Time-In-Queue ; arg1 = queue number, arg2 = number [macro-agent-manage] exten => s,1,Wait(1) exten => s,2,Macro(user-callerid) exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?116)) ; if no number, jump to fail. exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n||j) ; using chan_local allows us to have agents over trunks exten => s,6,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGIN,0) exten => s,7,Set(DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})=${EPOCH}) exten => s,8,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) exten => s,9,Wait(1) exten => s,10,Playback(agent-loginok) exten => s,11,Hangup() exten => s,106,RemoveQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) exten => s,107,UserEvent(RefreshQueue) exten => s,108,Set(ORGEPOCH=${DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})}) exten => s,109,Set(LGNT=$[${EPOCH} - ${ORGEPOCH}]) exten => s,110,GotoIf($["${LGNT}" = "0"]?116:111) exten => s,111,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGOFF,${LGNT}) exten => s,112,DBdel(agentlogin/q_${ARG1}_a_${CALLBACKNUM}) exten => s,113,Wait(1) exten => s,114,Playback(agent-loggedoff) exten => s,115,Hangup() exten => s,116,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. exten => s,117,Hangup()
Dynamically Manage Agents/Members and log Time-In-Queue (Asterisk 1.2)
Adds or removes a dynamic member to the queue based on called ID information and logs the time in queue in seconds to /var/log/asterisk/queue_log.
- Requires Queue_Log patch see Queue Log Function
; Adds or removes a dynamic agent/member for a queue and logs Time-In-Queue ; arg1 = queue number, arg2 = number [macro-agent-manage] exten => s,1,Wait(1) exten => s,2,Macro(user-callerid) exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?116)) ; if no number, jump to fail. exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) ; using chan_local allows us to have agents over trunks exten => s,6,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGIN,0) exten => s,7,Set(DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})=${EPOCH}) exten => s,8,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) exten => s,9,Wait(1) exten => s,10,Playback(agent-loginok) exten => s,11,Hangup() exten => s,106,RemoveQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) exten => s,107,UserEvent(RefreshQueue) exten => s,108,Set(ORGEPOCH=${DB(agentlogin/q_${ARG1}_a_${CALLBACKNUM})}) exten => s,109,Set(LGNT=$[${EPOCH} - ${ORGEPOCH}]) exten => s,110,GotoIf($["${LGNT}" = "0"]?116:111) exten => s,111,QueueLog(${UNIQUEID},${ARG1},${CALLBACKNUM},AGENTLOGOFF,${LGNT}) exten => s,112,DBdel(agentlogin/q_${ARG1}_a_${CALLBACKNUM}) exten => s,113,Wait(1) exten => s,114,Playback(agent-loggedoff) exten => s,115,Hangup() exten => s,116,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. exten => s,117,Hangup()
Dynamically Manage Agents/Members (Asterisk 1.4)
Adds or removes a dynamic member to the queue based on called ID information.
; Adds or removes a dynamic agent/member for a queue ; arg1 = queue number, arg2 = number [macro-agent-manage] exten => s,1,Wait(1) exten => s,2,Macro(user-callerid) exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?111)) ; if no number, jump to fail. exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n||j) ; using chan_local allows us to have agents over trunks exten => s,6,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) exten => s,7,Wait(1) exten => s,8,Playback(agent-loginok) exten => s,9,Hangup() exten => s,106,RemoveQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) exten => s,107,UserEvent(RefreshQueue) exten => s,108,Wait(1) exten => s,109,Playback(agent-loggedoff) exten => s,110,Hangup() exten => s,111,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. exten => s,112,Hangup()
Dynamically Manage Agents/Members (Asterisk 1.2)
Adds or removes a dynamic member to the queue based on called ID information.
; Adds or removes a dynamic agent/member for a queue ; arg1 = queue number, arg2 = number [macro-agent-manage] exten => s,1,Wait(1) exten => s,2,Macro(user-callerid) exten => s,3,Set(CALLBACKNUM=${CALLERID(number)}) exten => s,4,GotoIf($["${CALLBACKNUM}" = ""]?111)) ; if no number, jump to fail. exten => s,5,AddQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) ; using chan_local allows us to have agents over trunks exten => s,6,UserEvent(Agentlogin|Agent: ${CALLBACKNUM}) exten => s,7,Wait(1) exten => s,8,Playback(agent-loginok) exten => s,9,Hangup() exten => s,106,RemoveQueueMember(${ARG1}|Local/${CALLBACKNUM}@from-internal/n) exten => s,107,UserEvent(RefreshQueue) exten => s,108,Wait(1) exten => s,109,Playback(agent-loggedoff) exten => s,110,Hangup() exten => s,111,Playback(sorry-cant-let-you-do-that) ; Catch error and give simple notification. exten => s,112,Hangup()
FreePBX
The above macros are based on macros from the FreePBX front-end to Asterisk. If you choose to implement any of the above macros and are using FreePBX I recommend doing some additional cleanup.
- Remove all references to agent-add and agent-del in extensions_additional.conf as agent-manage will now facilitate this.
exten => 1234*,1,Macro(agent-add,1234,) exten => 1234**,1,Macro(agent-del,1234,1234)
- Remove agent-add and agent-del from extension.conf as agent-manage will now facilitate this.
[macro-agent-add] [macro-agent-del]
Categories: VoIP | Linux | Mac OS X