AI 编程教程中文版
官方教程中文版团队与集成

从 Slack 使用 Codex

你可以在 Slack 中使用 Codex,从 channels 和 threads 直接启动 coding tasks。

这一篇用 5 分钟换什么:把 Slack 集成从"在 Slack 里跑 Codex"重新理解成把 Slack thread 转成 scoped cloud task——真正执行仍在 Codex Cloud,所以前置条件是 GitHub connection / environment / repo map / cloud task 权限都已就位。读完后你不会把 Slack 当成本地 CLI 替身。

你可以在 Slack 中使用 Codex,从 channels 和 threads 直接启动 coding tasks。

mention @Codex 并附上 prompt,Codex 会创建 cloud task,并回复结果。

截图:

https://developers.openai.com/images/codex/integrations/slack-example.png

Slack 入口的本质不是“让 Codex 在 Slack 里跑命令”,而是把 Slack thread 转成 scoped cloud task。真正执行仍发生在 Codex Cloud environment 中,所以前置条件是 GitHub connection、environment、repo map 和 cloud task 权限都已经配置好。

设置 Slack App

  1. 设置 Codex cloud tasks。你需要 Plus、Pro、Business、Enterprise 或 Edu plan,见 ChatGPT pricing;还需要 connected GitHub account,以及至少一个 environment
  2. 打开 Codex settings,为你的 workspace 安装 Slack app。根据 Slack workspace policies,可能需要 admin approve install。
  3. @Codex 添加到 channel。如果还没有添加,当你 mention 它时,Slack 会提示你。

启动任务

  1. 在 channel 或 thread 中 mention @Codex,并写入 prompt。Codex 可以 reference thread 中较早的 messages,所以通常不需要重复上下文。
  2. 可选:在 prompt 中指定 environment 或 repository,例如 @Codex fix the above in openai/codex
  3. 等 Codex reaction(👀),并回复 task link。完成后,Codex 会发布 result,并根据你的 settings,可能在 thread 中附上 answer。

Codex 如何选择环境和仓库

  • Codex 会 review 你有 access 的 environments,并选择最匹配 request 的 environment。如果 request ambiguous,则 fallback 到你最近使用过的 environment。
  • task 会基于该 environment repo map 中列出的第一个 repository default branch 运行。如果你需要不同 default 或更多 repositories,请在 Codex 中更新 repo map。
  • 如果没有 suitable environment 或 repository,Codex 会在 Slack 中回复修复说明,你处理后再 retry。

Slack prompt 怎么写

Slack thread 往往上下文嘈杂。推荐在 mention @Codex 的最新消息里给一个短任务卡:

@Codex Please fix the failing checkout button test in openai/example-app.

Context:
- Failure is in the thread above.
- Prefer the web environment.
- Keep the change limited to checkout UI/test files.

Done when:
- Relevant tests pass.
- Reply with the task link and summary.

如果 thread 很长,不要指望 Codex 自动抓住早期所有细节。把关键错误、目标仓库、环境、限制和验收写在最新消息里。

适合和不适合的任务

适合:

  • thread 里已经讨论清楚的 bug fix。
  • 小范围 test failure。
  • 文档或示例更新。
  • 从 incident/issue thread 提炼可执行 cloud task。

不适合:

  • 需要本机未提交改动的任务,除非你使用支持本地状态委派的入口。
  • 需要生产凭据或人工登录的任务。
  • 目标仓库、环境或权限不明确的任务。
  • 高风险迁移或发布动作。

企业数据控制

默认情况下,Codex 会在 thread 中回复 answer,answer 可能包含它运行环境中的信息。

如果要避免这种情况,Enterprise admin 可以在 ChatGPT workspace settings 中取消 Allow Codex Slack app to post answers on task completion

admin 关闭 answers 后,Codex 只会回复 task link。

数据使用、隐私和安全

当你 mention @Codex 时,Codex 会接收你的 message 和 thread history,用来理解 request 并创建 task。

data handling 遵循 OpenAI 的 Privacy PolicyTerms of Use 以及其他适用 policies

更多 security 信息,见 Codex security documentation

Codex 使用 large language models,可能出错。始终 review answers 和 diffs。

使用建议和排错

  • Missing connections:如果 Codex 无法确认你的 Slack 或 GitHub connection,它会回复一个 reconnect link。
  • Unexpected environment choice:在 thread 中回复你希望使用的 environment,例如 Please run this in openai/openai (applied),然后再次 mention @Codex
  • Long or complex threads:在最新 message 中 summarize key details,避免 Codex 漏掉 thread 早期隐藏的 context。
  • Workspace posting:部分 Enterprise workspaces 会限制发布 final answers。遇到这种情况,请打开 task link 查看 progress 和 results。
  • More help:见 OpenAI Help Center

管理员检查清单

上线 Slack integration 前,管理员至少确认:

  • Slack app 安装经过 workspace policy 或 admin approval。
  • Codex Cloud environments 已配置 repo map、setup script、secrets 和联网权限。
  • Enterprise workspace 是否允许 Codex Slack app 在 task completion 后发布 answers。
  • 成员知道 @Codex 会接收 message 和 thread history。
  • 敏感 thread 不用 Slack 直接委派,或只发送最小必要摘要。

官方资料

接下来去哪

本页目录