Trying to implement call back queues in ael

I am just beginning my journey with Asterisk and am having a problem with the queues. I am trying to follow the example in the “Queues with callback members” tutorial which shows the use of dynamic queues. This tutorial is posted on the web and in the docs folder of the source. I can get the agent logged in (and out), but my issue is that a call to the extension which uses the Queue() app in the dialplan fails. Queue() returns that the queue is empty. My dialplan uses extension 800 as the entry point to the queue. I am included my dialplan (extensions.ael), queues.conf, and part of the asterisk console output below. I appreciate any help I can get :smile:

My configuration is a single 4 port card with 1 FXS and 1 FXO.

Here is my dialplan (extensions.ael):
globals {
OUTBOUNDTRUNK=zap/2;
MYLOCATION=sip/103;
}

// This if for SIP phones, mostly for testing
macro sip-extension(ext) {
if (${CALLERID(num)} = ${ext}) {
VoiceMailMain(${ext});
} else {
Dial(SIP/${ext}, 20);
if (${DIALSTATUS} = “BUSY”) {
Voicemail(${ext}, b);
} else {
Voicemail(${ext}, u);
}
Playback(vm-goodbye);
}
Hangup();
}

// This if for Startel Office extensions
macro startel-extension(ext) {
if (${CALLERID(num)} = ${ext}) {
VoiceMailMain(${ext});
} else {
Dial(${OUTBOUNDTRUNK}/${ext}, 20);
if (${DIALSTATUS} = “BUSY”) {
Voicemail(${ext}, b);
} else {
Voicemail(${ext}, u);
}
Playback(vm-goodbye);
}
Hangup();
}

// this is for call destined for Richard’s box
macro peer-extension(ext) {
Dial(IAX2/RPETTITT_ASTERISK/${ext}@sip_phone);
Hangup();
}

// this is for calls goint out the trunk line
macro outbound-trunk(num) {
Dial(${OUTBOUNDTRUNK}/${num});
Hangup();
}

// macro for recording a prompt for later.
macro record-prompt(num) {
Wait(2);
Record(/tmp/record${num}:wav);
Wait(1);
Playback(/tmp/record${num});
Hangup();
}

// This if for calls coming in from the pots line
// map to ring at MYLOCATION
context incoming {
s => {
Answer();
Dial(${MYLOCATION}, 30);
if (${DIALSTATUS} = “BUSY”) {
Voicemail(103, b);
} else {
Voicemail(103, u);
}
Playback(vm-goodbye);
Hangup();
}
}

// this is the default context where extension matching will be done…
context default {
includes {
queues-loginout;
agents;
}

// startel extensions are 3 digits and begin with a 6 or 7
_[67]XX => &startel-extension(${EXTEN});

// my sip phones will be 3 digits and begin with a 1 or 2
_[12]XX => &sip-extension(${EXTEN});

// 9 and extensions 1000 to 4999 will route to Richard's box
_9[1234]XXX => &peer-extension(${EXTEN:1});

// 9 and anything else goes to out bound
_9. => &outbound-trunk(${EXTEN:1});

// echo test
411 => { Answer(); Echo(); Hangup(); }

// record a prompt for later
_7XX => &record-prompt(${EXTEN:1});

}

context test-queue {
s => {
Ringing();
Wait(2);
Playback(QueueTest/queue-welcome);
Queue(test-queue);
Playback(vm-goodbye);
Hangup();
}
}

context queues-loginout {
6092 => {
Answer();
Read(AGENT_NUMBER,QueueTest/agent-enternum);
Set(queue-announce-success=1);
goto queues-manip,I${AGENT_NUMBER},1;
}

6093 => {
	Answer();
	Read(AGENT_NUMBER,QueueTest/agent-enternum);
	Set(queue-announce-success=1);
	goto queues-manip,O${AGENT_NUMBER},1;
}

}

context queues-manip {
_[IO]6103 => {
&queue-addremove(test-queue,10);
&queue-success();
}
}

macro queue-success() {
if (${queue-announce-success} > 0) {
switch (${MACRO_EXTEN:0:1}) {
case I: Playback(agent-loginok); break;
case O: Playback(agent-loggedoff); break;
}
Hangup();
}
}

macro queue-addremove(queuename, penalty) {
switch (${MACRO_EXTEN:0:1}) {
case I: AddQueueMember(${queuename}, Local/${MACRO_EXTEN:1}@agents, ${penalty}); break;
case O: RemoveQueueMember(${queuename}, Local/${MACRO_EXTEN:1}@agents); break;
case P: PauseQueueMember(${queuename}, Local/${MACRO_EXTEN:1}@agents); break;
case U: UnpauseQueueMember(${queuename}, Local/${MACRO_EXTEN:1}@agents); break;
default: Playback(invalid);
}
}

context agents {
800 => {
Set(QUEUE_MAX_PENALTY=0);
Queue(test-queue);
}

6103 => &callagent(SIP/103);

}

macro callagent(device) {
if (${GROUP_COUNT(${MACRO_EXTEN}@agents)}=0) {
Set(OUTBOUND_GROUP=${MACRO_EXTEN}@agents);
Dial(${device},10);
switch (${DIALSTATUS}) {
case BUSY:
Busy();
break;
case NOANSWER:
Set(queue-announce-success=0);
goto queues-manip,O${MACRO_EXTEN},1;
break;
default:
Hangup();
break;
}
} else {
Busy();
}
}
// END OF DIALPLAN

Here is my queues.conf:
[general]
persistentmembers=yes

[default]

