Skip to content

Presses and private cards

A press reaches the code for its action. Here a slot machine only its player sees, which spins when they pull:

A press is a method too, marked with [Press] and named by its action:

using Woosh.Wisp;
public sealed class Slots(Chips chips)
{
[Command("slots", "A machine only you can see")]
public Task Sit(CommandRun run) =>
run.AnswerPrivatelyAsync(Machine("❔ ❔ ❔").Button("pull", "Pull"));
[Press("pull")]
public async Task Pull(Press press)
{
// A frame while it spins.
await press.ShowPrivatelyAsync(Machine("πŸŒ€ πŸŒ€ πŸŒ€"));
var reels = chips.Spin(press.User.Id);
var again = Machine(reels).Button("pull", "Pull again");
await press.UpdateAsync(reels, again);
}
private static Card Machine(string reels) =>
new Card("#a855f7").Title("Your slots").Text(reels);
}

A press is answered once, within 15 seconds, like a run. Until then the button shows that your wisp is on it, and a second click of it does nothing.

Answer Shows
press.UpdateAsync(text?, card or patch) the pressed card changes in place; words left out are written again from the new card
press.UpdateAsync(text) words alone: a line changes its words and keeps its card; a private card becomes the words
press.AnswerAsync(text, card?), press.AnswerAsync(card) a new line, as a reply to the pressed one
press.AnswerPrivatelyAsync(text, card?), press.AnswerPrivatelyAsync(card) a private answer to the person who pressed
press.ShowAsync(card or patch) a live frame on the pressed line while you work, kept nowhere
press.ShowPrivatelyAsync(card) the same on a private card, always a whole card
press.AskAsync(form) a form for the person to fill in

press.User is who pressed, press.Action which action, and press.Value the value you put on the button or cell (up to 100 bytes), or the choice picked from a menu.

A game can keep its state in its own card that way and stay stateless. One handler can take several actions, with the press saying which:

public sealed class Blackjack(Table table)
{
[Press("hit"), Press("stand")]
public Task Play(Press press)
{
var player = press.User.Id;
var hand = press.Action == "hit"
? table.Hit(player)
: table.Stand(player);
return press.UpdateAsync(hand);
}
}

Without attributes: wisp.OnPress("pull", press => ...).

A card answered privately is for its person alone, and a press on it moves it on for them alone. It is the way to show one person something: a hand of cards, a balance, a settings menu. Woosh keeps a private card nowhere: it shows in the apps the person has open, until they dismiss it or close the app.

A card in the channel looks the same to everyone. To show each person something different, answer each one privately.

A tally is a button Woosh counts by itself: one press per person, and a second press takes it back. The count shows on the card for everyone, and it costs your wisp nothing, however many press. It is the button for giveaways, polls and sign-ups.

var line = await wisp.SendAsync(channel, new Card()
.Title("Win a monitor")
.Tally("enter", "Enter", Tone.Accent));

When you want to know who is in, read them, or let Woosh draw winners at random:

var entered = await wisp.TallyAsync(line, "enter").CountAsync();
IReadOnlyList<Guid> winners = await wisp.DrawAsync(line, "enter", 3);

A draw picks afresh each time, so keep the winners it gave you. To hear each press as it comes, add the tally with tell: true, and your press handler gets it, saying whether it counted the person or took them back (press.Counted; in TypeScript, press.counted).


Writing your own library? The frames underneath are in Presses and private cards, raw.

Β© 2026 Woosh AS. All rights reserved.