Slaikydocs

    Build an app#modals

    Modals and App Home

    Open a modal for one person and read what they fill in. Draw your app’s Home tab for each person who opens it.

    A modal is a window your app opens for one person, right after they did something: ran a command, clicked a button, used a shortcut. The Home tab is a page your app draws for each person, in its conversation with them. Both are views: blocks your app sends, shown to one person only.

    Open a modal

    Call views.open with the triggerId of what the person just did, within 30 seconds. A trigger opens one modal. A used or expired one answers invalid_trigger. Opening a modal closes any modal the person had open, from any app.

    your app → Slaikyviews.open
    {
      "triggerId": "1731240000.trigger.docs",
      "view": {
        "type": "modal",
        "title": "Daily update",
        "submit": "Post",
        "close": "Not now",
        "callbackId": "daily",
        "blocks": [
          { "type": "input", "blockId": "done", "label": "What did you finish?", "element": { "type": "plain_text_input", "actionId": "v", "multiline": true } },
          { "type": "input", "blockId": "mood", "label": "How is it going?", "optional": true, "element": { "type": "static_select", "actionId": "v", "options": [{ "text": "Smooth", "value": "smooth" }, { "text": "Blocked", "value": "blocked" }] } }
        ]
      }
    }
    Slaiky → your app
    { "ok": true, "view": { "id": "7f3c0017-5a1e-4c2b-9d6f-1a2b3c4d5e10", "type": "modal", "title": "Daily update", "callbackId": "daily", "previousId": null, "hash": "1731240000.docs", "…": "…" } }

    The view

    FieldWhat it is
    type"modal" or "home"
    titleThe modal’s title, up to 24 characters. A modal needs one
    submit, closeThe labels of its two buttons, up to 24 characters. A modal with inputs needs submit
    blocksWhat it shows: the message blocks, plus inputs. Up to 50
    callbackIdYour name for it. It comes back with everything that happens to it
    privateMetadataA string for your app, kept with the view
    notifyOnClosetrue to hear when the person closes it

    The whole schema is on Views.

    Inputs

    An input block has a blockId, a label, maybe a hint, optional when it may stay empty, and one element. Each blockId is used once per view.

    element.typeThe person givesIt comes back as
    plain_text_inputText (multiline, minLength, maxLength, placeholder, initialValue)value
    static_selectOne of the optionsselectedOption
    checkboxesAny of the options (initialValues)selectedOptions
    datepickerA date (initialDate)selectedDate, as YYYY-MM-DD

    Buttons and menus in a modal work as in messages: a click sends block_actions with the view, and a new triggerId.

    Stack and change

    views.push puts a modal on top of the one your app has open. It takes a fresh triggerId: a click in the modal brings one. The person goes back with the arrow. Up to 3 can be open at once.

    views.update changes an open view in place, by its viewId. Send its hash too: if the view changed since you read it, the call answers hash_conflict and changes nothing. Each change gives the view a new hash.

    When the person submits

    Slaiky checks the inputs first: what isn’t optional is filled in, picks are among the options, dates are dates, text fits its lengths. The person fixes those before your app hears anything. Then it gets view_submission, with what they gave under view.state.values, by blockId and then actionId:

    Slaiky → your appview_submission
    {
      "type": "view_submission",
      "userId": "7f3c0008-5a1e-4c2b-9d6f-1a2b3c4d5e07",
      "view": {
        "id": "7f3c0017-5a1e-4c2b-9d6f-1a2b3c4d5e10",
        "callbackId": "daily",
        "privateMetadata": null,
        "hash": "1731240000.docs",
        "state": {
          "values": {
            "done": { "v": { "type": "plain_text_input", "value": "Shipped the export to CSV" } },
            "mood": { "v": { "type": "static_select", "selectedOption": { "text": "Smooth", "value": "smooth" } } }
          }
        }
      },
      "triggerId": "1731240000.trigger.docs",
      "responseUrl": "https://app.slaiky.xyz/api/apps/respond/docs-response-token"
    }
    your app → Slaiky
    { "responseAction": "errors", "errors": { "done": "A few more words, please." } }

    Answer within 3 seconds, in the body of your HTTP answer or the payload of your ack:

    You answerThe person sees
    Nothing (an empty 2xx, an ack without payload)The modal closes
    responseAction: "errors" with errors, text by blockIdYour words under each input. The modal stays open
    responseAction: "update" with a viewThis modal, changed
    responseAction: "push" with a viewA new modal on top
    responseAction: "clear"Every modal closes

    An update or push needs a modal view that fits the schema; anything else is shown to the person as a view that can’t be shown. If your app doesn’t answer in time, the modal stays open and the person is told it didn’t answer. To post something after a submission, use its responseUrl (Answer later) or chat.postMessage.

    When the person closes it

    With notifyOnClose: true, closing the modal sends your app view_closed, with the view and isCleared: true when every open modal closed at once. Field by field: a modal closed.

    Nobody waits on view_closed, so your app needn’t answer it: the person who closed the modal is never told it didn’t. In Socket Mode, acknowledge it like any envelope all the same.

    Keep your own data with it

    privateMetadata is a string of up to 3000 characters that stays with the view: an id, a little JSON. It comes back in view_submission, view_closed and the clicks inside the view, and never reaches the person’s screen.

    App Home

    Turn it on in the app’s page, App Home → Home tab, or with features.app_home.home_tab_enabled in a manifest. Your app’s conversation with each person then has two tabs: Home and Messages.

    When someone opens Home, your app gets app_home_opened, if it hears that event (Events → Events it hears). Draw their Home with views.publish:

    Slaiky → your appapp_home_opened
    { "type": "event_callback", "event": { "type": "app_home_opened", "userId": "7f3c0008-5a1e-4c2b-9d6f-1a2b3c4d5e07", "channelId": "7f3c0016-5a1e-4c2b-9d6f-1a2b3c4d5e0f", "tab": "home" }, "…": "…" }
    your app → Slaikyviews.publish
    {
      "userId": "7f3c0008-5a1e-4c2b-9d6f-1a2b3c4d5e07",
      "view": { "type": "home", "blocks": [{ "type": "header", "text": "Hi there" }, { "type": "section", "text": "Your week, at a glance." }] }
    }

    Each person has their own Home. views.publish draws it for one userId, at any time, with no trigger; send the hash to avoid overwriting a newer one. A Home has no inputs, but its buttons and menus send block_actions with the view and a triggerId, so a click there can open a modal. With the Home tab off, views.publish is refused.

    The Messages tab

    Messages tab (messages_tab_enabled, on unless you turn it off) is where people and your app talk. Turn on Only the app writes (messages_tab_read_only_enabled) and people read your app’s messages there but can’t reply.

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