Sending messages
A bot never writes Slack Block Kit or Teams Adaptive Cards. It composes neutral blocks, and the platform adapter renders them.
The builder
import { message } from "@wingman/core";
await conversation.reply(
message("Here is what I found:")
.heading("Deployment")
.fields({ label: "Region", value: "eu" }, { label: "Plan", value: "Pro" })
.divider()
.context("Updated 2 minutes ago")
.button("docs", "Open the docs", { url: "https://example.com" })
.button("ask-a-person", "Talk to a human", { style: "primary" }),
);
reply() accepts a plain string, a builder, or an OutboundMessage literal —
there is no .build() to remember.
Mentioning someone
Use mention() rather than typing @name, which renders identically and
notifies nobody:
import { mention, message } from "@wingman/core";
await conversation.reply(message(`${mention(onCall)} could you take this one?`));
It returns a token that each adapter resolves into that platform's own form
while rendering. Mentions on an inbound message are on
event.message.mentions. See Mentions and direct messages.
The block vocabulary
| Block | Method | Notes |
|---|---|---|
| text | .text(markdown) |
A Markdown paragraph. |
| heading | .heading(text) |
Bold title line. |
| context | .context(text) |
De-emphasised footnote. |
| divider | .divider() |
Horizontal rule. |
| code | .code(text, lang?) |
Preformatted block. |
| fields | .fields(...) |
Label/value definition list. |
| image | .image(url, alt?) |
Absolute https URL. |
| triggers | .button(...), .select(...) |
Interactive controls. |
Text is Markdown. Each adapter converts it to its own dialect — Slack's
mrkdwn, for instance, where *x* means bold and links are <url|label>.
Buttons and selects
Consecutive .button() calls collapse into one row; .newTriggerRow() starts a
second. A button with a url is a link and produces no event. A button without
one produces a trigger event carrying its id and value:
message("Pick a plan").button("plan:starter", "Starter", { value: "starter" })
async onTrigger(event, conversation) {
if (event.triggerId === "plan:starter") await conversation.reply("Good choice.");
}
Namespace trigger ids (menu:pricing, refund:approve) so unrelated flows never
collide.
Threads, ephemeral messages and edits
await conversation.replyInThread("Working on it…"); // starts or continues a thread
await conversation.replyEphemeral("Only you see this");
await conversation.replyPrivately("Only you see this, on any platform");
const sent = await conversation.reply("Thinking…");
await conversation.update(sent.ref, "Here is the answer.");
replyInThread degrades to a normal reply where threads are unsupported.
replyEphemeral and update throw UnsupportedCapabilityError instead —
check Capabilities first when you need to degrade.
replyPrivately is the one that degrades on its own: ephemeral, else a direct
message, else the conversation. It returns { via, private }, and private is
false when only the public route was left — so a bot can decide not to say
something rather than say it in front of everybody.
Related: Capabilities, Handling events.