Pavel L
Pavel L

Reputation: 931

PhpAgi Dial: How to call a callback when callee answers the call

I'm using Asterisk to route calls. The logic of my application is rather complex, therefore I'm using PHPAGI.

I would like to execute Dial command and track several things:

  1. Has the call been answered?
  2. How many time it took for callee to answer the call?
  3. How many time did take the talk?

All I have now is the $agi->exec('Dial', ...) function. The Dial command allows me to specify a macro, that is being called when the callee answers the call. But how can I specify any php callback instead of this? How can I track the answer moment in my phpagi script?

Thank you!

Upvotes: 0

Views: 1121

Answers (1)

arheops
arheops

Reputation: 15247

You can do macro like this

[macro-dial]
exten => s,1,System(/full/path/php_callback_on_answer.php ${ID})

For callback on hangup use h-extension or just parse cdrs in mysql.

You can record in variable time when call started and calculate time before answer.

Upvotes: 1

Related Questions