Send your application events to Grok Bot routines
- Author:
- hooksnode
- Published:
- Updated:
- webhooks
- grok-bot
Your app already knows when something important happens. A user signs up, an order is paid, a card payment fails, a customer cancels, a support ticket comes in. A Grok Bot routine can do the follow-up work on each of these: draft a welcome note, look into a failed payment, write up the ticket.
A Grok Bot routine can start from a webhook. Each webhook routine has its own URL and its own key, sent as Authorization: Bearer <key>. If your app calls routines directly, it has to store every routine's URL and key, decide which event goes to which routine, and retry when a call fails.
Hooksnode takes that work off your app. Your app sends every event to one Hooksnode URL. Hooksnode sends each event to the routines and services that want it, adds each routine's key, retries failed deliveries and keeps a log of every attempt.
The setup
your app --POST user.signed_up / order.paid / payment.failed / ...-->
https://hooksnode.com/p/<source-id> (checks your signature)
|
+--> Grok Bot routine "Onboarding note" filter: user.signed_up
| + Authorization: Bearer <key A>
|
+--> Grok Bot routine "Failed payments" filter: payment.failed
| + Authorization: Bearer <key B>
|
+--> your analytics or CRM service no filter, gets everything
+ X-Hooksnode-Signature
Your app knows one URL and one signing secret. It doesn't know which routines exist, what their keys are, or whether one of them is down.
What each side does
| What happens | |
|---|---|
| Your app | Signs the JSON body with the source secret and POSTs it to the source URL. Hooksnode answers fast, so your request handler isn't held up by the routines. |
| Hooksnode, inbound | Refuses an unsigned or wrongly signed request with 401. Stores the body byte for byte (up to 4 MiB). |
| Hooksnode, routing | Each destination has an optional filter on body fields, such as {"type": "payment.failed"}, and an optional transform that reshapes the body for that destination only. |
| Hooksnode, routine auth | Each destination has Extra headers. Put Authorization: Bearer <routine key> there. Hooksnode never forwards an Authorization header from your request, so each routine gets only its own key. |
| Hooksnode, delivery | Up to 25 delivery attempts in total for each destination, with waits that grow and never go over 1 hour (about 17.5 hours for all 25). Each attempt waits up to 15 seconds. Each destination retries on its own, so one failing routine doesn't hold up the others. |
| Hooksnode, after failure | A delivery that used all its attempts is dead. Retry it from the event page, the Needs retry view, or the API. Replay sends an old event again, to every active destination or to one. |
| Grok Bot | A 200 means Grok Bot accepted the call and started a run, not that the run is done. The run gets the body together with the routine's instruction. |
Delivery is at least once, never exactly once. Hooksnode adds no idempotency key when it delivers. Put your own event ID in every event and have each routine and service check it (see Handle duplicates below).
Step 1: Design your events
Send one JSON object per event, with a type field to route on and your own unique ID:
{
"id": "evt_01JD8X2K4M",
"type": "user.signed_up",
"occurred_at": "2026-11-25T09:14:03Z",
"data": {
"user_id": "usr_8812",
"email": "ada@example.com",
"plan": "free",
"signup_source": "mobile"
}
}
Other events use the same shape: order.paid, payment.failed, subscription.cancelled, ticket.created. Hooksnode doesn't need any of these names. They only have to match the filters you write.
Send only the data the routines need. A routine reads what you send it, so leave out anything it shouldn't see.
Step 2: Create a Hooksnode source and turn on signing
- Create a project in Hooksnode. Its webhook source has a URL like
https://hooksnode.com/p/<source-id>. - Open the source and turn on Signing. Hooksnode makes a secret.
- Put the secret in your app's environment, for example
HOOKSNODE_SOURCE_SECRET.
Turn signing on. Without it, anyone who learns the source URL can send events to it, and those events would wake your routines.
Step 3: Sign and send events from your app
Compute an HMAC SHA256 of the exact body bytes you send, keyed with the source secret. Send it as X-Webhook-Signature: sha256=<hex>. Sign the same string you put on the wire. Don't re-serialise the JSON after signing.
Node.js
import crypto from "node:crypto";
const SOURCE_URL = process.env.HOOKSNODE_SOURCE_URL; // https://hooksnode.com/p/<source-id>
const SECRET = process.env.HOOKSNODE_SOURCE_SECRET;
export async function sendEvent(type, data) {
const body = JSON.stringify({
id: `evt_${crypto.randomUUID()}`,
type,
occurred_at: new Date().toISOString(),
data,
});
const sig = crypto.createHmac("sha256", SECRET).update(body).digest("hex");
const res = await fetch(SOURCE_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Webhook-Signature": `sha256=${sig}`,
},
body,
});
// 200 accepted, 202 held: Hooksnode has the event. Don't resend it.
if (res.status === 200 || res.status === 202) return;
// 429 and 5xx: try again later, after Retry-After.
throw new Error(`hooksnode answered ${res.status}`);
}
await sendEvent("user.signed_up", { user_id: "usr_8812", email: "ada@example.com", plan: "free" });
Python
import hashlib
import hmac
import json
import os
import uuid
from datetime import datetime, timezone
import requests
SOURCE_URL = os.environ["HOOKSNODE_SOURCE_URL"]
SECRET = os.environ["HOOKSNODE_SOURCE_SECRET"].encode()
def send_event(event_type: str, data: dict) -> None:
body = json.dumps({
"id": f"evt_{uuid.uuid4()}",
"type": event_type,
"occurred_at": datetime.now(timezone.utc).isoformat(),
"data": data,
}).encode()
sig = hmac.new(SECRET, body, hashlib.sha256).hexdigest()
res = requests.post(
SOURCE_URL,
data=body,
headers={
"Content-Type": "application/json",
"X-Webhook-Signature": f"sha256={sig}",
},
timeout=10,
)
# 200 accepted, 202 held: Hooksnode has the event. Don't resend it.
if res.status_code in (200, 202):
return
# 429 and 5xx: try again later, after Retry-After.
raise RuntimeError(f"hooksnode answered {res.status_code}")
send_event("payment.failed", {"order_id": "ord_5521", "amount_kobo": 1250000, "reason": "insufficient_funds"})
Test the signature with curl before you wire up your app:
BODY='{"id":"evt_test_1","type":"user.signed_up","data":{"user_id":"usr_test"}}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.* //')
curl -X POST https://hooksnode.com/p/<source-id> \
-H "Content-Type: application/json" \
-H "X-Webhook-Signature: sha256=$SIG" \
-d "$BODY"
A missing or wrong signature gets 401.
What Hooksnode answers
| Status | Meaning | What your app should do |
|---|---|---|
200 accepted |
Stored and queued for delivery | Nothing |
200 duplicate |
Hooksnode already has this exact request | Nothing |
202 held |
Your workspace is out of credits. The event is kept and delivered once you add credits | Don't resend. Add credits |
401 |
Wrong or missing signature | Check the secret and that you signed the exact body |
402 |
Nothing was stored. The hold is full, or the body is too large to hold | Add credits if the hold is full, or send a smaller body, then resend |
429 |
Over the source rate limit | Wait for Retry-After (60 seconds), then resend |
503 |
A short outage at Hooksnode | Resend after Retry-After |
Your app still needs a small retry for 429, 503 and network errors on this one call. That's the only retry it needs. Everything after Hooksnode accepts the event is Hooksnode's job.
Step 4: Create the Grok Bot routines
Create one routine per job, each with a webhook trigger. Open each routine on desktop. The Webhook section shows POST to (the URL), key (the secret) and header (the full Authorization: Bearer ... line). You'll paste the URL and key into Hooksnode in the next step, and nowhere else.
Write each instruction for the body it will get, and put the duplicate check first. Three examples:
Onboarding note (event user.signed_up):
When a webhook wakes you, read the event in the body. Act only if
typeisuser.signed_up. First check whether you already handled this eventid; if you did, stop. Then draft a short, friendly welcome note for this user based on their plan and signup source, and post the draft in this chat for me to review. Don't send it to the user.
Failed payments (event payment.failed):
When a webhook wakes you, read the event in the body. Act only if
typeispayment.failed. First check whether you already handled this eventid; if you did, stop. Look up the order, group the failure under the reason given (for example insufficient funds or a bank decline), and post a one-line triage note in this chat with the order ID, the amount in naira and a suggested next step. Never contact the customer.
Daily digest. A webhook wakes a routine once per event, and Hooksnode delivers each event when it arrives. Neither one batches events into a daily summary. For a digest, use a scheduled Grok Bot routine (for example every weekday at 9:00) and have it read the day's events from a place you control. The simplest way: add your own service as a Hooksnode destination that saves each event, and have the scheduled routine read from it.
Step 5: Add each routine as a Hooksnode destination
For each routine, open Destinations → Add destination:
- Name:
Grok Bot: Onboarding note - URL: the routine's POST to URL
- Extra headers:
{
"Authorization": "Bearer <routine key>"
}
- Filter:
{ "type": "user.signed_up" }
Do the same for the failed payments routine with { "type": "payment.failed" }. A filter can list several values, such as { "type": ["payment.failed", "subscription.cancelled"] }, if one routine should handle both.
Filters match exact values only. There is no "greater than" or "contains". Put rules like "only orders above a certain amount" in the routine's instruction instead.
Hooksnode masks the Authorization value in event search and exports.
Optional: trim the body for a routine
A transform reshapes the body for one destination. Use it to send a routine fewer fields:
{
"id": {{printf "%q" .id}},
"type": {{printf "%q" .type}},
"user_id": {{printf "%q" .data.user_id}},
"plan": {{printf "%q" .data.plan}}
}
Hooksnode runs the transform first, then the filter. Keep type in the output, or the filter stops matching. Use the Test panel in the destination editor to try a transform and filter on a sample body. Nothing is sent.
Step 6: Add your other services
Any HTTPS endpoint can be a destination too: your CRM sync, analytics, a data warehouse loader, the store your digest routine reads from. Turn on Signing for each one. Hooksnode then adds X-Hooksnode-Signature, either sha256=<hex> (an HMAC SHA256 of the delivered body) or a timestamped t=<unix>,v1=<hex> format, and your service checks it with its own secret. The signing docs have Node.js, Python, Go and PHP code.
Step 7: Test it
Send a test event with the curl command above, then check:
- The Hooksnode event page shows the event, with a delivery to each destination. Destinations whose filter didn't match show
deliveredwith status0and{"filtered":true}. - Each Grok Bot destination's attempt shows
200. - The Bot's chat shows each run's result.
Handle duplicates
Delivery is at least once, never exactly once. A routine or service can get the same event twice, for example when it did the work but answered too late.
- Use your own event
id. Hooksnode adds no idempotency key when it delivers. Theidin your body is the key. - Services: store the
idin a table with a unique constraint, in the same transaction as the work. If it's already there, answer200and stop. - Routines: each run starts fresh and doesn't remember earlier runs. Give the routine somewhere to check, such as your own backend or a sheet it can read, and keep the check first in the instruction.
On the way in, a signed source drops an exact resend (same body, same signature) within 10 minutes. With signing on, Hooksnode ignores the X-Idempotency-Key header. If your app resends after a timeout, send the exact same bytes and signature so this check can catch it. Rebuilding the body with a new timestamp makes it a new event.
Change routines without touching your app
- New routine key. Paste it into that destination's extra headers. Each attempt reads the destination's current headers, so retries still waiting use the new key.
- New routine, or a new routine URL. Update or add the destination. Retries still queued for an old URL stop when the URL changes. Use Replay to one destination for events the new routine should still get.
- Send an old event to a new routine. Add the destination, open the event in Hooksnode and use Replay to one destination. Good for testing a new instruction on real data.
- Pause a routine. A paused routine doesn't answer
200, so Hooksnode keeps retrying for about 17.5 hours. Resume within that time and the events arrive. After that, retry thedeaddeliveries from Needs retry.
Your app's code doesn't change in any of these cases.
Watch your routine usage
Every routine run spends Grok Bot usage. Grok Bot also limits runs: up to 200 an hour for each routine and 300 an hour across all your routines. A burst of signups can pass that.
- Filter each routine down to the events it really needs.
- Send high-volume events (page views, logins) only to your own services, never to a routine.
- For events that come in bursts, a scheduled digest routine is cheaper than one run per event.
Payment gateway events
If the events come from Paystack, Flutterwave or Stripe rather than your own app, the setup is the same, except Hooksnode checks the provider's own signature with a preset. See Send Paystack webhooks to a Grok Bot routine. For the general pattern, see Payment gateway webhooks: send one event to many services.
Our own team uses the same pattern for a tool whose webhooks can't add auth headers. GlitchTip alerts go to a Hooksnode source, and Hooksnode forwards them, signed with a timestamped X-Hooksnode-Signature, to our engineering bot's wake routine, which checks the signature, so GlitchTip never holds a password or token. The full setup is in A real setup: GlitchTip alerts waking an engineering bot.
Credits and plans
Each event Hooksnode receives uses one credit, however many destinations it goes to. Each retry or replay you start uses one credit. A project Free plan is $0 a month with 100,000 credits, 1 source and up to 5 destinations. A project Pro plan is $10 a month with 1,000,000 credits, up to 10 sources and up to 50 destinations. Both are hard caps. See pricing.
FAQ
Why not call the routine URLs straight from my app? You can. Then your app stores every routine's key, retries each call itself and keeps its own log. With Hooksnode, your app knows one URL and one secret, and adding or changing a routine is a dashboard change.
Does my app wait for the routine to finish? No. Hooksnode answers your app once it has stored the event. Grok Bot answers Hooksnode once a run has started. The run's result shows up in the Bot's chat.
Can one event go to several routines? Yes. Add a destination for each routine. With no filter, or a filter that matches, each one gets its own copy and its own retries.