What you need
Set it up
1
Create a Slack incoming webhook
In Slack, create an app with Incoming Webhooks turned on, add a webhook to the channel you want, and copy its URL. It starts with
https://hooks.slack.com/services/.2
Create an API key
In Settings → API keys, create a key for the brands you want alerts for. It needs the
read:projects and read:visibility scopes, which new keys include. See Authentication.3
Deploy the receiver
Deploy the code below to a host with a public HTTPS URL, and set the environment variables. For example, the receiver’s URL might be
https://alerts.example.com/hooks/quotable.4
Add the webhook endpoint
In Settings → Webhooks, select Add endpoint, enter the receiver’s URL, keep Tracking run finalized checked, and select Add endpoint. Copy the signing secret into
QUOTABLE_WEBHOOK_SECRET and restart the receiver. See Manage endpoints.Code
Test it locally
Quotable only delivers to public HTTPS URLs, but you can test the receiver on your machine by signing a sample event yourself. Start the receiver, then run this script with the sameQUOTABLE_WEBHOOK_SECRET:
send-test-event.mjs
Expected output
After each day’s tracking is scored, the receiver posts this message text. Slack shows:bar_chart: as an emoji and text between asterisks in bold.
Make it production-ready
- Persist deduplication. The in-memory set forgets everything on restart. Store event ids in your database with a unique index, and insert before you process.
- Use a queue for the work. Hand the event to a job queue instead of processing it in the request process, so a crash doesn’t lose it.
- Expect re-scored days. A day can be scored more than once. Each
tracking.run.finalizedcarries the latest score, so post an update, or edit the earlier message, rather than treating it as a new day. - Watch the delivery log. If the receiver is down for more than about a day and a half, deliveries go dead. Redeliver them from Settings → Webhooks once it’s back. See Delivery and retries.