Quick start
By the end of this page your wisp answers /spin in your own server with a card. You need a Woosh
account, a server you run (make one in the app if you have none), and for C# the .NET 8 SDK or
later, or for TypeScript Node 22.18 or
later.
1. Make your wisp
Section titled “1. Make your wisp”Go to developer.woosh.no, sign in with your Woosh account and press Make a wisp.
- Name: what people see on its lines, such as
lucky. It is a username, so nobody else, person or wisp, can hold it. - Description: what it does, in a sentence or two. Admins read it before they add your wisp.
- What it does: tick Post and Commands. That is all a wisp that answers commands needs.
Press Make the wisp. Its page shows its id and its secret. Copy the secret now and keep it somewhere safe: Woosh shows it once. Lost or leaked, reset it on the same page.
2. Add it to your server
Section titled “2. Add it to your server”On your wisp’s page, copy its Install link and open it. Woosh shows what your wisp asks for in plain words. Pick your server and press Add to server. Your wisp is now a member there, with the Wisp mark beside its name, offline until it runs.
3. Write it
Section titled “3. Write it”Make a project and add the library:
dotnet new console -n Luckycd Luckydotnet add package Woosh.WispAdd a file, Slots.cs. A command is a method with [Command]:
using Woosh.Wisp;
public sealed class Slots{ private static readonly string[] Reels = ["🍒", "🍋", "🔔", "💎"];
[Command("spin", "Spin the reels")] public Task Spin(CommandRun run, [Option("Coins to bet")] int bet = 10) { string[] spin = [Pick(), Pick(), Pick()]; var won = spin.Distinct().Count() == 1; var card = new Card(won ? "#22c55e" : "#f97316") .Title($"{run.User} bets {bet}") .Row(spin.Select(Cell.Emoji)); return run.AnswerAsync(won ? card.Text($"Jackpot! {bet * 10} coins.", tone: Tone.Good) : card.Text("No win this time.")); }
private static string Pick() => Reels[Random.Shared.Next(Reels.Length)];}Replace everything in Program.cs with:
using Woosh.Wisp;
// Reads WISP_ID and WISP_SECRET from the environment.await using var wisp = WispClient.FromEnvironment();wisp.AddCommands(new Slots());await wisp.RunAsync(); // until you press Ctrl+CMake a project and add the library:
mkdir luckycd luckynpm init -ynpm pkg set type=modulenpm install @woosh-no/wispAdd a file, wisp.ts. A command is a name, a description, its options by name, and what answers
it:
import { Wisp, card, grid, text, title } from "@woosh-no/wisp";
const reels = ["🍒", "🍋", "🔔", "💎"];const pick = () => reels[Math.floor(Math.random() * reels.length)]!;
// Its id and secret come from the environment.const wisp = new Wisp({ id: process.env.WISP_ID!, secret: process.env.WISP_SECRET! });
wisp.command("spin", "Spin the reels", { bet: { kind: "number", description: "Coins to bet" },}, async (run) => { const bet = run.options.bet ?? 10; const spin = [pick(), pick(), pick()]; const won = new Set(spin).size === 1; await run.answer(card({ color: won ? "#22c55e" : "#f97316", blocks: [ title(`${run.user} bets ${bet}`), grid([spin.map((emoji) => ({ emoji }))]), won ? text(`Jackpot! ${bet * 10} coins.`, { tone: "good" }) : text("No win this time."), ], }));});
await wisp.start(); // until you press Ctrl+C4. Run it
Section titled “4. Run it”Give it the id and secret from step 1, and start it:
WISP_ID=<id> WISP_SECRET=<secret> dotnet runIn PowerShell:
$env:WISP_ID="<id>"; $env:WISP_SECRET="<secret>"; dotnet runWISP_ID=<id> WISP_SECRET=<secret> node wisp.tsIn PowerShell:
$env:WISP_ID="<id>"; $env:WISP_SECRET="<secret>"; node wisp.tsYour wisp shows as online in your server.
5. Try it
Section titled “5. Try it”In a channel of your server, type /spin. The picker offers it, with its bet. Run it, and the card
appears in the channel, with your name and “used /spin” above it. Your wisp told Woosh about
/spin itself when it started, so the commands people see are always the ones your code answers.
Keep the secret out of your code and out of your repository. In a real project, keep it in configuration (Hosting your wisp).
- Give the card a button and answer its presses: Presses and private cards.
- Ask people for more than an option holds: Forms.
- React to what happens in the server, such as people joining: Hearing a server.
- Run it for real, with its secret in configuration and its place kept across restarts: Hosting your wisp and Running well.
- When it is ready for other servers, list it on wisp.woosh.no from its page at developer.woosh.no.