# Slack API

Every handle of the Slack fake: the `slack` fixture, the people and objects a test creates on it, and what they read and wait for. How to test a Slack app or agent, step by step, is in the [Slack guide](https://channelstack.dev/docs/platforms/slack).

Each call is shown in every SDK's language, with its required options (the table under it lists them all). Arguments go first; options are TypeScript's trailing object, Python's keyword arguments and Rust's builder setters. The variable names are the ones the calls return elsewhere on these pages, so `user` is a `SlackUser` handle.

Besides the errors listed with each method, most methods can fail with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires), [`cross_workspace_credential`](https://channelstack.dev/docs/reference/api/errors#cross-workspace-credential), [`fake_actor_in_live_world`](https://channelstack.dev/docs/reference/api/errors#fake-actor-in-live-world), [`internal`](https://channelstack.dev/docs/reference/api/errors#internal), [`invalid_argument`](https://channelstack.dev/docs/reference/api/errors#invalid-argument), [`live_misconfigured`](https://channelstack.dev/docs/reference/api/errors#live-misconfigured), [`live_not_allowlisted`](https://channelstack.dev/docs/reference/api/errors#live-not-allowlisted), [`not_found`](https://channelstack.dev/docs/reference/api/errors#not-found), [`session_not_found`](https://channelstack.dev/docs/reference/api/errors#session-not-found), [`unauthorized`](https://channelstack.dev/docs/reference/api/errors#unauthorized), [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): a bad request, a closed session, or live mode refusing or misconfigured.

## SlackFixture

Returned by [`Session.slack()`](https://channelstack.dev/docs/reference/api/client#slack).

| Field               | Python / Rust        | Type        |
| ------------------- | -------------------- | ----------- |
| `app`               | `app`                | `SlackApp`  |
| `apiUrl`            | `api_url`            | `string`    |
| `team`              | `team`               | `SlackTeam` |
| `socketConnections` | `socket_connections` | `number`    |

### createUser()

Create a person in the workspace.

```ts title="TypeScript"
const user = await slack.createUser({ name: "…" });
```

```python title="Python"
user = await slack.create_user(name="…")
```

```rust title="Rust"
let user = slack.create_user().name("…").await?;
```

| Parameter     | Python / Rust  | Type                       | Required |                                                                        |
| ------------- | -------------- | -------------------------- | -------- | ---------------------------------------------------------------------- |
| `name`        | `name`         | `string`                   | yes      | option                                                                 |
| `id`          | `id`           | `string`                   | no       | option                                                                 |
| `displayName` | `display_name` | `string`                   | no       | option                                                                 |
| `realName`    | `real_name`    | `string`                   | no       | option                                                                 |
| `email`       | `email`        | `string`                   | no       | option                                                                 |
| `timezone`    | `timezone`     | `string`                   | no       | option                                                                 |
| `admin`       | `admin`        | `boolean`                  | no       | option                                                                 |
| `owner`       | `owner`        | `boolean`                  | no       | option                                                                 |
| `guest`       | `guest`        | `boolean`                  | no       | option                                                                 |
| `bot`         | `bot`          | `boolean`                  | no       | option                                                                 |
| `token`       | `token`        | `string`                   | no       | option; read from `CHANNELSTACK_SLACK_USER_{name}_TOKEN` when left out |
| `browser`     | `browser`      | `{ storageState: string }` | no       | option                                                                 |

**Returns** [`SlackUser`](https://channelstack.dev/docs/reference/api/slack#slackuser).

**Errors** [`invalid_auth`](https://channelstack.dev/docs/reference/api/errors#invalid-auth), [`account_inactive`](https://channelstack.dev/docs/reference/api/errors#account-inactive).

### users()

The people this session created.

```ts title="TypeScript"
const users = await slack.users();
```

```python title="Python"
users = await slack.users()
```

```rust title="Rust"
let users = slack.users().await?;
```

**Returns** [`SlackUsers`](https://channelstack.dev/docs/reference/api/slack#slackusers).

### createApp()

Make another app in the workspace, with its own bot user, tokens and signing secret (decision 0027), or return the one made with this name and settings. Its events go to CHANNELSTACK_SLACK_APP\_\<NAME>\_WEBHOOK_URL, or over its own Socket Mode connection.

```ts title="TypeScript"
const app = await slack.createApp({ name: "…" });
```

```python title="Python"
app = await slack.create_app(name="…")
```

```rust title="Rust"
let app = slack.create_app().name("…").await?;
```

| Parameter   | Python / Rust | Type       | Required |        |
| ----------- | ------------- | ---------- | -------- | ------ |
| `name`      | `name`        | `string`   | yes      | option |
| `scopes`    | `scopes`      | `string[]` | no       | option |
| `botEvents` | `bot_events`  | `string[]` | no       | option |

**Returns** [`SlackApp`](https://channelstack.dev/docs/reference/api/slack#slackapp).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): not yet: live, the workspace holds only the app channelstack has credentials for.

### apps()

The apps this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here.

```ts title="TypeScript"
const apps = await slack.apps();
```

```python title="Python"
apps = await slack.apps()
```

```rust title="Rust"
let apps = slack.apps().await?;
```

**Returns** [`SlackApps`](https://channelstack.dev/docs/reference/api/slack#slackapps).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): not yet: live, the workspace holds only the app channelstack has credentials for.

### conversations()

The session's conversations, the one with the newest message last.

```ts title="TypeScript"
const conversations = await slack.conversations();
```

```python title="Python"
conversations = await slack.conversations()
```

```rust title="Rust"
let conversations = slack.conversations().await?;
```

**Returns** [`SlackConversations`](https://channelstack.dev/docs/reference/api/slack#slackconversations).

### createChannel()

Create a channel. Only the listed participants are members; include the app for it to receive events.

```ts title="TypeScript"
const conversation = await slack.createChannel({ name: "…" });
```

```python title="Python"
conversation = await slack.create_channel(name="…")
```

```rust title="Rust"
let conversation = slack.create_channel().name("…").await?;
```

| Parameter      | Type                           | Required |        |
| -------------- | ------------------------------ | -------- | ------ |
| `name`         | `string`                       | no       | option |
| `private`      | `boolean`                      | no       | option |
| `participants` | `Array<SlackUser \| SlackApp>` | no       | option |
| `topic`        | `string`                       | no       | option |
| `purpose`      | `string`                       | no       | option |
| `shared`       | `boolean`                      | no       | option |

**Returns** [`SlackConversation`](https://channelstack.dev/docs/reference/api/slack#slackconversation).

**Errors** [`name_taken`](https://channelstack.dev/docs/reference/api/errors#name-taken), [`unsupported_in_fake`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-fake).

### deliveries()

Every event channelstack sent the agent for this session, with every attempt.

```ts title="TypeScript"
const deliveries = await slack.deliveries({ app });
```

```python title="Python"
deliveries = await slack.deliveries(app=app)
```

```rust title="Rust"
let deliveries = slack.deliveries().app(&app).await?;
```

| Parameter | Type       | Required |        |
| --------- | ---------- | -------- | ------ |
| `app`     | `SlackApp` | no       | option |

**Returns** [`SlackDeliveries`](https://channelstack.dev/docs/reference/api/slack#slackdeliveries).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### calls()

The Web API calls the agent made about this session's conversations, people and files. Calls about nothing a session owns (auth.test, users.list) are in no session.

```ts title="TypeScript"
const apiCalls = await slack.calls({ operation: "…" });
```

```python title="Python"
api_calls = await slack.calls(operation="…")
```

```rust title="Rust"
let api_calls = slack.calls().operation("…").await?;
```

| Parameter   | Type             | Required |        |
| ----------- | ---------------- | -------- | ------ |
| `operation` | `string`         | no       | option |
| `error`     | `true \| string` | no       | option |

**Returns** [`SlackApiCalls`](https://channelstack.dev/docs/reference/api/slack#slackapicalls).

**Live:** needs proxy mode: no Slack API reads this back; proxy mode sees the agent's own calls. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### uninstallApp()

The workspace uninstalls an app: the built-in one, or the one given. Undone when this session closes; run such tests on their own.

```ts title="TypeScript"
const uninstallDeliveries = await slack.uninstallApp({ app });
```

```python title="Python"
uninstall_deliveries = await slack.uninstall_app(app=app)
```

```rust title="Rust"
let uninstall_deliveries = slack.uninstall_app().app(&app).await?;
```

| Parameter | Type       | Required |        |
| --------- | ---------- | -------- | ------ |
| `app`     | `SlackApp` | no       | option |

**Returns** [`SlackUninstallDeliveries`](https://channelstack.dev/docs/reference/api/slack#slackuninstalldeliveries).

**Errors** [`account_inactive`](https://channelstack.dev/docs/reference/api/errors#account-inactive).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): it revokes the app's tokens, and reinstalling needs the OAuth consent flow in a browser (a dedicated job, not every run).

### fault()

Inject a fault: into the agent's Web API calls (removed when this session closes), or drop its Socket Mode connection once.

```ts title="TypeScript"
const fault = await slack.fault({ type });
```

```python title="Python"
fault = await slack.fault(type=type)
```

```rust title="Rust"
let fault = slack.fault().r#type(r#type).await?;
```

| Parameter    | Python / Rust     | Type                                                    | Required |        |
| ------------ | ----------------- | ------------------------------------------------------- | -------- | ------ |
| `type`       | `type` · `r#type` | `"rate_limit" \| "latency" \| "error" \| "drop_socket"` | yes      | option |
| `operation`  | `operation`       | `string`                                                | no       | option |
| `retryAfter` | `retry_after`     | `Duration`                                              | no       | option |
| `delay`      | `delay`           | `Duration`                                              | no       | option |
| `after`      | `after`           | `Duration`                                              | no       | option |
| `error`      | `error`           | `string`                                                | no       | option |
| `times`      | `times`           | `number`                                                | no       | option |
| `app`        | `app`             | `SlackApp`                                              | no       | option |

**Returns** [`SlackFault`](https://channelstack.dev/docs/reference/api/slack#slackfault).

**Live:** needs proxy mode: a fault changes what the agent's own calls get back, and only proxy mode sits between the agent and Slack. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### waitForCall()

Waits for the next API call from the agent after the last one this handle returned: it polls `calls()` and never sleeps longer than it must.

```ts title="TypeScript"
const apiCall = await slack.waitForCall({ operation: "…" });
```

```python title="Python"
api_call = await slack.wait_for_call(operation="…")
```

```rust title="Rust"
let api_call = slack.wait_for_call().operation("…").await?;
```

| Parameter   | Type             | Required |             |
| ----------- | ---------------- | -------- | ----------- |
| `operation` | `string`         | no       | filter      |
| `error`     | `true \| string` | no       | filter      |
| `timeout`   | `Duration`       | no       | default 10s |

**Returns** [`SlackApiCall`](https://channelstack.dev/docs/reference/api/slack#slackapicall). When the time is up, it fails with what it was waiting for.

## SlackApp

Returned by [`SlackFixture.createApp()`](https://channelstack.dev/docs/reference/api/slack#createapp).

| Field           | Python / Rust    | Type       |
| --------------- | ---------------- | ---------- |
| `id`            | `id`             | `string`   |
| `name`          | `name`           | `string`   |
| `kind`          | `kind`           | `"app"`    |
| `botUserId`     | `bot_user_id`    | `string`   |
| `botId`         | `bot_id`         | `string`   |
| `botToken`      | `bot_token`      | `string`   |
| `appToken`      | `app_token`      | `string`   |
| `signingSecret` | `signing_secret` | `string`   |
| `scopes`        | `scopes`         | `string[]` |

### say()

An app a test made writes a top-level message, as its own chat.postMessage would: in a conversation it is a member of, or in a DM with the people in `to`.

```ts title="TypeScript"
const message = await app.say("…", { channel });
```

```python title="Python"
message = await app.say("…", channel=channel)
```

```rust title="Rust"
let message = app.say("…").channel(&channel).await?;
```

| Parameter | Type                                                    | Required |            |
| --------- | ------------------------------------------------------- | -------- | ---------- |
| `message` | `string \| SlackMessageInput`                           | yes      | positional |
| `channel` | `SlackConversation`                                     | no       | option     |
| `to`      | `SlackUser \| SlackApp \| Array<SlackUser \| SlackApp>` | no       | option     |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`cannot_dm_bot`](https://channelstack.dev/docs/reference/api/errors#cannot-dm-bot), [`no_text`](https://channelstack.dev/docs/reference/api/errors#no-text), [`msg_too_long`](https://channelstack.dev/docs/reference/api/errors#msg-too-long).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): not yet: live, the workspace holds only the app channelstack has credentials for.

### reply()

An app a test made replies in a thread: pass the message that starts it, or any reply in it.

```ts title="TypeScript"
const message = await app.reply("…", { thread });
```

```python title="Python"
message = await app.reply("…", thread=thread)
```

```rust title="Rust"
let message = app.reply("…").thread(&thread).await?;
```

| Parameter | Type                          | Required |            |
| --------- | ----------------------------- | -------- | ---------- |
| `message` | `string \| SlackMessageInput` | yes      | positional |
| `thread`  | `SlackThread \| SlackMessage` | yes      | option     |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`no_text`](https://channelstack.dev/docs/reference/api/errors#no-text), [`msg_too_long`](https://channelstack.dev/docs/reference/api/errors#msg-too-long).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): not yet: live, the workspace holds only the app channelstack has credentials for.

### react()

An app a test made reacts to a message.

```ts title="TypeScript"
const delivery = await app.react("…", { message });
```

```python title="Python"
delivery = await app.react("…", message=message)
```

```rust title="Rust"
let delivery = app.react("…").message(&message).await?;
```

| Parameter | Type           | Required |            |
| --------- | -------------- | -------- | ---------- |
| `emoji`   | `string`       | yes      | positional |
| `message` | `SlackMessage` | yes      | option     |

**Returns** [`SlackDelivery | undefined`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`already_reacted`](https://channelstack.dev/docs/reference/api/errors#already-reacted).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): not yet: live, the workspace holds only the app channelstack has credentials for.

### unreact()

An app a test made takes its reaction back.

```ts title="TypeScript"
const delivery = await app.unreact("…", { message });
```

```python title="Python"
delivery = await app.unreact("…", message=message)
```

```rust title="Rust"
let delivery = app.unreact("…").message(&message).await?;
```

| Parameter | Type           | Required |            |
| --------- | -------------- | -------- | ---------- |
| `emoji`   | `string`       | yes      | positional |
| `message` | `SlackMessage` | yes      | option     |

**Returns** [`SlackDelivery | undefined`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`no_reaction`](https://channelstack.dev/docs/reference/api/errors#no-reaction).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): not yet: live, the workspace holds only the app channelstack has credentials for.

## SlackUser

Returned by [`SlackFixture.createUser()`](https://channelstack.dev/docs/reference/api/slack#createuser).

| Field         | Python / Rust  | Type                  |
| ------------- | -------------- | --------------------- |
| `id`          | `id`           | `string`              |
| `name`        | `name`         | `string`              |
| `kind`        | `kind`         | `"user"`              |
| `displayName` | `display_name` | `string`              |
| `realName`    | `real_name`    | `string`              |
| `email`       | `email`        | `string \| undefined` |
| `isAdmin`     | `is_admin`     | `boolean`             |
| `isBot`       | `is_bot`       | `boolean`             |

### say()

Post a top-level message in a conversation, or in a DM with the people in `to`.

```ts title="TypeScript"
const message = await user.say("…", { channel });
```

```python title="Python"
message = await user.say("…", channel=channel)
```

```rust title="Rust"
let message = user.say("…").channel(&channel).await?;
```

| Parameter | Type                                                    | Required |            |
| --------- | ------------------------------------------------------- | -------- | ---------- |
| `message` | `string \| SlackMessageInput`                           | yes      | positional |
| `channel` | `SlackConversation`                                     | no       | option     |
| `to`      | `SlackUser \| SlackApp \| Array<SlackUser \| SlackApp>` | no       | option     |
| `files`   | `string \| FileInput[]`                                 | no       | option     |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`no_text`](https://channelstack.dev/docs/reference/api/errors#no-text), [`msg_too_long`](https://channelstack.dev/docs/reference/api/errors#msg-too-long).

### reply()

Reply in a thread: pass the message that starts it, or any reply in it.

```ts title="TypeScript"
const message = await user.reply("…", { thread });
```

```python title="Python"
message = await user.reply("…", thread=thread)
```

```rust title="Rust"
let message = user.reply("…").thread(&thread).await?;
```

| Parameter           | Python / Rust          | Type                          | Required |            |
| ------------------- | ---------------------- | ----------------------------- | -------- | ---------- |
| `message`           | `message`              | `string \| SlackMessageInput` | yes      | positional |
| `thread`            | `thread`               | `SlackThread \| SlackMessage` | yes      | option     |
| `alsoSendToChannel` | `also_send_to_channel` | `boolean`                     | no       | option     |
| `files`             | `files`                | `string \| FileInput[]`       | no       | option     |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`no_text`](https://channelstack.dev/docs/reference/api/errors#no-text), [`msg_too_long`](https://channelstack.dev/docs/reference/api/errors#msg-too-long).

### edit()

Edit one of this person's own messages.

```ts title="TypeScript"
const result = await user.edit("…", { message });
```

```python title="Python"
result = await user.edit("…", message=message)
```

```rust title="Rust"
let result = user.edit("…").message(&message).await?;
```

| Parameter | Type                          | Required |            |
| --------- | ----------------------------- | -------- | ---------- |
| `text`    | `string \| SlackMessageInput` | yes      | positional |
| `message` | `SlackMessage`                | yes      | option     |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`cant_update_message`](https://channelstack.dev/docs/reference/api/errors#cant-update-message), [`no_text`](https://channelstack.dev/docs/reference/api/errors#no-text).

### delete()

Delete a message: this person's own, or anyone's for an admin.

```ts title="TypeScript"
await user.delete({ message });
```

```python title="Python"
await user.delete(message=message)
```

```rust title="Rust"
user.delete().message(&message).await?;
```

| Parameter | Type           | Required |        |
| --------- | -------------- | -------- | ------ |
| `message` | `SlackMessage` | yes      | option |

**Returns** nothing.

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`cant_delete_message`](https://channelstack.dev/docs/reference/api/errors#cant-delete-message).

### click()

Click a button, found by its label or action_id: on a message, or on the app's latest message that has it in a thread or a conversation.

```ts title="TypeScript"
const delivery = await user.click("…", { message });
```

```python title="Python"
delivery = await user.click("…", message=message)
```

```rust title="Rust"
let delivery = user.click("…").message(&message).await?;
```

| Parameter | Type                          | Required |            |
| --------- | ----------------------------- | -------- | ---------- |
| `button`  | `string \| SlackButtonRef`    | yes      | positional |
| `message` | `SlackMessage`                | no       | option     |
| `thread`  | `SlackThread \| SlackMessage` | no       | option     |
| `channel` | `SlackConversation`           | no       | option     |

**Returns** [`SlackDelivery | undefined`](https://channelstack.dev/docs/reference/api/slack#slackdelivery). While refused with [`not_found`](https://channelstack.dev/docs/reference/api/errors#not-found), it tries again until the wait's timeout.

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`dispatch_failed`](https://channelstack.dev/docs/reference/api/errors#dispatch-failed).

### select()

Choose from a select menu on a message: options by their text or value, the menu by its placeholder or action_id.

```ts title="TypeScript"
const delivery = await user.select(option, { menu: "…", message });
```

```python title="Python"
delivery = await user.select(option, menu="…", message=message)
```

```rust title="Rust"
let delivery = user.select(option).menu("…").message(&message).await?;
```

| Parameter | Type                     | Required |            |
| --------- | ------------------------ | -------- | ---------- |
| `option`  | `string \| string[]`     | yes      | positional |
| `menu`    | `string \| SlackMenuRef` | yes      | option     |
| `message` | `SlackMessage`           | yes      | option     |

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery). While refused with [`not_found`](https://channelstack.dev/docs/reference/api/errors#not-found), it tries again until the wait's timeout.

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`dispatch_failed`](https://channelstack.dev/docs/reference/api/errors#dispatch-failed).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### shortcut()

Run an app's message shortcut on a message: it goes to that app alone.

```ts title="TypeScript"
const delivery = await user.shortcut("…", { message });
```

```python title="Python"
delivery = await user.shortcut("…", message=message)
```

```rust title="Rust"
let delivery = user.shortcut("…").message(&message).await?;
```

| Parameter    | Python / Rust | Type           | Required |            |
| ------------ | ------------- | -------------- | -------- | ---------- |
| `callbackId` | `callback_id` | `string`       | yes      | positional |
| `message`    | `message`     | `SlackMessage` | yes      | option     |
| `app`        | `app`         | `SlackApp`     | no       | option     |

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`dispatch_failed`](https://channelstack.dev/docs/reference/api/errors#dispatch-failed).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### runCommand()

Run an app's slash command in a conversation, e.g. `/deploy web staging`: it goes to that app alone.

```ts title="TypeScript"
const delivery = await user.runCommand("…", { channel });
```

```python title="Python"
delivery = await user.run_command("…", channel=channel)
```

```rust title="Rust"
let delivery = user.run_command("…").channel(&channel).await?;
```

| Parameter | Type                | Required |            |
| --------- | ------------------- | -------- | ---------- |
| `command` | `string`            | yes      | positional |
| `channel` | `SlackConversation` | yes      | option     |
| `app`     | `SlackApp`          | no       | option     |

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`dispatch_failed`](https://channelstack.dev/docs/reference/api/errors#dispatch-failed).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### stop()

Press Stop on the app's work in a thread: what is streaming there ends, and the app is told.

```ts title="TypeScript"
const delivery = await user.stop({ thread });
```

```python title="Python"
delivery = await user.stop(thread=thread)
```

```rust title="Rust"
let delivery = user.stop().thread(&thread).await?;
```

| Parameter | Type                          | Required |        |
| --------- | ----------------------------- | -------- | ------ |
| `thread`  | `SlackThread \| SlackMessage` | yes      | option |

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`stop_unavailable`](https://channelstack.dev/docs/reference/api/errors#stop-unavailable).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### openAgentThread()

Open an app's split view: a new thread in this person's DM with that app, started from the channel they are looking at.

```ts title="TypeScript"
const thread = await user.openAgentThread({ from });
```

```python title="Python"
thread = await user.open_agent_thread(from_=from_)
```

```rust title="Rust"
let thread = user.open_agent_thread().from(&from).await?;
```

| Parameter | Python / Rust    | Type                | Required |        |
| --------- | ---------------- | ------------------- | -------- | ------ |
| `from`    | `from_` · `from` | `SlackConversation` | no       | option |
| `app`     | `app`            | `SlackApp`          | no       | option |

**Returns** [`SlackThread`](https://channelstack.dev/docs/reference/api/slack#slackthread).

**Errors** [`split_view_unavailable`](https://channelstack.dev/docs/reference/api/errors#split-view-unavailable).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### pickPrompt()

Pick one of the prompts the app suggested in a thread: this person says its message there.

```ts title="TypeScript"
const message = await user.pickPrompt("…", { thread });
```

```python title="Python"
message = await user.pick_prompt("…", thread=thread)
```

```rust title="Rust"
let message = user.pick_prompt("…").thread(&thread).await?;
```

| Parameter | Type                          | Required |            |
| --------- | ----------------------------- | -------- | ---------- |
| `title`   | `string`                      | yes      | positional |
| `thread`  | `SlackThread \| SlackMessage` | yes      | option     |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage). While refused with [`not_found`](https://channelstack.dev/docs/reference/api/errors#not-found), it tries again until the wait's timeout.

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### switchContext()

Look at another channel while the split view stays open: the app is told the new context.

```ts title="TypeScript"
const delivery = await user.switchContext(channel, { thread });
```

```python title="Python"
delivery = await user.switch_context(channel, thread=thread)
```

```rust title="Rust"
let delivery = user.switch_context(&channel).thread(&thread).await?;
```

| Parameter | Type                          | Required |            |
| --------- | ----------------------------- | -------- | ---------- |
| `channel` | `SlackConversation`           | yes      | positional |
| `thread`  | `SlackThread \| SlackMessage` | yes      | option     |

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`split_view_unavailable`](https://channelstack.dev/docs/reference/api/errors#split-view-unavailable).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### modals()

The modals the app opened for this person, in the order it opened them; `open` says which are still up.

```ts title="TypeScript"
const modals = await user.modals();
```

```python title="Python"
modals = await user.modals()
```

```rust title="Rust"
let modals = user.modals().await?;
```

**Returns** [`SlackModals`](https://channelstack.dev/docs/reference/api/slack#slackmodals).

**Live:** needs proxy mode: no Slack API reads this back; proxy mode sees the agent's own calls. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### react()

Add an emoji reaction to a message.

```ts title="TypeScript"
const delivery = await user.react("…", { message });
```

```python title="Python"
delivery = await user.react("…", message=message)
```

```rust title="Rust"
let delivery = user.react("…").message(&message).await?;
```

| Parameter | Type           | Required |            |
| --------- | -------------- | -------- | ---------- |
| `emoji`   | `string`       | yes      | positional |
| `message` | `SlackMessage` | yes      | option     |

**Returns** [`SlackDelivery | undefined`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`already_reacted`](https://channelstack.dev/docs/reference/api/errors#already-reacted).

### unreact()

Remove this person's emoji reaction from a message.

```ts title="TypeScript"
const delivery = await user.unreact("…", { message });
```

```python title="Python"
delivery = await user.unreact("…", message=message)
```

```rust title="Rust"
let delivery = user.unreact("…").message(&message).await?;
```

| Parameter | Type           | Required |            |
| --------- | -------------- | -------- | ---------- |
| `emoji`   | `string`       | yes      | positional |
| `message` | `SlackMessage` | yes      | option     |

**Returns** [`SlackDelivery | undefined`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`no_reaction`](https://channelstack.dev/docs/reference/api/errors#no-reaction).

### openDM()

Open (or reuse) a DM with the app, another person, or several.

```ts title="TypeScript"
const conversation = await user.openDM(participants);
```

```python title="Python"
conversation = await user.open_dm(participants)
```

```rust title="Rust"
let conversation = user.open_dm(participants).await?;
```

| Parameter      | Type                                                    | Required |            |
| -------------- | ------------------------------------------------------- | -------- | ---------- |
| `participants` | `SlackUser \| SlackApp \| Array<SlackUser \| SlackApp>` | yes      | positional |

**Returns** [`SlackConversation`](https://channelstack.dev/docs/reference/api/slack#slackconversation).

### invite()

Invite people or the app to a channel.

```ts title="TypeScript"
await user.invite(participants, { channel });
```

```python title="Python"
await user.invite(participants, channel=channel)
```

```rust title="Rust"
user.invite(participants).channel(&channel).await?;
```

| Parameter      | Type                                                    | Required |            |
| -------------- | ------------------------------------------------------- | -------- | ---------- |
| `participants` | `SlackUser \| SlackApp \| Array<SlackUser \| SlackApp>` | yes      | positional |
| `channel`      | `SlackConversation`                                     | yes      | option     |

**Returns** nothing.

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`already_in_channel`](https://channelstack.dev/docs/reference/api/errors#already-in-channel), [`method_not_supported_for_channel_type`](https://channelstack.dev/docs/reference/api/errors#method-not-supported-for-channel-type).

### kick()

Remove someone from a channel.

```ts title="TypeScript"
await user.kick(participant, { channel });
```

```python title="Python"
await user.kick(participant, channel=channel)
```

```rust title="Rust"
user.kick(&participant).channel(&channel).await?;
```

| Parameter     | Type                    | Required |            |
| ------------- | ----------------------- | -------- | ---------- |
| `participant` | `SlackUser \| SlackApp` | yes      | positional |
| `channel`     | `SlackConversation`     | yes      | option     |

**Returns** nothing.

**Errors** [`not_in_channel`](https://channelstack.dev/docs/reference/api/errors#not-in-channel), [`method_not_supported_for_channel_type`](https://channelstack.dev/docs/reference/api/errors#method-not-supported-for-channel-type).

### ephemeral()

Messages only this person can see.

```ts title="TypeScript"
const ephemeralMessages = await user.ephemeral();
```

```python title="Python"
ephemeral_messages = await user.ephemeral()
```

```rust title="Rust"
let ephemeral_messages = user.ephemeral().await?;
```

**Returns** [`SlackEphemeralMessages`](https://channelstack.dev/docs/reference/api/slack#slackephemeralmessages). It reads once the app is quiet.

**Live:** needs proxy mode: no Slack API reads this back; proxy mode sees the agent's own calls. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### waitForModal()

Waits for the next open modal from the agent after the last one this handle returned: it polls `modals()` and never sleeps longer than it must.

```ts title="TypeScript"
const modal = await user.waitForModal();
```

```python title="Python"
modal = await user.wait_for_modal()
```

```rust title="Rust"
let modal = user.wait_for_modal().await?;
```

| Parameter | Type               | Required |                      |
| --------- | ------------------ | -------- | -------------------- |
| `title`   | `string \| RegExp` | no       | contains, or matches |
| `timeout` | `Duration`         | no       | default 10s          |

**Returns** [`SlackModal`](https://channelstack.dev/docs/reference/api/slack#slackmodal). When the time is up, it fails with what it was waiting for.

## SlackMessage

Returned by [`SlackApp.say()`](https://channelstack.dev/docs/reference/api/slack#say), [`SlackApp.reply()`](https://channelstack.dev/docs/reference/api/slack#reply), [`SlackUser.say()`](https://channelstack.dev/docs/reference/api/slack#say-1), [`SlackUser.reply()`](https://channelstack.dev/docs/reference/api/slack#reply-1).

| Field          | Python / Rust  | Type                         |
| -------------- | -------------- | ---------------------------- |
| `channel`      | `channel`      | `string`                     |
| `ts`           | `ts`           | `string`                     |
| `conversation` | `conversation` | `SlackConversation`          |
| `author`       | `author`       | `SlackUser \| SlackApp`      |
| `text`         | `text`         | `string`                     |
| `blocks`       | `blocks`       | `unknown[]`                  |
| `files`        | `files`        | `string[]`                   |
| `postedAt`     | `posted_at`    | `string`                     |
| `threadTs`     | `thread_ts`    | `string \| undefined`        |
| `edited`       | `edited`       | `boolean`                    |
| `visibleTo`    | `visible_to`   | `SlackUser \| undefined`     |
| `thread`       | `thread`       | `SlackThread`                |
| `delivery`     | `delivery`     | `SlackDelivery \| undefined` |
| `stream`       | `stream`       | `SlackStream \| undefined`   |

### refresh()

Re-read a message: its latest text, edits and deliveries.

```ts title="TypeScript"
const updated = await message.refresh();
```

```python title="Python"
updated = await message.refresh()
```

```rust title="Rust"
let updated = message.refresh().await?;
```

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

### reactions()

The reactions on a message, and who added each.

```ts title="TypeScript"
const reactions = await message.reactions();
```

```python title="Python"
reactions = await message.reactions()
```

```rust title="Rust"
let reactions = message.reactions().await?;
```

**Returns** [`SlackReactions`](https://channelstack.dev/docs/reference/api/slack#slackreactions).

### transcript()

A message and the replies under it as a person would read them.

```ts title="TypeScript"
const transcript = await message.transcript({ as });
```

```python title="Python"
transcript = await message.transcript(as_=as_)
```

```rust title="Rust"
let transcript = message.transcript().r#as(&r#as).await?;
```

| Parameter | Python / Rust  | Type                    | Required |        |
| --------- | -------------- | ----------------------- | -------- | ------ |
| `as`      | `as_` · `r#as` | `SlackUser \| SlackApp` | no       | option |

**Returns** [`SlackTranscript`](https://channelstack.dev/docs/reference/api/slack#slacktranscript).

### deliveryFor()

The first delivery this message caused to this app (decision 0027), or nothing when it wasn't told.

```ts title="TypeScript"
const delivery = await message.deliveryFor(app);
```

```python title="Python"
delivery = await message.delivery_for(app)
```

```rust title="Rust"
let delivery = message.delivery_for(&app).await?;
```

| Parameter | Type       | Required |            |
| --------- | ---------- | -------- | ---------- |
| `app`     | `SlackApp` | yes      | positional |

**Returns** [`SlackDelivery | undefined`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### deliveries()

Every delivery this message caused to the agent.

```ts title="TypeScript"
const messageDeliveries = await message.deliveries();
```

```python title="Python"
message_deliveries = await message.deliveries()
```

```rust title="Rust"
let message_deliveries = message.deliveries().await?;
```

**Returns** [`SlackMessageDeliveries`](https://channelstack.dev/docs/reference/api/slack#slackmessagedeliveries).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

## SlackConversation

Returned by [`SlackFixture.createChannel()`](https://channelstack.dev/docs/reference/api/slack#createchannel), [`SlackUser.openDM()`](https://channelstack.dev/docs/reference/api/slack#opendm).

| Field  | Type                                               |
| ------ | -------------------------------------------------- |
| `id`   | `string`                                           |
| `kind` | `"channel" \| "private_channel" \| "im" \| "mpim"` |
| `name` | `string \| undefined`                              |

### latestMessage()

The newest message of a conversation, replies included.

```ts title="TypeScript"
const message = await conversation.latestMessage();
```

```python title="Python"
message = await conversation.latest_message()
```

```rust title="Rust"
let message = conversation.latest_message().await?;
```

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

### messages()

Top-level messages of a conversation, oldest first.

```ts title="TypeScript"
const messages = await conversation.messages();
```

```python title="Python"
messages = await conversation.messages()
```

```rust title="Rust"
let messages = conversation.messages().await?;
```

**Returns** [`SlackMessages`](https://channelstack.dev/docs/reference/api/slack#slackmessages).

### members()

The people and apps in a conversation.

```ts title="TypeScript"
const members = await conversation.members();
```

```python title="Python"
members = await conversation.members()
```

```rust title="Rust"
let members = conversation.members().await?;
```

**Returns** [`SlackMembers`](https://channelstack.dev/docs/reference/api/slack#slackmembers).

### transcript()

The conversation as a person would read it, threads included.

```ts title="TypeScript"
const transcript = await conversation.transcript({ as });
```

```python title="Python"
transcript = await conversation.transcript(as_=as_)
```

```rust title="Rust"
let transcript = conversation.transcript().r#as(&r#as).await?;
```

| Parameter | Python / Rust  | Type                    | Required |        |
| --------- | -------------- | ----------------------- | -------- | ------ |
| `as`      | `as_` · `r#as` | `SlackUser \| SlackApp` | no       | option |

**Returns** [`SlackTranscript`](https://channelstack.dev/docs/reference/api/slack#slacktranscript).

### waitForMessage()

Waits for the next message after the last one this handle returned: it polls `messages()` and never sleeps longer than it must.

```ts title="TypeScript"
const message = await conversation.waitForMessage({ from: "my-agent" });
```

```python title="Python"
message = await conversation.wait_for_message(from_="my-agent")
```

```rust title="Rust"
let message = conversation.wait_for_message().from("my-agent").await?;
```

| Parameter | Python / Rust    | Type                              | Required |                     |
| --------- | ---------------- | --------------------------------- | -------- | ------------------- |
| `from`    | `from_` · `from` | `SlackUser \| SlackApp \| string` | no       | a handle, or a name |
| `timeout` | `timeout`        | `Duration`                        | no       | default 10s         |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage). When the time is up, it fails with what it was waiting for.

## SlackThread

Returned by [`SlackUser.openAgentThread()`](https://channelstack.dev/docs/reference/api/slack#openagentthread).

| Field          | Type                |
| -------------- | ------------------- |
| `channel`      | `string`            |
| `ts`           | `string`            |
| `conversation` | `SlackConversation` |

### suggestedPrompts()

The prompts the app suggested in a thread.

```ts title="TypeScript"
const suggestedPrompts = await thread.suggestedPrompts();
```

```python title="Python"
suggested_prompts = await thread.suggested_prompts()
```

```rust title="Rust"
let suggested_prompts = thread.suggested_prompts().await?;
```

**Returns** [`SlackSuggestedPrompts`](https://channelstack.dev/docs/reference/api/slack#slacksuggestedprompts). It reads once the app is quiet.

**Live:** needs proxy mode: no Slack API reads this back; proxy mode sees the agent's own calls. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### root()

The message that starts a thread, as it is now.

```ts title="TypeScript"
const message = await thread.root();
```

```python title="Python"
message = await thread.root()
```

```rust title="Rust"
let message = thread.root().await?;
```

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage).

### replies()

Replies in a thread, oldest first, without the message that starts it.

```ts title="TypeScript"
const replies = await thread.replies();
```

```python title="Python"
replies = await thread.replies()
```

```rust title="Rust"
let replies = thread.replies().await?;
```

**Returns** [`SlackReplies`](https://channelstack.dev/docs/reference/api/slack#slackreplies).

### status()

What the agent is doing in a thread: its status line, an open stream, or idle.

```ts title="TypeScript"
const threadStatus = await thread.status();
```

```python title="Python"
thread_status = await thread.status()
```

```rust title="Rust"
let thread_status = thread.status().await?;
```

**Returns** [`SlackThreadStatus`](https://channelstack.dev/docs/reference/api/slack#slackthreadstatus).

**Live:** needs proxy mode: no Slack API reads this back; proxy mode sees the agent's own calls. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### transcript()

A thread as a person would read it.

```ts title="TypeScript"
const transcript = await thread.transcript({ as });
```

```python title="Python"
transcript = await thread.transcript(as_=as_)
```

```rust title="Rust"
let transcript = thread.transcript().r#as(&r#as).await?;
```

| Parameter | Python / Rust  | Type                    | Required |        |
| --------- | -------------- | ----------------------- | -------- | ------ |
| `as`      | `as_` · `r#as` | `SlackUser \| SlackApp` | no       | option |

**Returns** [`SlackTranscript`](https://channelstack.dev/docs/reference/api/slack#slacktranscript).

### waitForReply()

Waits for the next reply after the last one this handle returned: it polls `replies()` and never sleeps longer than it must.

```ts title="TypeScript"
const message = await thread.waitForReply({ from: "my-agent" });
```

```python title="Python"
message = await thread.wait_for_reply(from_="my-agent")
```

```rust title="Rust"
let message = thread.wait_for_reply().from("my-agent").await?;
```

| Parameter | Python / Rust    | Type                              | Required |                     |
| --------- | ---------------- | --------------------------------- | -------- | ------------------- |
| `from`    | `from_` · `from` | `SlackUser \| SlackApp \| string` | no       | a handle, or a name |
| `timeout` | `timeout`        | `Duration`                        | no       | default 10s         |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage). When the time is up, it fails with what it was waiting for.

### latestReply()

The latest reply, once the app is quiet. Waits for at least one: it polls `replies()` and never sleeps longer than it must.

```ts title="TypeScript"
const message = await thread.latestReply({ from: "my-agent" });
```

```python title="Python"
message = await thread.latest_reply(from_="my-agent")
```

```rust title="Rust"
let message = thread.latest_reply().from("my-agent").await?;
```

| Parameter  | Python / Rust    | Type                              | Required |                     |
| ---------- | ---------------- | --------------------------------- | -------- | ------------------- |
| `from`     | `from_` · `from` | `SlackUser \| SlackApp \| string` | no       | a handle, or a name |
| `timeout`  | `timeout`        | `Duration`                        | no       | default 10s         |
| `quietFor` | `quiet_for`      | `Duration`                        | no       | default 750ms       |

**Returns** [`SlackMessage`](https://channelstack.dev/docs/reference/api/slack#slackmessage). When the time is up, it fails with what it was waiting for.

## SlackDelivery

Returned by [`SlackApp.react()`](https://channelstack.dev/docs/reference/api/slack#react), [`SlackApp.unreact()`](https://channelstack.dev/docs/reference/api/slack#unreact), [`SlackUser.click()`](https://channelstack.dev/docs/reference/api/slack#click), [`SlackUser.select()`](https://channelstack.dev/docs/reference/api/slack#select).

| Field       | Python / Rust     | Type                                                                      |
| ----------- | ----------------- | ------------------------------------------------------------------------- |
| `id`        | `id`              | `string`                                                                  |
| `channel`   | `channel`         | `"slack"`                                                                 |
| `app`       | `app`             | `string`                                                                  |
| `type`      | `type` · `r#type` | `string`                                                                  |
| `eventType` | `event_type`      | `string \| undefined`                                                     |
| `eventId`   | `event_id`        | `string \| undefined`                                                     |
| `payload`   | `payload`         | `unknown \| undefined`                                                    |
| `attempts`  | `attempts`        | `DeliveryAttempt[]`                                                       |
| `status`    | `status`          | `"pending" \| "acknowledged" \| "failed" \| "timed_out" \| "unreachable"` |

### refresh()

Re-read a delivery: its attempts and status.

```ts title="TypeScript"
const updated = await delivery.refresh();
```

```python title="Python"
updated = await delivery.refresh()
```

```rust title="Rust"
let updated = delivery.refresh().await?;
```

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### resend()

Send the delivery again, unchanged or forged: a wrong signature, or a timestamp outside the replay window.

```ts title="TypeScript"
const deliveryAttempt = await delivery.resend({ badSignature });
```

```python title="Python"
delivery_attempt = await delivery.resend(bad_signature=bad_signature)
```

```rust title="Rust"
let delivery_attempt = delivery.resend().bad_signature(bad_signature).await?;
```

| Parameter      | Python / Rust   | Type                     | Required |        |
| -------------- | --------------- | ------------------------ | -------- | ------ |
| `badSignature` | `bad_signature` | `boolean`                | no       | option |
| `stale`        | `stale`         | `boolean`                | no       | option |
| `headers`      | `headers`       | `Record<string, string>` | no       | option |

**Returns** [`DeliveryAttempt`](https://channelstack.dev/docs/reference/api/client#deliveryattempt).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### retry()

Retry the way Slack does: the same payload, with X-Slack-Retry-Num and X-Slack-Retry-Reason.

```ts title="TypeScript"
const deliveryAttempt = await delivery.retry({ after });
```

```python title="Python"
delivery_attempt = await delivery.retry(after=after)
```

```rust title="Rust"
let delivery_attempt = delivery.retry().after(after).await?;
```

| Parameter | Type                                                     | Required |        |
| --------- | -------------------------------------------------------- | -------- | ------ |
| `after`   | `Duration`                                               | no       | option |
| `reason`  | `"http_timeout" \| "http_error" \| "too_many_redirects"` | no       | option |

**Returns** [`DeliveryAttempt`](https://channelstack.dev/docs/reference/api/client#deliveryattempt).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### settled()

Waits for the delivery to settle: it polls `refresh()` and never sleeps longer than it must.

```ts title="TypeScript"
const updated = await delivery.settled();
```

```python title="Python"
updated = await delivery.settled()
```

```rust title="Rust"
let updated = delivery.settled().await?;
```

| Parameter | Type       | Required |             |
| --------- | ---------- | -------- | ----------- |
| `timeout` | `Duration` | no       | default 10s |

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery). When the time is up, it fails with what it was waiting for.

## SlackStream

Returned by [`SlackStream.refresh()`](https://channelstack.dev/docs/reference/api/slack#refresh-2).

| Field       | Python / Rust | Type                                 |
| ----------- | ------------- | ------------------------------------ |
| `channel`   | `channel`     | `string`                             |
| `ts`        | `ts`          | `string`                             |
| `state`     | `state`       | `"open" \| "stopped" \| "completed"` |
| `chunks`    | `chunks`      | `string[]`                           |
| `startedAt` | `started_at`  | `string`                             |
| `endedAt`   | `ended_at`    | `string \| undefined`                |

### refresh()

Re-read a streamed message's stream: its state and what was streamed so far.

```ts title="TypeScript"
const updated = await stream.refresh();
```

```python title="Python"
updated = await stream.refresh()
```

```rust title="Rust"
let updated = stream.refresh().await?;
```

**Returns** [`SlackStream`](https://channelstack.dev/docs/reference/api/slack#slackstream).

**Live:** needs proxy mode: no Slack API reads this back; proxy mode sees the agent's own calls. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### ended()

Waits for the stream to end: it polls `refresh()` and never sleeps longer than it must.

```ts title="TypeScript"
const updated = await stream.ended();
```

```python title="Python"
updated = await stream.ended()
```

```rust title="Rust"
let updated = stream.ended().await?;
```

| Parameter | Type       | Required |             |
| --------- | ---------- | -------- | ----------- |
| `timeout` | `Duration` | no       | default 10s |

**Returns** [`SlackStream`](https://channelstack.dev/docs/reference/api/slack#slackstream). When the time is up, it fails with what it was waiting for.

## SlackModal

| Field    | Python / Rust | Type                     |
| -------- | ------------- | ------------------------ |
| `viewId` | `view_id`     | `string`                 |
| `user`   | `user`        | `SlackUser`              |
| `title`  | `title`       | `string`                 |
| `blocks` | `blocks`      | `unknown[]`              |
| `open`   | `open`        | `boolean`                |
| `errors` | `errors`      | `Record<string, string>` |

### values()

What is filled in: each input by its label (or action_id), with the text a person sees in it.

```ts title="TypeScript"
const modalValues = await modal.values();
```

```python title="Python"
modal_values = await modal.values()
```

```rust title="Rust"
let modal_values = modal.values().await?;
```

**Returns** [`SlackModalValues`](https://channelstack.dev/docs/reference/api/slack#slackmodalvalues).

**Live:** needs proxy mode: no Slack API reads this back; proxy mode sees the agent's own calls. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### submit()

Fill in inputs, by label or `block_id.action_id`, and submit the modal.

```ts title="TypeScript"
const delivery = await modal.submit();
```

```python title="Python"
delivery = await modal.submit()
```

```rust title="Rust"
let delivery = modal.submit().await?;
```

| Parameter | Type                                 | Required |            |
| --------- | ------------------------------------ | -------- | ---------- |
| `values`  | `Record<string, string \| string[]>` | no       | positional |

**Returns** [`SlackDelivery`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`dispatch_failed`](https://channelstack.dev/docs/reference/api/errors#dispatch-failed).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### close()

Close the modal. The app is told only if it asked to be (`notify_on_close`).

```ts title="TypeScript"
const delivery = await modal.close();
```

```python title="Python"
delivery = await modal.close()
```

```rust title="Rust"
let delivery = modal.close().await?;
```

**Returns** [`SlackDelivery | undefined`](https://channelstack.dev/docs/reference/api/slack#slackdelivery).

**Errors** [`dispatch_failed`](https://channelstack.dev/docs/reference/api/errors#dispatch-failed).

**Live:** needs the browser actor: Slack sends this only when a person does it in the client; no API does it as a person. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

## SlackFault

Returned by [`SlackFixture.fault()`](https://channelstack.dev/docs/reference/api/slack#fault).

| Field | Type     |
| ----- | -------- |
| `id`  | `string` |

### undo()

Remove a fault.

```ts title="TypeScript"
await fault.undo();
```

```python title="Python"
await fault.undo()
```

```rust title="Rust"
fault.undo().await?;
```

**Returns** nothing. Disposing the handle calls it.

**Live:** needs proxy mode: a fault changes what the agent's own calls get back, and only proxy mode sits between the agent and Slack. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

## Types

Plain values the handles return and take.

### SlackTeam

| Field  | Type     |
| ------ | -------- |
| `id`   | `string` |
| `name` | `string` |

### SlackApps

```ts
type SlackApps = SlackApp[];
```

### SlackMessageInput

| Field      | Type                                |
| ---------- | ----------------------------------- |
| `text`     | `string \| undefined`               |
| `blocks`   | `unknown[] \| undefined`            |
| `metadata` | `SlackMessageMetadata \| undefined` |

### SlackMessageMetadata

| Field           | Type                      |
| --------------- | ------------------------- |
| `event_type`    | `string`                  |
| `event_payload` | `Record<string, unknown>` |

### SlackUsers

```ts
type SlackUsers = SlackUser[];
```

### SlackConversations

```ts
type SlackConversations = SlackConversation[];
```

### SlackButtonRef

| Field      | Python / Rust | Type                  |
| ---------- | ------------- | --------------------- |
| `label`    | `label`       | `string \| undefined` |
| `actionId` | `action_id`   | `string \| undefined` |
| `value`    | `value`       | `string \| undefined` |

### SlackMenuRef

| Field      | Python / Rust | Type                  |
| ---------- | ------------- | --------------------- |
| `label`    | `label`       | `string \| undefined` |
| `actionId` | `action_id`   | `string \| undefined` |

### SlackSuggestedPrompts

```ts
type SlackSuggestedPrompts = Array<{ title: string; message: string }>;
```

### SlackModals

```ts
type SlackModals = SlackModal[];
```

### SlackModalValues

```ts
type SlackModalValues = Record<string, string | string[] | undefined>;
```

### SlackMessages

```ts
type SlackMessages = SlackMessage[];
```

### SlackMembers

```ts
type SlackMembers = Array<SlackUser | SlackApp>;
```

### SlackReplies

```ts
type SlackReplies = SlackMessage[];
```

### SlackReactions

```ts
type SlackReactions = SlackReaction[];
```

### SlackReaction

| Field   | Type                           |
| ------- | ------------------------------ |
| `emoji` | `string`                       |
| `by`    | `Array<SlackUser \| SlackApp>` |

### SlackThreadStatus

| Field           | Python / Rust    | Type                                                               |
| --------------- | ---------------- | ------------------------------------------------------------------ |
| `state`         | `state`          | `"working" \| "streaming" \| "stopped" \| "idle"`                  |
| `text`          | `text`           | `string \| undefined`                                              |
| `sessionStatus` | `session_status` | `"active" \| "processing" \| "suspended" \| "closed" \| undefined` |

### SlackTranscript

| Field     | Type                     |
| --------- | ------------------------ |
| `entries` | `SlackTranscriptEntry[]` |
| `text`    | `string`                 |

### SlackTranscriptEntry

| Field           | Python / Rust     | Type                                              |
| --------------- | ----------------- | ------------------------------------------------- |
| `id`            | `id`              | `string`                                          |
| `author`        | `author`          | `SlackPrincipal`                                  |
| `at`            | `at`              | `string`                                          |
| `text`          | `text`            | `string`                                          |
| `controls`      | `controls`        | `string[]`                                        |
| `edited`        | `edited`          | `boolean`                                         |
| `depth`         | `depth`           | `number`                                          |
| `files`         | `files`           | `string[]`                                        |
| `alsoInChannel` | `also_in_channel` | `true \| undefined`                               |
| `streaming`     | `streaming`       | `"open" \| "stopped" \| "completed" \| undefined` |
| `visibleTo`     | `visible_to`      | `SlackPrincipal \| undefined`                     |

### SlackPrincipal

| Field  | Type              |
| ------ | ----------------- |
| `id`   | `string`          |
| `name` | `string`          |
| `kind` | `"user" \| "app"` |

### SlackEphemeralMessages

```ts
type SlackEphemeralMessages = SlackMessage[];
```

### SlackMessageDeliveries

```ts
type SlackMessageDeliveries = SlackDelivery[];
```

### SlackDeliveries

```ts
type SlackDeliveries = SlackDelivery[];
```

### SlackApiCalls

```ts
type SlackApiCalls = SlackApiCall[];
```

### SlackApiCall

| Field            | Python / Rust     | Type                   |
| ---------------- | ----------------- | ---------------------- |
| `id`             | `id`              | `string`               |
| `channel`        | `channel`         | `"slack"`              |
| `operation`      | `operation`       | `string`               |
| `method`         | `method`          | `string`               |
| `path`           | `path`            | `string`               |
| `at`             | `at`              | `string`               |
| `durationMs`     | `duration_ms`     | `number`               |
| `request`        | `request`         | `unknown \| undefined` |
| `responseStatus` | `response_status` | `number`               |
| `response`       | `response`        | `unknown \| undefined` |
| `error`          | `error`           | `string \| undefined`  |

### SlackUninstallDeliveries

```ts
type SlackUninstallDeliveries = SlackDelivery[];
```
