Understanding the dialplan

Hi

i am experiencing a problem with agents in a queue not receiving calls because of the following dialplan:

exten => s,n(report2),Set(__TTL=${IF($[“foo${TTL}” = “foo”]?6:$[ ${TTL} - 1 ])})
exten => s,n,GotoIf($[ ${TTL} > 0 ]?continue)
exten => s,n,Wait(${RINGTIMER})

The TTL doesn’t return with a value grater then 0 and this hands at wait.

What exactly is foo${TTL} looking at, where is TTL programmed?

Regards

Ask the person who wrote the dialplan, that’s s custom variable not set by asterisk.

Its part of FreePBX 13 and they referred me to Asterisk Community.

Asterisk doesn’t come with a dialplan, Who sent you here? all admins in FreePBX knows that their diaplan is a special dialplan. If they think that the IF or the GotoIF are not working then probably is a bug with asterisk but you need to show the debug of the call and the complete dialplan involved. So far the issue is with your variable which is set by FreePBX.

Thank you, I am escalating it back to FreePBX support desk.

Cool, so that is a new functionality of FreePBX or you added that in a custom context?

If they added it, they added it by cut and paste coding, as “foo” serves no useful purpose at all. It’s just a hack to turn empty strings into non-empty ones, but should not be needed because "'s solve the problem of matching empty strings. “foo” could be any string that is not syntactically significant.

Its part of FreePBX context its a macro they generate:

[macro-user-callerid]
exten => s,1,Set(TOUCH_MONITOR=${UNIQUEID})
exten => s,n,Set(AMPUSER=${IF($["${AMPUSER}" = “”]?${CALLERID(number)}:${AMPUSER})})
exten => s,n,GotoIf($["${CUT(CHANNEL,@,2):5:5}"=“queue” | ${LEN(${AMPUSERCIDNAME})}]?report)
exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = “”]?Set(REALCALLERIDNUM=${CALLERID(number)}))
exten => s,n,Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n,GotoIf($["${AMPUSER}" = “none”]?limit)
exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => s,n,GotoIf($["${AMPUSERCIDNAME:1:2}" = “”]?report)
exten => s,n,Set(AMPUSERCID=${IF($["${ARG2}" != “EXTERNAL” & “${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}” = “1”]?${DB_RESULT}:${AMPUSER})})
exten => s,n,Set(__DIAL_OPTIONS=${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/dialopts)}" = “1”]?${DB_RESULT}:${DIAL_OPTIONS})})
exten => s,n,Set(CALLERID(all)="${AMPUSERCIDNAME}" <${AMPUSERCID}>)
exten => s,n,GotoIf($["${ARG1}"=“LIMIT” & ${LEN(${AMPUSER})} & ${DB_EXISTS(AMPUSER/${AMPUSER}/concurrency_limit)} & ${DB(AMPUSER/${AMPUSER}/concurrency_limit)}>0 & ${GROUP_COUNT(${AMPUSER}@concurrency_limit)}>=$
exten => s,n,ExecIf($["${ARG1}"=“LIMIT” & ${LEN(${AMPUSER})}]?Set(GROUP(concurrency_limit)=${AMPUSER}))
exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/language)}" != “”]?Set(CHANNEL(language)=${DB(AMPUSER/${AMPUSER}/language)}))
exten => s,n(report),GotoIf($[ “${ARG1}” = “SKIPTTL” | “${ARG1}” = “LIMIT” ]?continue)
exten => s,n,ExecIf($["${CALLEE_ACCOUNCODE}" = “”]?Set(__CALLEE_ACCOUNCODE=${DB(AMPUSER/${IF($["${MACRO_CONTEXT}"=“macro-exten-vm”]?${ARG2}:${MACRO_EXTEN})}/accountcode)}))
exten => s,n(report2),Set(__TTL=${IF($[“foo${TTL}” = “foo”]?6:$[ ${TTL} - 1 ])})
exten => s,n,GotoIf($[ ${TTL} > 0 ]?continue)
exten => s,n,Wait(${RINGTIMER})
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n,Gosub(macro-user-callerid,lang-playback,1(hook_0))
exten => s,n,Macro(hangupcall,)
exten => s,n(limit),Answer
exten => s,n,Wait(1)
exten => s,n,Gosub(macro-user-callerid,lang-playback,1(hook_1))
exten => s,n,Macro(hangupcall,)
exten => s,n,Congestion(20)
exten => s,n(continue),Set(CALLERID(number)=${CALLERID(number):0:40})
exten => s,n,Set(CALLERID(name)=${CALLERID(name):0:40})
exten => s,n,GotoIf($["${CALLERID(name)}" = “”]?cnum)
exten => s,n,Set(CDR(cnam)=${CALLERID(name)})
exten => s,n(cnum),Set(CDR(cnum)=${CALLERID(num)})
exten => s,n,Set(CHANNEL(language)=${MASTER_CHANNEL(CHANNEL(language))})

However as soon as the queue rings the member it calls the macro and fails:

-- Executing [s@macro-user-callerid:1] Set("Local/2028@from-queue-0002c416;2", "TOUCH_MONITOR=1505382582.381471") in new stack
-- Executing [s@macro-user-callerid:2] Set("Local/2028@from-queue-0002c416;2", "AMPUSER=+27114528644") in new stack
-- Executing [s@macro-user-callerid:3] GotoIf("Local/2028@from-queue-0002c416;2", "1?report") in new stack
-- Executing [s@macro-user-callerid:15] GotoIf("Local/2028@from-queue-0002c416;2", "0?continue") in new stack
-- Executing [s@macro-user-callerid:16] ExecIf("Local/2028@from-queue-0002c416;2", "1?Set(__CALLEE_ACCOUNCODE=)") in new stack
-- Executing [s@macro-user-callerid:17] Set("Local/2028@from-queue-0002c416;2", "__TTL=0") in new stack
-- Executing [s@macro-user-callerid:18] GotoIf("Local/2028@from-queue-0002c416;2", "0?continue") in new stack
-- Executing [s@macro-user-callerid:19] Wait("Local/2028@from-queue-0002c416;2", "21") in new stack
-- Executing [s@macro-user-callerid:20] Answer("Local/2028@from-queue-0002c416;2", "") in new stack

Other queues TTL does return with a value greater then 0 and the call gets processed.

Regards

I seam to have identified the problem, the calls to the queues not getting processed in the queue are related to calls being transferred to the queue, the original channel has the variable TTL set which causes the ${IF($[“foo${TTL}” = “foo”] to not match and it process $[ ${TTL} - 1 ] then after specific amount of transfers the TTL reaches 0 and the dial plan doesn’t continue.

1 Like

Definitely a FreePBX bug, that they should have dealt with themselves.