1

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

Ble
  • 101
  • 1
  • 12

2 Answers2

-1

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

arheops
  • 15,544
  • 1
  • 21
  • 27
  • Sorry didnt mention that the installation is a FreePBX installation, so it already stores this data in the database, but I need this to be reported to the api at the time of callend – Ble Aug 06 '20 at 15:34
  • So what is the problem? Read it from db and push to API – arheops Aug 07 '20 at 01:14
  • The idea is that this is to be done in real time, something like , select data from this call, how to get "this call" part its my problem – Ble Aug 07 '20 at 13:27
  • CDR is realtime. – arheops Aug 07 '20 at 18:55
-1

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

os11k
  • 1,210
  • 2
  • 13
  • 26
  • Run script instead of CDR backend can result PBX core instability starting at moderate load. There is CDR,CEL,AMI for that. – arheops Aug 07 '20 at 19:23
  • Maybe you are correct, but I personally never had problems with h extension, maybe I was running systems on very low load. Based on what he asked I think he needs a way to push data, not pull, so this solution in my personal opinion suits better him. – os11k Aug 07 '20 at 19:31
  • That just mean your scripts are fast and/or you load is low. Start of AGI is full environment start, i.e it take significant time just to start. After that it do some sql, which can delay too. As result on significant load(above 5 CPS) it can and usually do increased execution time with each new call. Result - your loose your server. h-extension is not designed for run external script. – arheops Aug 07 '20 at 19:43
  • Can you point to official documentation were is explicitly stated that it is not recommended to run scripts in h extension or using hangup handler? I never heard about this. – os11k Aug 07 '20 at 19:48
  • Simplest way test - add sleep(3) in your AGI and run performance test. sure you can shoot in your leg if you want. – arheops Aug 07 '20 at 20:08