> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hue.run/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To set up Hue in an application, fetch https://docs.hue.run/guides/agent-setup.md and follow it.
> Hue's project-data MCP server is https://mcp.hue.run/mcp. https://docs.hue.run/mcp only searches these docs and cannot read a Hue project.
> Never ask the user to paste a Hue API key into chat; they store it as HUE_API_KEY themselves.
> Install the exact SDK versions pinned on the page you're following, or on https://docs.hue.run/quickstart.md. Run the latest CLI without a project install as `npx -y @hue-run/sdk@latest`. In a project with `@hue-run/sdk` installed, use `npx hue`. Pin an exact version for reproducible CI runs.
> Use Hue product terms: eval set, case, evaluator, run and scoring run. Older APIs may say dataset, scorer or experiment; prefer the current SDK methods. See https://docs.hue.run/concepts.md.

# Test a Slack bot in a World

> Send test messages, commands, and button clicks to your Slack bot without posting to a real workspace.

Run a test copy of your bot against a simulated Slack workspace. `hue listen` forwards signed Slack requests from the World instance to your bot's HTTP receiver. Your bot calls the instance's Slack Web API to reply. You don't need to install the bot in a real workspace or [enable tracing](https://docs.hue.run/quickstart.md).

## Before you begin

* Use a bot with an HTTP receiver, such as a Slack Bolt request handler, and a configurable Slack API URL, bot token, and signing secret. Socket Mode is not supported. You don't need a public callback URL.
* Run the listener with Node.js 22.12 or later, even if your bot uses Python or another language. The CLI is in the npm package, not the Python package. Use SDK 0.27.0 or later for slash commands and buttons.
* Only Slack traffic goes to the Slack World. [Configure other app clients](https://docs.hue.run/evaluations/eval-ready-agent.md) to use test services and credentials.

Check the Node.js version and listener command before registering a subscription:

```sh theme={null}
node --version
npx -y @hue-run/sdk@0.30.2 listen --help
```

## Prepare a Slack World

Use a World whose Slack account [acts as your bot](https://docs.hue.run/worlds/create-with-mcp.md#act-as-your-slack-apps-bot). For a first test, ask your [coding agent connected to Hue](https://docs.hue.run/agents/mcp-server.md) to generate one:

```text Prompt wrap theme={null}
Create a Slack World for testing my bot Ledger. Set acting_identity to kind bot, name Ledger, and channels ["bot-testing"]. Include a fictional teammate in #bot-testing who can mention Ledger. Wait for the World to be ready and give me its link.
```

In **Worlds**, open the World, choose **World token** under **Connect through**, and select **Start instance**. From the instance's **Connect** tab, copy the Slack Web API URL and world token. Keep its instance ID for the subscription. Over MCP, use `start_instance` and `get_instance_connections`.

## Register the subscription

Create a **Read and write** project key in **Settings → API keys** for the instance's project. Load it into `HUE_API_KEY` in your setup shell. Use the project key to create and inspect the subscription, not to run the bot or listener.

Create a listen subscription. Replace `<running instance ID>` with the instance ID, not the World version ID. Keep the response file out of Git because it contains the signing secret.

```sh theme={null}
umask 077
curl --fail-with-body \
  --request POST https://app.hue.run/api/v1/event-subscriptions \
  --header "Authorization: Bearer $HUE_API_KEY" \
  --header "Content-Type: application/json" \
  --output .hue-slack-subscription.json \
  --data '{
    "worldId": "<running instance ID>",
    "provider": "slack",
    "delivery": "listen",
    "events": [
      "app_mention", "message.im",
      "slash_commands", "interactivity"
    ]
  }'
```

The response includes the subscription `id` and `signingSecret`. Registration sends no request to the bot. One active Slack subscription is allowed per instance; reuse it or revoke it before creating another.

Choose the event names your bot handles:

| Event name | Input |
| - | - |
| `app_mention` | A message that mentions the bot. |
| `message.im` | A direct message. |
| `message.channels`, `message.groups`, `message.mpim` | Public-channel, private-channel, or group direct messages. |
| `slash_commands` | A slash command. |
| `interactivity` | A button click, in a message or an open modal, or a modal submission. |
| `app_home_opened` | A user opening the app's Home tab. |

## Configure the bot and start the listener

Put these values in your test configuration, such as an ignored `.env.hue-slack` file:

```dotenv theme={null}
HUE_WORLD_TOKEN=<instance world token>
HUE_SIM_SLACK_WEB_API_URL=<instance Slack Web API URL>
SLACK_SIGNING_SECRET=<subscription signingSecret>
```

Wire the bot's Slack client to `HUE_SIM_SLACK_WEB_API_URL` and use `HUE_WORLD_TOKEN` in place of its Slack bot token. JavaScript [Bolt](https://docs.slack.dev/tools/bolt-js/reference/interfaces/AppOptions/) uses `clientOptions.slackApiUrl`; JavaScript [Slack WebClient](https://docs.slack.dev/tools/node-slack-sdk/reference/web-api/interfaces/WebClientOptions/) uses `slackApiUrl`. Python [Slack WebClient](https://docs.slack.dev/tools/python-slack-sdk/reference/web/client.html) uses `base_url`. Set the values where your bot reads its configuration. An environment variable alone won't change the client.

Configure the HTTP receiver with `SLACK_SIGNING_SECRET`. Keep normal Slack signature verification enabled. The listener preserves the signed body and headers, including form-encoded commands and button payloads. Your handler must answer `url_verification` with HTTP 200 and the echoed challenge; Slack frameworks usually handle this.

Start the bot with these values using its normal startup command. Wait until its HTTP receiver is listening, then run the listener in another terminal:

```sh theme={null}
npx -y @hue-run/sdk@0.30.2 listen \
  --origin https://app.hue.run \
  --subscription "<subscription ID>" \
  --forward-to http://localhost:3000/slack/events \
  --env-path .env.hue-slack
```

Replace the port and path with your bot's receiver. `--env-path` loads values for the listener only; it does not start the bot or configure its process. The listener forwards every subscribed request to this one URL. If your bot uses separate command or interaction paths, route those requests from this receiver to the corresponding handler.

`localhost` refers to the listener's network namespace. For a containerized bot, run the listener in the same namespace or expose the bot's port on the listener's host. An off-machine receiver needs an HTTPS URL and `--allow-remote-forward`.

Wait until `GET /api/v1/event-subscriptions/<subscription ID>`, authorized with the setup project key, reports `verification.state: "verified"`. The listener performs the verification handshake; don't call the subscription's `/verify` route.

## Try a message and inspect the result

Keep both processes running. Open Slack in the instance and go to a channel your bot belongs to. Use the person picker above the message box to choose a teammate in that channel. Send a message your bot handles, such as `@Ledger help`, and check for the expected reply. In the instance's **Server** tab, check that the bot's Slack API calls reached the instance.

To run the same test over MCP, call [`send_instance_input`](https://docs.hue.run/agents/mcp-tools#instances). Use `list_projects` to find the instance's project ID. If your connection is [pinned to one project](https://docs.hue.run/agents/mcp-server.md#pin-a-connection-to-one-project), omit `project_id`.

Look up the teammate and channel IDs with `get_instance_state`. Call `auth.test` with the bot's test client to check the workspace and get the bot's `user_id`. Use a new `idempotency_key` for each new input and reuse it if you retry.

```json theme={null}
{
  "project_id": "<project ID>",
  "instance_id": "<running instance ID>",
  "idempotency_key": "ledger-mention-1",
  "kind": "message",
  "sender": "<teammate user ID>",
  "channel": "<channel ID>",
  "text": "<@BOT_USER_ID> help"
}
```

Replace `BOT_USER_ID` inside the mention and change `help` to a prompt your bot handles. Read the reply with `get_instance_state` (`include_content: true`) and inspect the bot's calls with `list_instance_requests`.

## Try direct messages and interactions

To message the bot directly, set the message's `channel` to the bot's own user ID (`U…`). Hue opens a direct message for the sender if one doesn't exist and returns its `D…` ID in `committed.channel`. Commands and button clicks take a conversation ID, so send them to the `D…` ID. Any other user ID is refused with `recipient_not_agent`. Over REST, `POST /api/v1/instances/<instance ID>/inputs` takes the same value as `channelId`.

A slash command or button click carries a `trigger_id` that your bot can exchange once with `views.open` or `views.push`, as in Slack. To act in the modal it opened, send a button click with the modal's `view_id` in place of a channel and message, or submit it with `view_submission`, its `view_id` and the inputs' `state.values`. A button click can carry what the user has entered so far as `values`, which your bot receives in the payload's `view.state.values`. Your bot's HTTP response to the submission applies as Slack applies it: an empty body closes the modal, and `response_action` `errors`, `update`, `push` or `clear` does what it does in Slack. `app_home_opened` opens the app's Home tab for a user and sends the home view your bot last published with `views.publish`.

## Troubleshoot a missing reply

The input result's `deliveries` lists the events Hue announced to your subscription. When it is empty for a message, `undelivered` gives a `reason` and a `message`:

| Reason | Meaning |
| - | - |
| `no_subscription` | No active subscription receives the instance's Slack events. |
| `subscription_unverified` | The subscription is not verified yet; the listener's first delivery verifies it. |
| `not_derived` | Hue has not announced the message's events yet; check the deliveries list shortly. |
| `no_subscribed_event` | The message announced no event the subscription names, such as a channel message without a mention when the subscription names only `app_mention`. |

The result also gives the instance's expiry: `expires_at` over MCP, `expiresAt` over REST.

To see what Hue sent your bot and how it answered, list the subscription's deliveries with the setup project key:

```sh theme={null}
curl --fail-with-body \
  --header "Authorization: Bearer $HUE_API_KEY" \
  "https://app.hue.run/api/v1/event-subscriptions/<subscription ID>/deliveries?limit=20"
```

The answer lists the subscription's events newest first. Each has its `state`, a `settleReason` such as `acknowledged` or `world_sealed`, and an `attemptLog` of every attempt with its outcome, HTTP status, diagnostic and duration. An event's `deliveryId` matches the `delivery_id` (`deliveryId` over REST) in the input's result; an attempt's `id` is the delivery the listener pulled and acknowledged. For a slash command or button click, `input.acknowledgement` holds your bot's answer: its status, its body up to 16 KiB, and `replyStored`, which says whether Hue stored the reply in the World. `listening` says whether a listener is pulling now. `limit` takes 1 to 200 (default 50); pass the answer's `nextCursor` as `cursor` for the next page.

Your receiver must acknowledge within three seconds. A successful command or interaction can return an immediate reply body of at most 64 KiB; URL verification bodies are capped at 4 KiB. These responses must finish within the deadline, even when the body exceeds the capture limit. An interrupted response reports `connection_failed` without sending its partial body to Hue. Larger bodies are truncated, which can change the displayed reply. Ordinary event response bodies and unsuccessful response bodies stay on the listener's machine.

Hue stores a slash command's successful reply in the World as Slack shows it: an ephemeral message that only the sender sees, or a channel message when the reply sets `response_type` to `in_channel`. An empty body posts nothing.

Return immediate replies without HTTP compression; the listener does not decode compressed receiver responses. Keep successful replies suitable for storage as test evidence. A `response_url` in a request authorizes later replies, so keep it out of application logs and shared output.

The listener remembers recent delivery results in memory. A restart loses that memory, and the listener does not guarantee exactly-once execution. Make financial writes and other business effects safe to retry in your application.

## Stop and clean up

An instance also stops when its lifetime ends; [Use an instance](https://docs.hue.run/worlds/overview.md#use-an-instance) gives the defaults. Its subscription then receives no more events, its world token stops working, and an input answers `instance_closed`, whose message says when the instance expired or was stopped. For a longer test, start a new instance with a longer lifetime and register a subscription for it.

Press Ctrl+C to stop the listener. It waits for deliveries in progress. Stop the test bot and the World instance. Remove the ignored `.env.hue-slack` and `.hue-slack-subscription.json` files when you no longer need their credentials. For a fresh instance, repeat the connection and subscription setup with its own values.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.