Bafflux Docs Developer Portal

Building bots

Webhooks

Post into a channel from anywhere with one URL, no bot needed.

A webhook is a secret URL that posts messages into one channel. It's the simplest way to send things like build results, alerts or feed updates into Bafflux: no token, no gateway, no code running all the time.

Making one

In a server, open the channel's settings (the gear next to it), go to Integrations and press Create Webhook. Name it and copy its URL. You need Manage Webhooks in that channel.

Bots with Manage Webhooks can make them too:

http
POST /api/channels/{channelId}/webhooks
{ "name": "Deploys" }

GET /api/channels/{channelId}/webhooks lists them (with their URLs), PATCH /api/webhooks/{id} renames one and DELETE removes it. Up to 15 per channel.

Posting

bash
curl -X POST "https://bafflux.com/api/webhooks/103760000000000000/9c2f...e1" \
  -H "Content-Type: application/json" \
  -d '{"content": "Deploy finished: **v1.4.2** is live"}'

The message appears under the webhook's name with the BOT tag. Formatting and mentions work as in Messages. Webhooks can post 5 messages every 5 seconds.

Add up to 10 embeds next to (or instead of) content:

bash
curl -X POST "https://bafflux.com/api/webhooks/103760000000000000/9c2f...e1" \
  -H "Content-Type: application/json" \
  -d '{"embeds": [{"title": "Deploy finished", "description": "**v1.4.2** is live", "color": 3065014, "fields": [{"name": "Duration", "value": "2m 14s", "inline": true}]}]}'

Per-message username and avatar_url overrides aren't supported: rename the webhook instead.

Anyone with the URL can post as the webhook, so treat it like a password. If it leaks, delete the webhook and make a new one.

GitHub

Add /github to the end of a webhook URL and give it to GitHub, and the repository's activity shows up in the channel as embeds, like Discord's GitHub webhooks:

https://bafflux.com/api/webhooks/{webhook.id}/{webhook.token}/github

On GitHub, open the repository (or the organization, for every repository) and go to Settings > Webhooks > Add webhook. Paste the URL as the Payload URL, set Content type to application/json (application/x-www-form-urlencoded works too), leave Secret empty, and pick the events you want.

GitHub eventWhat's posted
ping"Webhook connected", sent once when you add it
pushThe branch and up to 5 commits with links
pull_requestOpened, reopened, ready for review, merged, closed
pull_request_reviewApproved, changes requested, commented
issuesOpened, reopened, closed
issue_commentNew comments on issues and pull requests
releasePublished releases
workflow_runFinished GitHub Actions runs: succeeded, failed, cancelled
create / deleteBranches and tags created or deleted
star, forkNew stars and forks

Other events and actions are accepted (204) without posting anything. Posts use the webhook's own name and picture, so name it something like "GitHub".

Webhooks or a bot?

WebhookBot
Posts messagesOne channelAnywhere it's allowed
Reads messages, reacts, moderatesNoYes
Slash commandsNoYes
Needs your code runningOnly when you postFor the gateway, yes