Slaikydocs

    Build an app#interactivity

    Commands, shortcuts and buttons

    Slash commands, shortcuts, buttons and menus. What reaches your app when someone uses one, and the three ways to answer.

    Someone types your command, runs your shortcut or clicks your button. Slaiky tells your app who did it and where, and waits a moment for an answer. You can answer at once, answer later, or open a modal.

    Slash commands

    On the app’s page, open Slash commands and add a Command (/deploy), What it does, a Usage hint and a Request URL. In Socket Mode, commands arrive on the app’s connection and need no URL. Adding a command gives the app the commands permission. In a manifest, commands are features.slash_commands.

    A command name is used once per workspace: it can’t be another app’s, or one Slaiky has built in.

    When someone runs it, the command goes to its own Request URL as a signed POST of JSON, or arrives as a slash_commands envelope in Socket Mode. Its text is what they typed after the command.

    Shortcuts

    A global shortcut is in the composer’s Shortcuts menu. A message shortcut is in a message’s menu, and comes with that message.

    On the app’s page, open Buttons and shortcuts and add one under Shortcuts: a Name, Where (Composer or Message menu) and a Callback ID, which comes back to you so you know which one ran. In a manifest, they are features.shortcuts, with type "global" or "message" and a callback_id. An app has up to 10.

    Shortcuts need the commands permission, and somewhere to go: the Interactivity URL, or Socket Mode. In a manifest, interactivity must be on too (settings.interactivity.is_enabled). One arrives as shortcut, or as message_action with the message and its messageId, both with the callbackId.

    Buttons and menus

    Put them in your message’s blocks, in an actions block or as a section’s accessory. A button has its text, an actionId you choose, a value, and a style if you like (primary or danger). A static_select has an actionId, a placeholder and its options, each { "text", "value" }.

    your app → Slaikychat.postMessage
    {
      "channel": "#launch",
      "text": "Ship it?",
      "blocks": [
        { "type": "actions", "elements": [
          { "type": "button", "text": "Ship", "actionId": "ship", "value": "v42", "style": "primary" },
          { "type": "static_select", "actionId": "region", "placeholder": "Where", "options": [{ "text": "Europe", "value": "eu" }, { "text": "Americas", "value": "us" }] }
        ] }
      ]
    }

    A click or a pick reaches your app as block_actions, at the Interactivity URL or as an interactive envelope. actions[0] says what happened: its actionId, type and value, and for a pick selectedOption, the option chosen, as { "text", "value" }. A pick is always one of the menu’s own options. Only messages your app posted send it clicks. A button with a url opens that link instead, and your app hears nothing.

    Slaiky → your appblock_actions
    {
      "type": "block_actions",
      "actions": [{ "type": "button", "value": "v42", "actionId": "ship" }],
      "messageId": "7f3c0018-5a1e-4c2b-9d6f-1a2b3c4d5e11",
      "message": { "id": "7f3c0018-5a1e-4c2b-9d6f-1a2b3c4d5e11", "body": "Ship it?", "…": "…" },
      "userId": "7f3c0008-5a1e-4c2b-9d6f-1a2b3c4d5e07",
      "channelId": "7f3c0009-5a1e-4c2b-9d6f-1a2b3c4d5e08",
      "triggerId": "1731240000.trigger.docs",
      "responseUrl": "https://app.slaiky.xyz/api/apps/respond/docs-response-token"
    }
    your app → Slaiky
    { "text": "Shipping **v42**…", "replaceOriginal": true }

    The full message and the person come with it: see a click or a pick.

    What arrives

    Every command, shortcut and click tells you who and where, and how to answer:

    FieldWhat it is
    userId, userThe person who acted, and their profile
    channelId, parentIdWhere: the conversation, and the thread (or null)
    responseUrl, responseTokenHow to answer later
    triggerIdHow to open a modal for them
    appId, workspaceIdYour app, and the workspace it is in

    Each kind, field by field and recorded on a real server: Interaction payloads.

    Answer at once

    Answer the request itself: the body of your HTTP answer, or the payload of your ack in Socket Mode. It must arrive within 3 seconds.

    FieldWhat it does
    textThe answer, in Markdown
    blocksBlocks, as in messages
    responseTypeephemeral (the default): only that person sees it. in_channel: your bot posts it in the conversation, in the thread if there is one
    replaceOriginalThe answer takes the place of the message that was clicked
    deleteOriginalThe message that was clicked is deleted

    replaceOriginal and deleteOriginal work only on a message your app posted. The snake_case spellings (response_type…) work too.

    Slaiky → your appPOST /slaiky/commands
    { "type": "command", "command": "/deploy", "text": "main", "userId": "…", "channelId": "…", "parentId": null, "triggerId": "…", "responseUrl": "…" }
    your app → Slaiky
    HTTP/1.1 200 OK
    content-type: application/json
    
    { "text": "Deploying **main**…", "responseType": "in_channel" }

    An empty 2xx answers nothing. Plain text answers as text. An answer over 256 KB counts as none. Blocks that don’t fit the catalog are dropped from an HTTP answer, and refuse the whole ack in Socket Mode.

    Answer later

    Slow work? Answer at once with a word (or nothing), then post to responseUrl with the same fields when you are done. It needs no token: the URL is the secret, so keep it to yourself. It works for 30 minutes, for up to 5 answers.

    your app → SlaikyresponseUrl
    curl -s "$RESPONSE_URL" -H 'content-type: application/json' \
      -d '{"text": "Deployed **main**.", "responseType": "in_channel"}'

    It answers { "ok": true } with the message it posted, the ephemeral it showed, or "deleted": true. Holding the bot token instead of the URL? commands.respond does the same with the responseToken.

    Open a modal

    triggerId lets your app open a modal for the person who just acted, with views.open. It works for 30 seconds, and opens one modal. Answer or acknowledge the request first, then open it.

    When the app doesn’t answer

    If your app says nothing within 3 seconds (no 2xx over HTTP, no ack in Socket Mode), the person who ran the command or the shortcut, or who clicked or picked, is told that it didn’t answer. Only they see it. If your app isn’t connected (Socket Mode on, or no URL and no socket open), they are told it isn’t connected.

    A late ack is ignored. The responseUrl still works.

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