[test-queue]
music=default
context=test-queue
strategy=leastrecent
joinempty=strict
leavewhenempty=strict

Finally, here is an extract from the asterisk console showing the successful agent login, and the failed call to extension 800.

CLI>
– Executing [6092@default:1] Answer(“SIP/103-0999c9e8”, “”) in new stack
– Executing [6092@default:2] Read(“SIP/103-0999c9e8”, “AGENT_NUMBER|QueueTest/agent-enternum”) in new stack
– <SIP/103-0999c9e8> Playing ‘QueueTest/agent-enternum’ (language ‘en’)
– User entered ‘6103’
– Executing [6092@default:3] Set(“SIP/103-0999c9e8”, “queue-announce-success=1”) in new stack
– Executing [6092@default:4] Goto(“SIP/103-0999c9e8”, “queues-manip|I6103|1”) in new stack
– Goto (queues-manip,I6103,1)
– Executing [I6103@queues-manip:1] Macro(“SIP/103-0999c9e8”, “queue-addremove|test-queue|10”) in new stack
– Executing [s@macro-queue-addremove:1] Set(“SIP/103-0999c9e8”, “queuename=test-queue”) in new stack
– Executing [s@macro-queue-addremove:2] Set(“SIP/103-0999c9e8”, “penalty=10”) in new stack
– Executing [s@macro-queue-addremove:3] Set(“SIP/103-0999c9e8”, “EXTEN=s”) in new stack
– Executing [s@macro-queue-addremove:4] Goto(“SIP/103-0999c9e8”, “sw-18-I|10”) in new stack
– Goto (macro-queue-addremove,sw-18-I,10)
– Executing [sw-18-I@macro-queue-addremove:10] AddQueueMember(“SIP/103-0999c9e8”, “test-queue| Local/6103@agents| 10”) in new stack
[Sep 10 15:54:47] NOTICE[6343]: app_queue.c:3619 aqm_exec: Added interface ‘Local/6103@agents’ to queue ‘test-queue’
– Executing [sw-18-I@macro-queue-addremove:11] Goto(“SIP/103-0999c9e8”, “s|5”) in new stack
– Goto (macro-queue-addremove,s,5)
– Executing [s@macro-queue-addremove:5] NoOp(“SIP/103-0999c9e8”, “Finish switch-queue-addremove-18”) in new stack
– Executing [I6103@queues-manip:2] Macro(“SIP/103-0999c9e8”, “queue-success”) in new stack
– Executing [s@macro-queue-success:1] GotoIf(“SIP/103-0999c9e8”, “1?2:6”) in new stack
– Goto (macro-queue-success,s,2)
– Executing [s@macro-queue-success:2] Set(“SIP/103-0999c9e8”, “EXTEN=s”) in new stack
– Executing [s@macro-queue-success:3] Goto(“SIP/103-0999c9e8”, “sw-17-I|10”) in new stack
– Goto (macro-queue-success,sw-17-I,10)
– Executing [sw-17-I@macro-queue-success:10] Playback(“SIP/103-0999c9e8”, “agent-loginok”) in new stack
– <SIP/103-0999c9e8> Playing ‘agent-loginok’ (language ‘en’)
– Executing [sw-17-I@macro-queue-success:11] Goto(“SIP/103-0999c9e8”, “s|4”) in new stack
– Goto (macro-queue-success,s,4)
– Executing [s@macro-queue-success:4] NoOp(“SIP/103-0999c9e8”, “Finish switch-if-queue-success-16-17”) in new stack
– Executing [s@macro-queue-success:5] Hangup(“SIP/103-0999c9e8”, “”) in new stack
== Spawn extension (macro-queue-success, s, 5) exited non-zero on ‘SIP/103-0999c9e8’ in macro ‘queue-success’
== Spawn extension (macro-queue-success, s, 5) exited non-zero on ‘SIP/103-0999c9e8’

*CLI>
*CLI> queue show
test-queue has 0 calls (max unlimited) in ‘leastrecent’ strategy (0s holdtime), W:0, C:0, A:0, SL:0.0% within 0s
Members:
Local/6103@agents with penalty 10 (dynamic) (Invalid) has taken no
calls yet
No Callers

default has 0 calls (max unlimited) in ‘ringall’ strategy (0s holdtime), W:0, C:0, A:0, SL:0.0% within 0s
No Members
No Callers

*CLI>
*CLI>
– Executing [800@default:1] Set(“SIP/101-0999c9e8”, “QUEUE_MAX_PENALTY=0”) in new stack
– Executing [800@default:2] Queue(“SIP/101-0999c9e8”, “test-queue”) in new stack
[Sep 10 15:55:02] WARNING[6344]: app_queue.c:3933 queue_exec: Unable to join queue ‘test-queue’
[Sep 10 15:55:02] WARNING[6344]: app_queue.c:3936 queue_exec: reason: JOINUNAVAIL
== Auto fallthrough, channel ‘SIP/101-0999c9e8’ status is ‘UNKNOWN’

Thanks!

I just noticed that the results of my queue show

test-queue has 0 calls (max unlimited) in ‘leastrecent’ strategy (0s holdtime), W:0, C:0, A:0, SL:0.0% within 0s
Members:
Local/6103@agents with penalty 10 (dynamic) (Invalid) has taken no
calls yet
No Callers

default has 0 calls (max unlimited) in ‘ringall’ strategy (0s holdtime), W:0, C:0, A:0, SL:0.0% within 0s
No Members
No Callers

lists my agent as Invalid. Can anyone point me in the direction of why the agent would be invalid?

Thanks!

Russell Markus