Webhooks
A webhook is a link that posts messages into one channel. It doesn’t need a bot account or a connection, which makes it a good fit for announcements from another service: a stream going live, a server starting, a new post on a site.
#Make a webhook
In littlespace.chat, open the channel’s settings, go to Webhooks and create one. Copy its URL. Treat it like a password, because anyone with it can post in that channel.
#Post to it
import { executeWebhook } from '@littlespace/fluxkit';
await executeWebhook(process.env.LIVE_WEBHOOK, {
content: 'cigaming is live! 🎮',
embeds: [{
title: 'Cozy Minecraft night',
url: 'https://twitch.tv/cigaming',
color: 0xf5a3d3,
}],
});You can also change the name and picture for just that post:
await executeWebhook(url, { content: 'Storytime in 10 minutes!', username: 'Story Bear' });Webhook posts don’t count against your bot’s rate limit. If Fluxer does ask the webhook to slow down, executeWebhook waits and tries again.
#Webhook or bot?
| Use a webhook when | Use a bot when |
|---|---|
| You only need to post | The bot reads messages or answers people |
| Posts come from somewhere else, like Twitch or a server | You need commands, reactions or moderation |
| It’s one channel | It works across channels and communities |