# Connecting GitHub notifications to Discord or Slack in less than 5 minutes with microfn
Table of Contents
In today’s guide we’ll hook GitHub repository events into Discord (or Slack) using microfn.
It only takes a few minutes to capture GitHub webhooks in a function and relay the highlights to the chat channel your team actually watches.
1. Create a microfn account
If you don’t have one yet, head to https://microfn.dev. Sign up for free—no credit card required.
2. Create a new function
Tap the “+” button in the top-left to create a function. Give it a descriptive name like github-notifier
, or fork an existing notifier if you already have one in your workspace.
After saving, open the Triggers tab and copy the webhook URL. It looks like https://microfn.dev/run/:username/:functionName
.

3. Connect the function to GitHub
In GitHub, open the repository you want to monitor and navigate to Settings → Webhooks. Paste the microfn URL into the webhook target field (https://microfn.dev/run/:username/:functionName
) and keep the default application/json
content type.
Choose the events you care about (start with “Just the push event” if you’re not sure), then hit Add webhook.
4. Check the GitHub webhook that arrived at your function
Head back to microfn, select your function, and open the Executions tab. You should see the incoming GitHub webhook, complete with its JSON payload.

Click Replay to resend the event while you iterate and add downstream actions.
5. Forward alerts to Discord or Slack
Use the webhook payload to craft a message, then hand it off to a reusable notifier function.
import fn from '@microfn/fn';
export async function main(input) { const payload = input.body ?? input; const repo = payload.repository?.full_name ?? 'unknown-repo'; const actor = payload.sender?.login ?? 'someone'; const branch = payload.ref?.split('/')?.at(-1) ?? 'main'; const commits = (payload.commits ?? []) .map((commit) => `• ${commit.message}`) .join('\n');
const message = `🔔 ${actor} pushed to ${repo}/${branch}` + (commits ? `\n${commits}` : '');
await fn.executeFunction('david/send-discord-message', { channelId: process.env.DISCORD_CHANNEL_ID, content: message });
return { status: 'delivered' };}
Store DISCORD_CHANNEL_ID
as a secret or environment variable in microfn. When a push arrives, the helper function handles Discord authentication and posting.
Need the helper? You can fork david/send-discord-message, or drop in the implementation below:
import secret from '@microfn/secret';
export async function main(input) { const token = await secret.getRequired('DISCORD_BOT_TOKEN');
let actualInput = input; if (actualInput.input) { actualInput = actualInput.input; }
const { channelId, content } = actualInput;
const response = await fetch( `https://discord.com/api/v10/channels/${channelId}/messages`, { method: 'POST', headers: { Authorization: `Bot ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ content }) } );
const data = await response.json(); if (!response.ok) { throw new Error( `Discord API error: ${response.status} ${JSON.stringify(data)}` ); }
return data;}
Swap in Slack by calling your Slack webhook instead, or branch on the payload to send to both platforms.
Built in microfn, your toolbox for small composable functions
Microfn is a tiny cloud runner for composable JavaScript functions. Write your function, hit save, and microfn deploys it anywhere you need it.
Start for free—no credit card required!