Slaikydocs

    Build an app#messages

    Messages and blocks

    Post as your bot in Markdown, mention people, add blocks, then edit, delete, show a message to one person, react and pin.

    Your bot speaks with chat.postMessage, in the conversations it is a member of. A message is text in Markdown, and it may carry blocks: a header, fields, buttons, a menu, an image.

    Post a message

    chat.postMessage needs chat:write and takes a channel (its id, or "#name" for a channel) and the text. Add threadId to reply in a thread, and alsoInChannel to show that reply in the channel too.

    your app → Slaikypost-message.sh
    curl -s "${SLAIKY_API:-https://app.slaiky.xyz/api/methods}/chat.postMessage" \
      -H "authorization: Bearer $SLAIKY_BOT_TOKEN" \
      -H 'content-type: application/json' \
      -d "{\"channel\": \"${SLAIKY_CHANNEL:-#general}\", \"text\": \"Deploy finished. *All green.*\"}"
    your app → Slaikypost-message.mjs
    // Post a message as your bot. Node 22+, no packages.
    const API = process.env.SLAIKY_API ?? 'https://app.slaiky.xyz/api/methods';
    
    const res = await fetch(`${API}/chat.postMessage`, {
      method: 'POST',
      headers: { authorization: `Bearer ${process.env.SLAIKY_BOT_TOKEN}`, 'content-type': 'application/json' },
      body: JSON.stringify({ channel: process.env.SLAIKY_CHANNEL ?? '#general', text: 'Deploy finished. *All green.*' }),
    });
    const answer = await res.json();
    console.log(JSON.stringify(answer));
    if (!answer.ok) process.exit(1);
    your app → Slaikypost_message.py
    # Post a message as your bot. Python 3, no packages.
    import json, os, urllib.request
    
    API = os.environ.get("SLAIKY_API", "https://app.slaiky.xyz/api/methods")
    TOKEN = os.environ["SLAIKY_BOT_TOKEN"]
    
    
    def call(method, body):
        req = urllib.request.Request(
            f"{API}/{method}",
            data=json.dumps(body).encode(),
            headers={"authorization": f"Bearer {TOKEN}", "content-type": "application/json"},
        )
        try:
            with urllib.request.urlopen(req) as res:
                return json.load(res)
        except urllib.error.HTTPError as err:  # a refusal still answers JSON
            return json.load(err)
    
    
    answer = call("chat.postMessage", {"channel": os.environ.get("SLAIKY_CHANNEL", "#general"), "text": "Deploy finished. *All green.*"})
    print(json.dumps(answer))
    if not answer["ok"]:
        raise SystemExit(f"{answer['error']['code']}: {answer['error']['message']}")

    In a public channel the bot isn’t in, it joins on first use with channels:join (new apps have it); without it, chat:write.public lets it post there. A private channel, a DM or a group DM needs the bot in it first: add it to the channel, or open the DM with conversations.open.

    A thread reply names the thread’s first message. In an event, that is message.parentId, or the message’s own id when it has no parent:

    your app → Slaikychat.postMessage
    { "channel": "7f3c0009-5a1e-4c2b-9d6f-1a2b3c4d5e08", "threadId": "7f3c0007-5a1e-4c2b-9d6f-1a2b3c4d5e06", "text": "Deploy is green." }
    Slaiky → your app
    { "ok": true, "message": { "id": "7f3c0021-5a1e-4c2b-9d6f-1a2b3c4d5e14", "channelId": "7f3c0009-5a1e-4c2b-9d6f-1a2b3c4d5e08", "parentId": "7f3c0007-5a1e-4c2b-9d6f-1a2b3c4d5e06", "body": "Deploy is green.", "blocks": null, "…": "…" } }

    Write in Markdown

    text is Markdown, up to 40000 characters:

    your app → Slaikytext
    **bold**  _italic_  ++underline++  ~~strike~~  `code`
    > a quote
    - a list    1. a numbered list    - [ ] a task
    # A heading    ## Smaller    ### Smaller still
    ---
    [a link](https://example.com)    @alex    #launch    :tada:

    Three backticks on a line of their own start a block of code, and three more end it. Links in a bot’s message show no preview card.

    Mention people

    @handle mentions a person, and they are notified if they can read the conversation. Every payload gives you handles (user.handle, message.author.handle); users.info finds a person by id or @handle. #name links a channel.

    In a channel, @channel and @everyone notify every member, and @here whoever is online. Inside code or a quote, nobody is notified: the mention still shows, it just doesn’t ping. Mentions in the blocks’ text count too.

    Text and blocks

    Blocks lay out what text can’t: fields side by side, buttons, a menu, an image. Send a short text with them: it shows above the blocks, and it is what a notification and a search result say. Leave it empty and Slaiky fills those with the blocks’ own words, and the message shows only the blocks. A chat.update with new blocks and no text keeps those words in step.

    your app → Slaikychat.postMessage
    {
      "channel": "#launch",
      "text": "Deploy **v42** finished.",
      "blocks": [
        { "type": "section", "fields": ["**Branch**\nmain", "**Commit**\na1b2c3d"] },
        { "type": "context", "elements": ["From the deploy pipeline"] }
      ]
    }

    The blocks

    A message holds up to 50 blocks, from a closed catalog. Anything else is refused, so every screen can show every message.

    BlockWhat it shows
    headerA title line, plain text, up to 150 characters
    sectionMarkdown text, up to 10 fields in two columns, and one accessory at its side: a button or a menu
    actionsA row of up to 5 buttons and menus
    contextSmall text: up to 10 short parts on one line
    dividerA line across
    imageAn image from an http(s) url, with its alt text

    Every field and limit is on Blocks. What happens when someone clicks a button or picks from a menu is on Commands, shortcuts and buttons.

    Edit and delete

    Your bot changes only its own messages. Another’s answers forbidden.

    chat.update takes the messageId and what changes: text, blocks, or both. "blocks": null takes the blocks away. The message is marked edited, and apps in the conversation hear message_changed.

    your app → Slaikychat.update
    curl -s https://app.slaiky.xyz/api/methods/chat.update \
      -H "authorization: Bearer $SLAIKY_BOT_TOKEN" -H 'content-type: application/json' \
      -d '{"messageId": "7f3c0021-5a1e-4c2b-9d6f-1a2b3c4d5e14", "text": "Deploy is green. Checked twice."}'

    chat.delete takes the messageId. The message is gone for everyone, and apps hear message_deleted with its id only, never what it said.

    Show a message to one person

    chat.postEphemeral shows a message to one user in a conversation they can see, with text, maybe blocks and a threadId. They see it marked as for them only. It is not kept: it is not in the conversation’s history. Answers to commands and clicks are this kind by default.

    React and pin

    reactions.add and reactions.remove take a messageId and an emoji: the emoji itself, or :name: for one of the workspace’s own. They need reactions:write, which new apps have. Each answers with the message’s reactions:

    your app → Slaikyreactions.add
    { "messageId": "7f3c0007-5a1e-4c2b-9d6f-1a2b3c4d5e06", "emoji": "👀" }
    Slaiky → your app
    { "ok": true, "reactions": [{ "emoji": "👍", "count": 1, "userIds": ["7f3c0008-5a1e-4c2b-9d6f-1a2b3c4d5e07"] }, { "emoji": "👀", "count": 1, "userIds": ["7f3c0004-5a1e-4c2b-9d6f-1a2b3c4d5e03"] }] }

    pins.add and pins.remove take a messageId and need pins:write. New apps don’t have it: add it under Permissions on the app’s page. pins.list takes a channel and needs pins:read, and the conversation’s :history permission.

    Every method, with what it takes and answers: Methods.

    Updated . Every method, scope, event and limit here is generated from the server’s own code.