Can't get webhook to work

Hi guys stumbling along with chatgpt.

Locally linux server ver 16
No sip trunks installed testing using sip mobile apps
I can call 202 from 203 and talk etc
In the freepbx console I can call my n8n webhook
curl -X POST http://192.168.x.x/webhook/mywebhook
This simply send a sms message to confirm.

ChatGPT
setup simple api call on calling ext 202 Step 1: Custom Extensions Using the GUI

  1. Log in to the FreePBX web interface.
  2. Navigate to Admin > Config Edit (this may also be called File Editor or similar, depending on your version of FreePBX). This tool allows you to edit FreePBX configuration files, including extensions_custom.conf. Note that this tool should be used cautiously.
  3. Alternatively, you can create a Custom Destination directly in the GUI:
  • Go to Admin > Custom Destinations:
    • Click Add Custom Destination.
    • Enter the following:
      • Custom Destination: custom-webhook-202,202,1
      • Description: Webhook for Extension 202
      • Return: Leave this as the default option.
      • Return Description: Leave this blank if not needed.

Step 3: Custom Context for Webhook

If you want to implement a custom dialplan that will be called every time the extension 202 is dialed, follow these steps to add the custom dialplan logic:

  1. Navigate back to Admin > Config Edit (or File Editor).
  2. Open the extensions_custom.conf file.
  3. Add the Custom Dialplan:
  • Add something like:
  • text
  • Copy code
  • [custom-webhook-202]
  • exten => 202,1,NoOp(Triggering Webhook for Extension 202)
  • same => n,System(curl -X POST http://192.168.x.x/webhook/mywebhook)
  • same => n,Dial(SIP/202)
  • same => n,Hangup()
  • Save the changes.

Step 1: Verify Dialplan Context Usage

Make sure that the custom context custom-webhook-202 is actually being used by extension 202 in FreePBX. The steps to check and update this are:

  1. Go to FreePBX Web Interface.
  2. Navigate to Applications > Extensions.
  3. Select Extension 202.
  4. Advanced Tab:
  • Look for the context setting. By default, this might be set to something like from-internal.
  • Change it to use your custom context: custom-webhook-202.

If the context for extension 202 is still set to from-internal or another default value, your custom dialplan won’t be executed. Changing it to custom-webhook-202 will ensure that the custom logic is used when extension 202 receives a call.

Great, reloading the dialplan with:

sudo asterisk -rx “dialplan reload”

So each time I get

Spawn extention -(custom-webhook-202, ,1) exited non-zero on PJSIP/202-00000007

I have tried various configurations like

run a script

[custom-webhook-202]
exten => 202,1,NoOp(Triggering Webhook for Extension 202)
same => n,System(/usr/local/bin/test_asterisk_script.sh || true)
same => n,NoOp(After Shell Script Execution)
same => n,Dial(PJSIP/202)
same => n,Hangup()

or simply
[custom-webhook-202]
same => n,System(touch /tmp/test_file_created_by_asterisk)

Anyone have a working script or explain why these are not triggering

You might want to try a simpler approach, first, such as adding a new prefix dialing option that triggers your script - great HOWTO video on this more generic concept by @lgaetz here:

1 Like

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