Make a bot
Webhooks
A webhook is a secret link that posts into one channel. Send it a web request and the message appears, with whatever name and picture you choose. There's no bot account, no token and nothing to keep running.
Good for
- Alerts from your own programs: a build finished, a game server started, a website went down.
- Posting news or updates on a schedule (with a scheduled task or a cron job).
- Quick scripts that post once and end.
Webhooks only post. To read messages or answer people, make a bot.
Make one
- Open the channel's webhooksOpen Channel Settings → Webhooks (or Server Settings → Webhooks to see them all). You need Manage Webhooks.
- Make itPress New Webhook and give it a name. Its posts show that name unless a post picks another one.
- Copy the URLPress Copy URL. It looks like
https://roarnode.com/api/v1/webhooks/<id>/<token>, or…/v1/instances/<node>/http/api/v1/webhooks/…for a node that's reached through the relay.
The URL is the password. Anyone with it can post in the channel. Keep it out of public code and screenshots. If it leaks, delete the webhook and make a new one.
A channel can have up to 15 webhooks. Text, announcement, voice and stage channels can all have them.
Send a message
Send a POST with a JSON body to the URL:
curl -X POST "$ROAR_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{"content": "Hello from a webhook! 👋"}'await fetch(process.env.ROAR_WEBHOOK_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ content: "Hello from a webhook! 👋" }),
});import os, requests
requests.post(os.environ["ROAR_WEBHOOK_URL"], json={"content": "Hello from a webhook! 👋"}).raise_for_status()Invoke-RestMethod -Method Post -Uri $env:ROAR_WEBHOOK_URL -ContentType "application/json" `
-Body (@{ content = "Hello from a webhook! 👋" } | ConvertTo-Json)With Roar.js it's new Webhook(url).send("Hello!"): see the reference.
What you can send
| Field | |
|---|---|
content | The text, up to 4000 characters, with Markdown. Webhooks may ping @everyone. |
embeds | Up to 10 embed cards (about 12 KB in total). The fields are the same as a bot's: Embeds. |
username | The name shown on this post (1–80 characters). |
avatar_url | A picture for this post: an https:// link to an image. |
At least one of content or embeds is needed. The node answers 200 with the message it posted.
{
"username": "Server Monitor",
"avatar_url": "https://example.com/monitor.png",
"content": "Heads up:",
"embeds": [{
"title": "The game server is back",
"description": "It was down for 4 minutes.",
"color": 6281578,
"fields": [{ "name": "Players online", "value": "12", "inline": true }],
"footer": { "text": "checked every minute" }
}]
}In JSON, color is a number: #5fd96a is 0x5fd96a, which is 6281578.
Limits
- Webhooks can't send files yet, and can't edit or delete what they posted.
- Through the relay a request has 25 seconds to finish, and a body can be up to 8 MB.
- Posts from webhooks show a BOT tag, with the webhook's name and picture.