Introduction
A wisp is a bot for Woosh servers. People type its commands after a /, press the buttons on
its cards and fill in its forms. You write it in C# with the Woosh.Wisp library or in TypeScript
with @woosh-no/wisp, run it wherever you like, and a server’s admin adds it with one link.
This is a whole command, with a card for its answer:
using Woosh.Wisp;
public sealed class Slots{ private static readonly string[] Reels = ["🍒", "🍋", "🔔", "💎"];
[Command("spin", "Spin the reels")] public Task Spin(CommandRun run) { string[] spin = [Pick(), Pick(), Pick()]; var won = spin.Distinct().Count() == 1; return run.AnswerAsync(new Card("#f97316") .Title($"{run.User} spins") .Row(spin.Select(Cell.Emoji)) .Text(won ? "Jackpot!" : "No win this time.")); }
private static string Pick() => Reels[Random.Shared.Next(Reels.Length)];}import { card, grid, text, title, type Wisp } from "@woosh-no/wisp";
const reels = ["🍒", "🍋", "🔔", "💎"];const pick = () => reels[Math.floor(Math.random() * reels.length)]!;
export function slots(wisp: Wisp) { wisp.command("spin", "Spin the reels", async (run) => { const spin = [pick(), pick(), pick()]; const won = new Set(spin).size === 1; await run.answer(card({ color: "#f97316", blocks: [ title(`${run.user} spins`), grid([spin.map((emoji) => ({ emoji }))]), text(won ? "Jackpot!" : "No win this time."), ], })); });}Someone types /spin in their server, and the card appears in the channel, drawn by Woosh in
every app, on desktop, web and phone, in every theme.
What the library does for you
Section titled “What the library does for you”You write what your wisp does. The library does the rest:
- Connecting and staying connected. It signs in with your wisp’s id and secret, keeps one connection to Woosh open, and comes back after a drop without missing anything said meanwhile.
- Commands from your code. A command is declared beside the code that answers it. Your wisp tells Woosh about its commands each time it starts, so there is nothing to set up anywhere else.
- Mistakes caught early. A command, card or form that breaks one of Woosh’s rules is a build error, a type error or an exception where you wrote it, in plain words, before anything is sent.
- Speed limits handled. Every call is paced to the limits Woosh gives your wisp, and calls to one channel stay in the order you made them.
What a wisp can do
Section titled “What a wisp can do”- Offer commands, and answer each one in the channel or privately to the person who ran it.
- Post cards with words, fields, grids of emoji or pictures, progress bars, buttons, menus and pages, and change them in place as people press them.
- Ask people to fill in a form: a poll’s question, a giveaway’s prize, a reason for a report.
- Hear what happens in a server: people joining, roles changing, lines posted, each only if the server’s admin allows it.
- Act in a server: post, edit, react, give roles, kick and ban, with the permissions an admin gave it.
A wisp never speaks in voice, never starts a DM, never sees a line before it is posted, and never opens anything a person did not ask for. A server’s admins approve everything it may do, and can change that or remove it at any time (How a server lets it in).
Three steps to your first wisp
Section titled “Three steps to your first wisp”- Make it at developer.woosh.no: a name and what it asks for. You get its id and secret, and set its picture on its page.
- Add it to a server you run, with the install link the portal gives you.
- Run it:
dotnet add package Woosh.Wisp, a few lines of C#, anddotnet run; ornpm install @woosh-no/wisp, a few lines of TypeScript, andnode wisp.ts.
The quick start takes you through all three in about ten minutes.
Woosh for developers
Section titled “Woosh for developers”| docs.woosh.no | You are here: how to build a wisp |
| developer.woosh.no | Make your wisps and look after them: their name, picture, what they ask for, their secret |
| wisp.woosh.no | Where people find wisps and add them to their servers. List yours there when it is ready |
Writing a library of your own, in another language? Everything the library does is in the raw protocol.