Getting the ring time and anwered time of the extension in the queue

hello guys, i’m new here. There is a customer service application I am currently working on. I am using asterisk 18.20.0 and mysql 8. I created a plan by reviewing the documents and the forum.

1-The customer makes a call to the switchboard.
2-The incoming call is answered and directed to an agi script for IVR processing.
3-If the customer wants to connect to the customer representative, he is directed to the queue with the goto function from the network.
4-Connection responses from the customers are expected and added to the CDR as a result of this event. and when the call is finished my another agi script runs to save the cdr summary to another table but here billsec gives asterisk as ringtime + answeredtime.

The plot goes like this. What I want to do here is to obtain the real billsec value when the customer opens an extension from the queue, because it is recorded in the cdr along with the ringtime and response time. As far as I understand, I think this problem is because I answered the first call. Below is the extensions.conf file content;

[fid10-external]
exten => 08xxxxxxxxx,1,Answer()
same => n,Set(callDurationTime=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
same => n,AGI(custom-ivr.php)

exten => 08xxxxxxxxx,4,Set(callStartTime=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
same => n,ResetCdr()
same => n,Set(RecDIR=/var/lib/asterisk/agi-bin/records/call-${callStartTime}-${UNIQUEID}.wav)
same => n,MixMonitor(${RecDIR},b)
same => n,Queue(standart,20)
same => n,Set(testTime=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
same => n,GotoIf($[${QUEUESTATUS} = TIMEOUT]?timeout:hangup)
same => n(timeout),NoOp(All available agents are busy or unavailable)
same => n,Dial(PJSIP/05xxxxxxxxx@mytrunk)
exten => h,1,AGI(call-summary.php)

exten => hangup,1,Hangup()

±--------------------±-----------------------------±------------±------------±---------------±--------±---------------±---------±--------±------------±-----------------------±--------------------±--------------±------------±--------------±----------±--------------------±--------------------+
| calldate | clid | src | dst | dcontext | lastapp | lastdata | duration | billsec | disposition | channel | dstchannel | amaflags | accountcode | uniqueid | userfield | answer | end |
±--------------------±-----------------------------±------------±------------±---------------±--------±---------------±---------±--------±------------±-----------------------±--------------------±--------------±------------±--------------±----------±--------------------±--------------------+
| 2023-12-16 10:32:31 | “905xxxxxxxxxx” <05xxxxxxxxx> | 05xxxxxxxxx | 08xxxxxxxxx | fid10-external | Queue | standart,20 | 15.8025 | 15.8025 | ANSWERED | PJSIP/mytrunk-00000038 | PJSIP/2000-00000039 | DOCUMENTATION | NULL | 1702711929.90 | NULL | 2023-12-16 10:32:31 | 2023-12-16 10:32:47 |
±--------------------±-----------------------------±------------±------------±---------------±--------±---------------±---------±--------±------------±-----------------------±--------------------±--------------±------------±--------------±----------±--------------------±--------------------+

It might seem a bit complicated, as I said, I’m new here. I hope I was able to explain what I wanted to do. Don’t hesitate to ask questions. Kind regards

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.