Getting information from asterisk (freepbx) on call end , and passing it to php file

1.5k Views Asked by At

I am trying to pass some call information, to an api-script if the call is answered following variables will be needed:

  1. Caller ID
  2. Time Call Started
  3. Time Call Ended
  4. Total Call Duration
  5. Conclusion type (1= Completed, so the call went through, 2=Aborted )
  6. State (if the call was aborted, the "why" state, busy,no-answer,cancelled,failed,voicemail)

The perfect thing would be to do this in the extension , something like

exten=> X,1,Wait(1)
exten=> X,2,Set(CallerID=${CALLERID(num)})
exten=> X,3,Dial(number)
exten=> X,4,AGI(api.php?var1=callerid etc...)
exten=> X,5,Hangup()

Any idea on how to approach all this would be welcomed, even partially as I read a lot of different google results, but cant figure this out

P.S. The server has FreePBX installed so its not a bare-bone installation.

Thanks in advance

2

There are 2 best solutions below

4
arheops On

Asterisk have odbc storage for cdr (call detail record) data, see

https://wiki.asterisk.org/wiki/display/AST/Getting+Asterisk+Connected+to+MySQL+via+ODBC

5
os11k On

You can try to run your script after hangup - check what is h extension or hangup handlers. I personally prefer in following way:

exten=> X,1,Wait(1)
exten=> X,2,Set(CallerID=${CALLERID(num)})
exten=> X,3,Dial(number)
exten=> X,5,Hangup()
exten=> h,1,AGI(api.php?var1=callerid etc...)

https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

http://the-asterisk-book.com/1.6/besondere-extensions.html