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:
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
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:
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}/githubOn 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 event | What's posted |
|---|---|
ping | "Webhook connected", sent once when you add it |
push | The branch and up to 5 commits with links |
pull_request | Opened, reopened, ready for review, merged, closed |
pull_request_review | Approved, changes requested, commented |
issues | Opened, reopened, closed |
issue_comment | New comments on issues and pull requests |
release | Published releases |
workflow_run | Finished GitHub Actions runs: succeeded, failed, cancelled |
create / delete | Branches and tags created or deleted |
star, fork | New 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?
| Webhook | Bot | |
|---|---|---|
| Posts messages | One channel | Anywhere it's allowed |
| Reads messages, reacts, moderates | No | Yes |
| Slash commands | No | Yes |
| Needs your code running | Only when you post | For the gateway, yes |