Webhook on answered call

Hello all FreePBX professionals!

I need a webhook to fire when a inbound call is answered by an extension. The webhook should contain caller ID and extension number either as parameter or as body payload.

I started a trial for the CRM module and created a webhook for inbound calls.
My problem with this solution is that the webhook only is fired two times:

  • First before the call is answered (and then it does ofcource not know whitch extension that is going to answer
  • Second when the call is ended. And that is too late.

Is it possible to configure CRM-link to fire the webhook when the call is answered instead of when it is ended?

Another solution would be to use Superfecta. But Superfecta does not contain data about the extension that answers… So thats a non-working solution.

If there is no possible solution for this via CRM LINK. How can I make a webhook for this in another way? Is is possible to hook in to the dial plan and make a cURL when the incomming call is answered?

There is this method for queue calls only

1 Like

we did something very similar on this:

  1. wrote a simple node.js module to attach to the AMI stream
  2. set it to fire events/webhooks when it sees certain types of messaging.
  • in our case, the most important was to fire off data when it sees a CDR (call completion) towards two of our CRM-Like products.

you could likely do the same, and send your webhook on Answer

your AMI Type might be one of { NewConnectedLine, QueueCallerJoin } depending on your use case.
and of course CDR on call completion.

Thank you so much! This worked very well for me. Very valuable!
I added this line to the extensions_custom.conf stub and it made exactly what I was asking for.

exten => s,n,Set(foo=${CURL(https://domain.com/test?var1=${CHANNEL:6:3}\&var2=${CALLERID(num)})})

sholinaty: thanks for you answer too. I never tried your solution. It sounds a bit more advanced, but I guess work good too.


I have spent my day configuring my CRM to handle this webhook smooth. And guess what happens now when I make a call to my PBX to test before deployment?

Suddenly the variable ${CALLERID(num)} does no longer give me the number that is calling. It gives me the number that is beeing called

I cannot recall changing any settings at all in freepbx since I tried the webhook two days ago and it worked fine. What can be the problem? How can I fix it?

Call trace probably has a clue, share via pastebin:

Thanks. This is the log from one incomming call. You can see the response from my curl request on line 409 (i just return it from my server for debugging).
Im starting to belive that it never worked 2 days ago either. I even tried to set up a new install of freePBX and it is still the same problem

@sholinaty would you mind elaborating your suggestion. I have never worked with either node.js or the AMI-stream before. If Im going this way, can you please point me in the direction where to start?

My last option if I cant solve this myself is to hire someone to do it. I just want to get it done now. Anyone knows if a Sangoma 2hrs support ticket for 390 USD would solve this? Anywere else to buy pro support from?

I found the solution myself. Here’s how I made it!

Step 1
run this in /etc/asterisk/extensions_custom.conf
exten => s,n,DumpChan

Step 2. From output in asterisk logfile (reports -> asterisk logfiles) I found that the incomming number was stored in “ConnectedLineIDNum”

Step 3.
To access “ConnectedLineIDNum” use this variable in dial plan:

1 Like

DumpChan is extremely useful when doing your own dialplan and trying to figure out what FreePBX is doing.


apologies for disappearing. ive been trying to demystify this code.

----see github link —

try this.

you should be able to set up the config.js file with your server details
and run it via

node init.js

at present, its a skeleton of a program, but it Should do the needful for you.


It’s conventional to link to a github repo when sharing code, and all code shared on the forum must have clear license terms.

1 Like

fair enough. i’ll pop it to my github.


I’m not seeing license details. If you don’t know or care about such things you can just use the FreePBX/Asterisk licesnse, GNU GPL3+

1 Like

i thought i’d added a GNU/GPL3 to that repo…
seems it was stuck in my IDE / not committed. its added now

1 Like

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