# Slash commands and buttons

Add a /command to the composer, answer it from your server, and put buttons on what your app posts.

## Add a command

1. **Set a request address** On the app’s **Events and buttons** tab, enter the **Request address** your server listens on. Commands, button presses and events all go there.
2. **Add the command** On **Slash commands**, press **Add a command**: its name after the `/`, a usage hint such as `[site] [branch]`, and **What it does**. Press **Add command**.

- A name is 2 to 32 lowercase letters, numbers, hyphens or underscores, starting with a letter, and is unique in the workspace.
- Kinnlo’s own commands can’t be taken: `/me`, `/shrug`, `/topic`, `/invite`, `/leave`, `/mute`, `/status`, `/away`, `/active`, `/search`, `/remind` and `/poll`.
- In the composer, app commands are listed after the built-in ones with the app’s name.
- A request address is an `https://` address on the public internet, up to 2,000 characters, with no sign-in details in it.

## What your server receives

A `POST` with a JSON body, [signed](https://www.kinnlo.com/docs/apps/verify), with `User-Agent: Kinnlo-Apps/1.0`. Redirects are not followed. The person must be able to post in the conversation.

```json
{
  "type": "command",
  "command": "deploy",
  "text": "web main",
  "workspaceId": "…",
  "channelId": "…",
  "threadRootId": null,
  "memberId": "…",
  "memberName": "Ada Lin",
  "triggerId": "…",
  "responseUrl": "https://www.kinnlo.com/api/hooks/respond/…"
}
```

## Answer within 3 seconds

Answer with JSON, or with an empty body and follow up later through `responseUrl`.

```json
{
  "responseType": "in_channel",
  "text": "Deploying web",
  "blocks": [{"type": "actions", "items": [
    {"type": "button", "text": "Approve", "actionId": "approve", "style": "primary"}
  ]}]
}
```

| Field | What it does |
| --- | --- |
| `responseType` | `in_channel` posts for everyone in the conversation. Anything else, or none, shows the answer only to the person who asked. |
| `text` | Up to 40,000 characters. |
| `blocks` | Optional [blocks](https://www.kinnlo.com/docs/apps/blocks). |
| `replaceOriginal` | For buttons: `true` or `{text, blocks}` rewrites the message the button was on. |

If your server answers with an error status, takes longer than 3 seconds, or sends more than 64 KB, the person sees that the app didn’t answer, and why. A plain-text answer is shown only to the person who asked.

## Follow up later with responseUrl

`POST` the same JSON to `responseUrl` within 30 minutes. A follow-up must be `"responseType": "in_channel"`, or `replaceOriginal` for a button’s message: it can’t be shown to one person later. It can be used up to 30 times a minute.

## Buttons

Put buttons in an `actions` block ([blocks](https://www.kinnlo.com/docs/apps/blocks)). A button with a `url` opens it; any other sends a press to your request address:

```json
{
  "type": "block_action",
  "actionId": "approve",
  "value": null,
  "workspaceId": "…",
  "channelId": "…",
  "message": {"id": "…", "channelId": "…", "threadRootId": null, "body": "…", "blocks": […]},
  "memberId": "…",
  "memberName": "Ada Lin",
  "triggerId": "…",
  "responseUrl": "…"
}
```

Answer the same way as a command. `replaceOriginal` rewrites the card; `in_channel` posts in the thread under it. On a message only one person could see, `message` is `null` and `replaceOriginal` replaces it for them.
