Webhooks Guide

Learn how to set up and use webhooks for real-time events

Overview

Webhooks allow you to receive real-time notifications when specific events occur. We support webhooks for GitHub events that are forwarded to Discord using the Bot API - no webhook URLs needed!

Available Webhooks

GitHub Webhooks

Receive notifications for GitHub repository events and forward to Discord.

POST /api/webhooks/services/github

Events: push, pull_request, issues, issue_comment, release

Universal Webhook Forwarder

Forward messages to Discord or Slack using the Bot API.

POST /api/webhooks?service=discord

Query params: service=discord|slack, channel=CHANNEL_ID

Dynamic Channel Selection

The webhook system automatically determines where to send messages:

  1. If ?channel=ID is provided in the URL
  2. If DISCORD_CHANNEL_OWNER_REPO env var is set for the repo
  3. Fallback: Bot automatically finds the first text channel in its server

This means you don't need to configure a default channel - just invite the bot and it will work!

Setup GitHub Webhook

  1. Go to your GitHub repository → Settings → Webhooks
  2. Click "Add webhook"
  3. Payload URL: https://yourdomain.com/api/webhooks/services/github
  4. Content type: application/json
  5. Secret: GITHUB_WEBHOOK_SECRET value from your env
  6. Select events you want to receive
  7. Click "Add webhook"

Setup Discord Bot

  1. Go to Discord Developer Portal
  2. Create a new application and add a bot
  3. Copy the bot token and add to env: DISCORD_BOT_TOKEN
  4. Add public key to env: DISCORD_PUBLIC_KEY
  5. Invite the bot to your server with appropriate permissions
  6. Enable "Server Members Intent" in Discord Developer Portal

⚠️ Important URL Configuration

In Discord Developer Portal → Your App → General Information:

  • Interactions Endpoint URL: https://yourdomain.com/api/webhooks/services/discord
  • Linked Roles Verification URL: https://yourdomain.com/api/webhooks/services/discord?interaction_token=...

Per-Repository Channels

You can configure different Discord channels for different GitHub repositories:

# Environment variables format:
DISCORD_CHANNEL_OWNER_REPO=123456789

# Example:
DISCORD_CHANNEL_MYUSER_MYPROJECT=987654321
DISCORD_CHANNEL_OTHERUSER_OTHERPROJECT=555555555

Environment Variables

VariableRequiredDescription
DISCORD_BOT_TOKENYesYour Discord bot token
DISCORD_PUBLIC_KEYYesYour Discord app's public key (from Developer Portal)
GITHUB_WEBHOOK_SECRETYesSecret for GitHub webhook verification
DISCORD_CHANNEL_*NoPer-repo channel mapping (format: OWNER_REPO)

Usage Examples

GitHub → Discord (automatic)

# Just configure GitHub webhook:
Payload URL: https://yoursite.com/api/webhooks/services/github
Secret: (your GITHUB_WEBHOOK_SECRET)

# Bot will auto-forward to Discord!

Manual webhook call

curl -X POST "https://yoursite.com/api/webhooks?service=discord&channel=123456789" \
  -H "Content-Type: application/json" \
  -d '{"content": "Hello from webhook!"}'