Set it up
- Add a Webhook node. Set HTTP Method to POST and Respond to Immediately.
- Copy the Production URL and publish the workflow, so the URL answers. The Test URL only listens while you choose Listen for test event.
- In Hyperodds, open Alerts and sign in. Paste the Production URL on the Webhook card and choose Add webhook. The test message shows up in the workflow's Executions.
- Add the nodes that should run after the Webhook node. The alert is under body, so the edge is body.data.edge_pts.
Check the signature
To check signatures, add a Crypto node after the Webhook node: action Hmac, type SHA256, your signing secret, encoding hex, property name expected, and this value:
{{ $json.headers["hyperodds-signature"].split(",")[0].slice(2) }}.{{ JSON.stringify($json.body) }}Then add an If node with this condition, and continue only when it is true:
{{ $json.headers["hyperodds-signature"].split(",").includes("v1=" + $json.expected)
&& Math.abs($now.toSeconds() - Number($json.headers["hyperodds-signature"].split(",")[0].slice(2))) < 300 }}Good to know
JSON.stringify of the body gives back the exact bytes Hyperodds signed, because Hyperodds sends compact JSON.
The URL has to be public and served over HTTPS. A workflow on your own computer needs a tunnel to be reachable.