Queue GoSub Variables

I wish i could pass a variable from queue gosub to Hangup exten…
in this case ${tsfine} is set on Answer via gosub…

but
same => n,GotoIf($["${tsfine}foo"=“foo”]?:bye)
always evaluates as true…
I wish i could check on Hangup if the call has been answered or not…to fix timestamp…

[Servizio_Utenti]
exten => s,1,NoOp()
same =>n,Queue(test,subQueueConnected)

exten => h,1,NoOp()
same => n,GotoIf($["${tsfine}foo"=“foo”]?:bye)

[subQueueConnected]
exten =>s,1,NoOp()
same => n,Set(__tsfine=${SHELL(/var/scripts/datacheck.sh):0:-1})
same => n,Return()

And why you can’t do it?

I think that’s because he wants to pass it to the hangup extension on the caller’s channel, when the subroutine is run on the agent’s channel.

1 Like

I don’t know…gotoif evaluates as true if call is answered and even if not…$tsfine seems to be zeroed on hangup…
I have to write a timestamp if call is answered or abandoned by caller…in mysql…
In this case the values is written twice on answered…
Is there another way to accomplish this task?

I have understood why…thanks… Can you help me to solve this problem?

Shouldn’t that data already be in your queue log?

ABANDONED calls should be noted there, same with when the call is connected.

Yes but i need to put these values on a Db…how Can i get them for every call?

I only need a variable set on queue’s agent answered…i’m looking for it to set the gotoif…

Store your Queue Logs in your MySQL database?

You can use extconfig to send queue logs to ODBC and connect ODBC to your Mysql Server.

https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration

I had to calculate the average time between call enter Asterisk (so not wait time on queue and stop) and Queue agent answers or caller hangup…

OK?

You can look up the same record in both your CDR and your queue log and do the math.

You will have the start of the call in your CDR as the calldate field, and in your queue log you will have log entries for ENTERQUEUE to tell when your call went into the queue from your dialplan and COMPLETEAGENT/COMPLETECALLER/ABANDON to tell you when the call is finished.

COMPLETEAGENT/COMPLETECALLER/ABANDON also log as part of their data their hold and call times.

Just link the two records on the uniqueid.

1 Like

Is there a queue variable set only in case of caller hangup before agent could answer?

That would be an abandoned call.

Queue subroutine will run on called party’s channel so to achieve what you need you should use variable inheritance and Shared function .

So something like this should work for you
[Servizio_Utenti]
exten => s,1,NoOp()
same =>n,Set(__callerChannel=${CHANNEL})
same =>n,Queue(test,subQueueConnected)

exten => h,1,NoOp()
;;same => n,GotoIf($["${tsfine}foo"=“foo”]?:bye)
same => n,GotoIf($["${SHARED(tsfine,${callerChannel}}foo"=“foo”]?:bye)

[subQueueConnected]
exten =>s,1,NoOp()
;;same => n,Set(__tsfine=${SHELL(/var/scripts/datacheck.sh):0:-1})
same => n,Set(SHARED(tsfine,${callerChannel})=${SHELL(/var/scripts/datacheck.sh):0:-1})
same => n,Return()

–Satish Barot

1 Like

Thanks…i have got almost the same solution…

but i have to write to Mysql the variable (such as uniqueid value) on answer…

Back from Gosub even with double underscore…the variable zeroed…so i have to use the db…

On queue Gosub i’m writing on the DB the values…(when call ha been answered)

On Hangup i’m checking via func_odbc for variable presence…if yes…bye…if not (call not answered) i’ll write on DB the values i need

In these two scenario i’ve got time spent by caller on queue from call Answer by IVR…to queue pickup the call or caller abandon…

At whatever point you can set a variable to the internal db in asterisk Set(DB(myfamily/mykey)=something), then in your hangup handler you retrieve the var and using the func_odbc or in the easiest way by adding a column in your DB called “mytime”(to say something) just SET(CDR(mytime)=${DB(myfamily/mykey)})

1 Like