Send and Receive Webhooks with Django (Reference)
Using Ngrok
- setup ngrok on your machine
- tunnel your port to ngrok to make it publicly available (put your local host on the internet)
./ngrok http 8000
- ngrok will then provide a publicly available url that fowards to your localhost(reverse proxy)
http://83d4-169-255-125-200.ngrok.io -> http://localhost:8000
- Provide your webhook URL
http://83d4-169-255-125-200.ngrok.io/hook/process/
to whoever will be sending you webhooks - The logic on /hook/process should then parse the event and do with it as you have commanded.
Sending webhook events is pretty much straightfoward.
- Receive the destination webhook URL
- Get the data ready
- Call the
http://localhost:8000/hook/send/
endpoint with the data
curl -X POST http://localhost:8000/hook/send/ -d '{"foo": "bar"}'