LittleSpace Network Developers
Sign in

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

JavaScript
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:

JavaScript
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 whenUse a bot when
You only need to postThe bot reads messages or answers people
Posts come from somewhere else, like Twitch or a serverYou need commands, reactions or moderation
It’s one channelIt works across channels and communities