Webhooks
Webhooks let you automatically trigger actions on other services when something happens with your comments. The most common use case is triggering a site rebuild when a new comment is submitted.
What Are Webhooks?
Section titled “What Are Webhooks?”A webhook is a way for JamComments to send a message to another service when a specific event occurs. Instead of that service constantly asking “any new comments?” (polling), JamComments proactively says “hey, a new comment was just submitted!” (pushing).
When Webhooks Fire
Section titled “When Webhooks Fire”Webhooks are triggered when:
- A new comment is submitted on your site
- A comment’s status changes (approved, rejected, etc.)
- You toggle certain settings (like removing branding)
Setting Up a Webhook
Section titled “Setting Up a Webhook”- Go to your site’s settings in the JamComments dashboard
- Scroll to the Webhooks section
- Click Add Webhook
- Enter a name (for your reference) and the URL to call
That’s it! From now on, JamComments will send a POST request to that URL whenever a comment event occurs.
Common Use Cases
Section titled “Common Use Cases”Trigger a Site Rebuild
Section titled “Trigger a Site Rebuild”Most Jamstack hosts let you trigger new builds via a special URL. This means when someone leaves a comment, your site automatically rebuilds and the comment appears without you doing anything.
Vercel:
- Go to your project settings
- Find “Git” → “Deploy Hooks”
- Create a hook and copy the URL
- Paste it into JamComments
Netlify:
- Go to Site settings → Build & deploy → Build hooks
- Create a build hook and copy the URL
- Paste it into JamComments
Cloudflare Pages:
- Go to your project settings
- Find “Builds & deployments” → “Build hooks”
- Create a hook and copy the URL
- Paste it into JamComments
Notify a Slack Channel
Section titled “Notify a Slack Channel”You can send comment notifications to Slack using their incoming webhooks:
- Create a Slack app with incoming webhooks enabled
- Copy the webhook URL
- Paste it into JamComments
- New comments will appear as Slack messages
Call a Custom Endpoint
Section titled “Call a Custom Endpoint”If you have your own server or serverless function, you can have JamComments call it directly. This lets you build custom workflows like:
- Sending custom email notifications
- Updating a database
- Posting to social media
- Running moderation checks
Webhook Payload
Section titled “Webhook Payload”When JamComments calls your webhook URL, it sends a JSON payload with information about what happened:
{ "event": "comment.created", "site": { "domain": "your-site.com", "name": "My Blog" }, "comment": { "id": 123, "content": "Great article!", "author": "Jane Doe", "path": "/posts/my-post", "status": "pending" }}The event field tells you what happened:
comment.created— New comment submittedcomment.approved— Comment was approvedcomment.rejected— Comment was rejected
Testing Webhooks
Section titled “Testing Webhooks”Not sure if your webhook is working? Here are a few ways to test:
- Use a webhook testing service like webhook.site — it gives you a temporary URL that shows exactly what JamComments sends
- Check your hosting provider’s build logs — if using a deploy hook, you should see new builds starting
- Submit a test comment in development mode — webhooks won’t fire in development mode, so use production
Multiple Webhooks
Section titled “Multiple Webhooks”You can create as many webhooks as you need for a single site. Each webhook fires independently, so if one fails, the others still run.
Webhook Reliability
Section titled “Webhook Reliability”JamComments makes a best-effort attempt to deliver webhooks. If your endpoint returns an error (non-2xx status), JamComments may retry a few times but cannot guarantee delivery.
For critical workflows, consider:
- Making your webhook handler idempotent (safe to call multiple times)
- Having a backup plan in case webhooks fail
- Monitoring your endpoint’s availability