Ask Spotlight in Slack

The agent answers in the mention's thread and can propose tasks, which you accept or dismiss with a button. You need:

  • A Slack app you can configure, installed in your Slack workspace.
  • Terraform 1.11 or later, set up with the Spotlight provider, using a token that has the configure and secrets scopes. See Manage Spotlight with Terraform.
  • A Spotlight account for each person who mentions the app, on the team that holds the integration. The email of their Slack account is their sign-in email or an email they verified. See Add another email to your account.
  • On a self-hosted Spotlight with an outbound allow-list, the list includes slack.com and files.slack.com. Spotlight calls Slack's API and downloads Slack files from its own servers.

Prepare the Slack app

In the Slack app's settings:

Give the app's bot the scopes app_mentions:read, chat:write, channels:history, files:read, files:write, reactions:write, users:read and users:read.email, and reinstall the app.

Turn on Agents & AI Apps. Slack then shows a status in the thread while the agent works.

Copy the app's bot token and its signing secret.

Note the ID of the Slack channel that questions from other tasks should go to.

Add the Slack module

The Slack module keeps the signing secret and the bot token as workspace secrets, and creates the Slack integration on the team. A task created from a Slack chat posts its questions to the channel of that chat, each in a new thread. routes names the channel for questions from a line's other tasks, by the line's key (delivery is the built-in Delivery line's key): replace <channel id> with the channel you noted.

terraform {
  required_providers {
    spotlight = {
      source  = "usespotlightai/spotlight"
      version = "0.1.0-rc.4"
    }
  }
}

variable "slack_signing_secret" {
  type      = string
  sensitive = true
  ephemeral = true
}

variable "slack_bot_token" {
  type      = string
  sensitive = true
  ephemeral = true
}

module "slack" {
  source  = "usespotlightai/slack/spotlight"
  version = "0.1.0-rc.11"

  workspace = "acme"
  team      = "core"

  signing_secret = var.slack_signing_secret
  bot_token      = var.slack_bot_token

  routes = {
    delivery = "<channel id>"
  }
}

output "slack_webhook_url" {
  value = module.slack.webhook_url
}

The module and the provider are release candidates, and Terraform selects a release candidate only for an exact version. Keep both versions exact. If your configuration already has a required_providers block, set the provider's version there.

Change workspace to the part after /w/ in the workspace's address, and team to your team's key. The agent reads the repositories of the team's lines. To answer with another harness, set harness, as in codex. To show another status while the agent works, set status, or set it to null for no status. To react with other emojis when a task is complete, when a run of it fails, or when a mention reopens it, set finished_reaction, failed_reaction and acknowledge, or set them to null for no reaction. On a self-hosted Spotlight, set spotlight_url to your deployment's address. Run terraform apply.

Choose what the app posts

By default, the app posts the questions of tasks and says in a task's thread when the task is complete. Set notify to choose what it posts:

ValueWhat the app postsWhere
questionsThe questions of tasks.The channel of the task's Slack chat, or else the channel in routes for the task's line.
finishedA message that the task is complete.The task's thread.
inbox_requestsA request that waits for a person in the inbox: proposed memories or a station alert.The channel of the task's Slack chat, or else the channel in routes for the task's line.
noticesA notice of the team that is addressed to nobody, such as a config pull request that Spotlight opened.The channel in notices_channel.
module "slack" {
  # ...

  notify          = ["questions", "finished", "inbox_requests", "notices"]
  notices_channel = "<channel id>"
}

Each post has an Open in Spotlight button. A notice that links to a pull request also has a button to it. When a request has no channel, because its task did not come from Slack and its line has no route, the app does not post it. A notice that is addressed to one person stays in that person's inbox. The app posts a request or a notice once, when it first opens. Without questions, nobody can answer a question in Slack.

Point Slack at the team

In the Slack app's event subscription settings:

Turn events on and give the slack_webhook_url output as the request URL. Slack sends a challenge, Spotlight responds to it, and Slack marks the address verified.

Subscribe the bot to the app_mention and message.channels events.

Save, and reinstall the app if Slack asks.

In the interactivity settings, turn interactivity on and give the slack_webhook_url output as the request URL. The buttons need it.

Check it

Mention the app in a channel it has joined, with a question about your code. While the agent works, the thread shows "is thinking…". The agent's answer then appears in the thread, with an Open in Spotlight button. The chat also shows on your Agent page. Files attached to the mention, such as screenshots, go to the agent with it. To ask more, mention the app again in the same thread. Only the person who started the chat can talk to it. When another person mentions the app in that thread, the app replies that only the person who started the chat can talk to it, and the chat does not change.

Ask for a change. When the agent proposes a task, its answer lists the open proposals, each with a number that it keeps and an Accept and a Dismiss button. Click Accept to create the task, or Dismiss to remove the proposal. You can also reply with a mention and accept or dismiss, and add the number when more than one proposal is open, as in accept 2. The thread then links to the new task. When the task asks a question, the question appears in the channel in a new thread and mentions you. The images of the question, such as screenshots of the change, show below it. The app waits up to 10 seconds until Slack has processed them, and posts the question without them when Slack has not. A reply in that thread answers it and resumes the work. On the task in Spotlight, the reply shows the avatar of the member who uses the email of your Slack account. A mention of the app at the start of the reply is removed.

When a run of the task fails, the app reacts to the first message of that thread with x. When the task is complete, the app removes x, reacts with white_check_mark and says so in the thread, with the pull request. When the task asked no question, the reactions go on your first mention instead.

After the task finishes, mention the app in that thread to ask for more. The mention reopens the task, the app reacts with the eyes emoji, removes white_check_mark, and the agent works on the task again. A task at Completed does not reopen. The app then replies that you must mention it in a new message.

If the app replies that no member uses your email, check that the email of your Slack account is your Spotlight sign-in email or a verified email under Settings › Emails. If it is neither, add it to your account. Also check that the bot has the users:read and users:read.email scopes.

If the app replies that the team's lines run in different images, the agent cannot read all their repositories in one chat. Give the team's lines one image. See Repository fields.

On this page