Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

docs: simplify and update Slack setup documentation

cyhhao23dbd38b9e11
diff --git a/docs/SLACK_SETUP.md b/docs/SLACK_SETUP.md
index cf792cf10..5028fce83 100644
--- a/docs/SLACK_SETUP.md
+++ b/docs/SLACK_SETUP.md
@@ -26,9 +26,6 @@ This guide will walk you through setting up a Slack bot for the Claude Code Remo
- `channels:history` - View messages in public channels
- `channels:read` - View basic information about public channels
- `chat:write` - Send messages as bot
- - `im:history` - View direct message history
- - `im:read` - View basic information about direct messages
- - `im:write` - Send direct messages
- `app_mentions:read` - View messages that mention your bot
- `users:read` - View basic information about users
- `commands` - Use slash commands (automatically added)
@@ -38,11 +35,6 @@ This guide will walk you through setting up a Slack bot for the Claude Code Remo
- `groups:history` - View messages in private channels
- `groups:write` - Send messages to private channels
-### Multi-Party DM Support
- - `mpim:read` - View basic information about group DMs
- - `mpim:history` - View messages in group DMs
- - `mpim:write` - Send messages to group DMs
-
### Enhanced Features
- `chat:write.public` - Send messages to channels without joining
- `chat:write.customize` - Send messages with custom username and avatar
@@ -57,12 +49,11 @@ This guide will walk you through setting up a Slack bot for the Claude Code Remo
### Quick Permission Checklist
To ensure full functionality, make sure you've added:
-- ✅ All Essential Scopes (9 scopes)
+- ✅ All Essential Scopes (6 scopes)
- ✅ All Private Channel scopes (3 scopes)
-- ✅ All Multi-Party DM scopes (3 scopes)
- ✅ Any Enhanced Features you want (up to 8 additional scopes)
-**Total recommended scopes: ~23 scopes** for full functionality without future permission issues.
+**Total recommended scopes: ~17 scopes** for full functionality.
## Step 3: Install App to Workspace
@@ -94,8 +85,6 @@ Socket Mode allows your bot to connect without exposing a public URL.
### Message Events
- `message.channels` - Messages in public channels
- `message.groups` - Messages in private channels
- - `message.im` - Direct messages
- - `message.mpim` - Messages in group DMs
- `app_mention` - When someone mentions your bot
### Additional Events (Optional but Recommended)
@@ -115,137 +104,75 @@ Native Slack slash commands provide the best user experience with autocomplete a
### 6.1 Access Slash Commands Configuration
-**详细步骤**:
-1. **打开浏览器** 并导航到 [https://api.slack.com/apps](https://api.slack.com/apps)
-2. **登录你的 Slack 账户** (如果尚未登录)
-3. **找到你的 App**: 在 "Your Apps" 列表中找到之前创建的 Claude Code Bot 应用
-4. **点击应用名称** 进入应用管理界面
-5. **导航到斜杠命令**: 在左侧边栏中,找到 **"Features"** 分组,点击 **"Slash Commands"**
-6. **查看当前状态**: 你会看到标题为 "Slash Commands" 的页面,显示任何现有的命令
-
-**页面说明**:
-- 如果是新应用,页面会显示 "You haven't created any slash commands yet"
-- 右上角有绿色的 **"Create New Command"** 按钮
-- 现有命令会以列表形式显示,每个命令都有编辑选项
-
-### 6.2 创建命令的通用流程
-
-**每个命令的创建步骤**:
-1. **点击 "Create New Command"** 按钮 (页面右上角的绿色按钮)
-2. **填写命令表单** (详见下方每个命令的具体配置)
-3. **点击 "Save"** 保存命令
-4. **等待确认** - Slack 会显示 "Your slash command was saved!" 的成功消息
-5. **返回命令列表** 验证命令已创建
-
-**重要提醒**:
-- ⚠️ 每次只能创建一个命令,需要重复8次这个过程
-- ⚠️ 命令名称不能重复,不能包含空格
-- ⚠️ 所有字段都区分大小写
-
-### 6.3 推荐创建的命令 (逐一配置)
-
-**配置原则**:
-- 所有命令的 **Request URL** 都留空 (我们使用 Socket Mode)
-- 所有命令都要勾选 **"Escape channels, users, and links"**
-- 按照下面的模板逐个创建,可以直接复制粘贴
-
----
-
-#### 命令 1/8: `/claude-start`
-**📋 复制这些内容到表单**:
-```
-Command: /claude-start
-Request URL: (留空)
-Short Description: Show welcome message and help
-Usage Hint: Get started with Claude Code bot
-```
-**操作步骤**:
-1. 点击 **"Create New Command"**
-2. 在 **"Command"** 字段填入: `/claude-start`
-3. **"Request URL"** 保持空白 (不要填任何内容)
-4. 在 **"Short Description"** 字段填入: `Show welcome message and help`
-5. 在 **"Usage Hint"** 字段填入: `Get started with Claude Code bot`
-6. ✅ **勾选** "Escape channels, users, and links" 复选框
-7. 点击 **"Save"** 按钮
-8. 看到绿色成功消息后点击 **"← Back to Slash Commands"**
-
-#### 命令 2/8: `/claude-status`
-**📋 复制这些内容到表单**:
-```
-Command: /claude-status
-Request URL: (留空)
-Short Description: Show current queue status
-Usage Hint: Check queue and execution status
-```
-**重复上述步骤,将对应内容填入表单各字段**
-
----
+1. Navigate to [https://api.slack.com/apps](https://api.slack.com/apps)
+2. Log in to your Slack account (if not already logged in)
+3. Find your Claude Code Bot app in the "Your Apps" list
+4. Click on your app name to enter the management interface
+5. In the left sidebar, find **"Features"** section and click **"Slash Commands"**
+6. You'll see the "Slash Commands" page showing any existing commands
-#### 命令 3/8: `/claude-clear`
-**📋 复制这些内容到表单**:
-```
-Command: /claude-clear
-Request URL: (留空)
-Short Description: Clear message queue
-Usage Hint: Clear all queued messages
-```
-
----
+**Page Overview**:
+- New apps will show "You haven't created any slash commands yet"
+- Green **"Create New Command"** button is in the top right corner
+- Existing commands appear in a list with edit options
-#### 命令 4/8: `/claude-cwd`
-**📋 复制这些内容到表单**:
-```
-Command: /claude-cwd
-Request URL: (留空)
-Short Description: Show current working directory
-Usage Hint: Display current working directory
-```
+### 6.2 Create Commands
----
+**Steps for each command**:
+1. Click **"Create New Command"** button
+2. Fill in the command form (see specific configurations below)
+3. Click **"Save"** to save the command
+4. Wait for confirmation - Slack will show "Your slash command was saved!" message
+5. Return to command list to verify creation
-#### 命令 5/8: `/claude-set-cwd`
-**📋 复制这些内容到表单**:
-```
-Command: /claude-set-cwd
-Request URL: (留空)
-Short Description: Set working directory
-Usage Hint: Set working directory: /path/to/directory
-```
+**Important Notes**:
+- Commands must be created one at a time
+- Command names cannot be duplicated or contain spaces
+- All fields are case-sensitive
----
+### 6.3 Required Commands
-#### 命令 6/8: `/claude-queue`
-**📋 复制这些内容到表单**:
-```
-Command: /claude-queue
-Request URL: (留空)
-Short Description: Show message queue
-Usage Hint: View messages in queue
-```
+**Configuration Guidelines**:
+- Leave **Request URL** empty for all commands (we use Socket Mode)
+- Check **"Escape channels, users, and links"** for all commands
+- Copy and paste the configurations below
---
-#### 命令 7/8: `/claude-settings`
-**📋 复制这些内容到表单**:
+#### Command 1: `/start`
```
-Command: /claude-settings
-Request URL: (留空)
-Short Description: Configure personalization settings
-Usage Hint: Open personalization settings menu
+Command: /start
+Request URL: (leave empty)
+Short Description: Open main menu with interactive buttons
+Usage Hint: Start Claude Code bot and show menu
```
-
----
-
-#### 命令 8/8: `/claude-execute`
-**📋 复制这些内容到表单**:
+**Steps**:
+1. Click **"Create New Command"**
+2. Fill in **"Command"** field: `/start`
+3. Leave **"Request URL"** blank
+4. Fill in **"Short Description"**: `Open main menu with interactive buttons`
+5. Fill in **"Usage Hint"**: `Start Claude Code bot and show menu`
+6. ✅ Check "Escape channels, users, and links"
+7. Click **"Save"**
+8. Return to Slash Commands page
+
+#### Command 2: `/stop`
```
-Command: /claude-execute
-Request URL: (留空)
-Short Description: Process queue manually
-Usage Hint: Manually trigger queue processing
+Command: /stop
+Request URL: (leave empty)
+Short Description: Stop Claude Code bot session
+Usage Hint: Stop the current bot session
```
+**Steps**:
+1. Click **"Create New Command"**
+2. Fill in **"Command"** field: `/stop`
+3. Leave **"Request URL"** blank
+4. Fill in **"Short Description"**: `Stop Claude Code bot session`
+5. Fill in **"Usage Hint"**: `Stop the current bot session`
+6. ✅ Check "Escape channels, users, and links"
+7. Click **"Save"**
-**🎉 完成后**: 返回 Slash Commands 主页面,你应该看到所有8个命令都已列出。
+**✅ Complete**: After creating both commands, you should see them listed on the Slash Commands page.
### 6.4 Important Configuration Notes
@@ -257,96 +184,32 @@ Usage Hint: Manually trigger queue processing
### 6.5 Verification
-After creating all commands:
+After creating both commands:
1. Go back to the main "Slash Commands" page
-2. You should see all 8 commands listed
+2. You should see both `/start` and `/stop` commands listed
3. Each command should show "✅ Configured" status
-### 6.6 快速设置检查清单
-
-**逐项检查确保设置正确**:
-- [ ] 访问了 [https://api.slack.com/apps](https://api.slack.com/apps) 并选择了正确的应用
-- [ ] 导航到了 "Features" > "Slash Commands" 页面
-- [ ] 创建了 `/claude-start` 命令
-- [ ] 创建了 `/claude-status` 命令
-- [ ] 创建了 `/claude-clear` 命令
-- [ ] 创建了 `/claude-cwd` 命令
-- [ ] 创建了 `/claude-set-cwd` 命令
-- [ ] 创建了 `/claude-queue` 命令
-- [ ] 创建了 `/claude-settings` 命令
-- [ ] 创建了 `/claude-execute` 命令
-- [ ] 所有命令的 **Request URL** 都是空白的
-- [ ] 所有命令都勾选了 **"Escape channels, users, and links"**
-- [ ] 在 Slash Commands 主页面能看到全部8个命令列出
-
-### 6.7 常见问题排查
-
-#### ❌ 问题:命令创建后不显示自动完成
-**原因**: 应用可能需要重新安装到工作区
-**解决方案**:
-1. 前往 "OAuth & Permissions" 页面
-2. 点击 "Reinstall to Workspace"
-3. 重新授权应用
-
-#### ❌ 问题:输入 `/claude-` 没有命令提示
-**可能原因**:
-- 命令名称拼写错误 (检查是否有多余空格或字符)
-- 应用未正确安装到当前工作区
-- Socket Mode 未启用
-
-**解决步骤**:
-1. 检查命令列表,确认命令名称完全正确
-2. 确认 Socket Mode 已启用 (Step 4)
-3. 确认 bot 已添加到当前频道: `/invite @YourBotName`
-
-#### ❌ 问题:"This command doesn't exist" 错误
-**原因**: 命令配置有误或未保存成功
-**解决方案**:
-1. 回到 Slash Commands 页面验证命令确实存在
-2. 检查命令名称是否与输入完全匹配
-3. 尝试删除并重新创建该命令
-
-#### ❌ 问题:命令执行后无响应
-**原因**: Bot 应用可能未运行或连接有问题
-**解决方案**:
-1. 检查 bot 进程是否在运行
-2. 查看 bot 日志是否有错误信息
-3. 确认 `SLACK_APP_TOKEN` 和 `SLACK_BOT_TOKEN` 配置正确
-
-### 6.8 设置完成验证
-
-**测试步骤**:
-1. 在任意频道或 DM 中输入 `/claude-`
-2. 应该看到所有8个命令的自动完成列表
-3. 选择 `/claude-start` 并发送
-4. Bot 应该响应欢迎消息
-
-**预期结果**:
-- ✅ 命令自动完成正常工作
-- ✅ 命令执行后 bot 能正确响应
-- ✅ 在频道中使用命令会创建线程回复
-
-### 6.7 Automation Possibilities (Currently Limited)
-
-**Can Slash Commands Be Created Automatically?**
-
-Unfortunately, as of 2025, Slack does not provide an API to programmatically create slash commands. They must be created manually through the Slack App Management interface at [api.slack.com/apps](https://api.slack.com/apps).
-
-**Why No Automation?**
-- Slack considers slash commands part of the app's core configuration
-- Each command requires careful consideration of permissions and scope
-- Manual creation ensures proper security review
-- Prevents automated spam of command namespaces
-
-**Alternative Approaches:**
-- Use the existing `/claude-*` command pattern for consistency
-- Focus on @ mention + command syntax for dynamic commands
-- Consider using Slack's Block Kit for interactive menus instead of many commands
-
-**Future Possibilities:**
-- Slack may introduce API endpoints for slash command management
-- Consider using Slack's Workflow Builder for some automation needs
-- Monitor Slack's developer blog for new automation features
+### 6.6 Setup Checklist
+
+**Verify your configuration**:
+- [ ] Accessed [https://api.slack.com/apps](https://api.slack.com/apps) and selected your app
+- [ ] Navigated to "Features" > "Slash Commands" page
+- [ ] Created `/start` command
+- [ ] Created `/stop` command
+- [ ] All commands have empty **Request URL**
+- [ ] All commands have **"Escape channels, users, and links"** checked
+- [ ] Both commands appear on the Slash Commands page
+
+### 6.7 Troubleshooting Slash Commands
+
+If commands not showing in autocomplete:
+- Reinstall app to workspace via "OAuth & Permissions" page
+- Verify Socket Mode is enabled
+- Ensure bot is invited to channel: `/invite @YourBotName`
+
+If commands execute but no response:
+- Check bot process is running
+- Verify `SLACK_APP_TOKEN` and `SLACK_BOT_TOKEN` are correctly configured
## Step 7: Configure Your Environment
@@ -360,7 +223,7 @@ IM_PLATFORM=slack
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_APP_TOKEN=xapp-your-app-token-here
-# Optional: Whitelist of allowed channel IDs (empty = DM only, null = all channels)
+# Optional: Whitelist of allowed channel IDs (null = all channels)
SLACK_TARGET_CHANNEL=[C1234567890,C0987654321]
```
@@ -390,53 +253,40 @@ python main.py
### Command Methods
-The bot supports multiple ways to use commands:
+The bot supports multiple ways to interact:
-#### 1. Native Slash Commands (Recommended)
-If you configured slash commands in Step 6:
+#### 1. Slash Commands (Recommended)
```
-/claude-start
-/claude-status
-/claude-cwd
+/start
+/stop
```
- Provides autocomplete and help text
- Works in any channel where the bot is invited
- Most user-friendly experience
-#### 2. @ Mention + Command
-Mention the bot followed by a command:
-```
-@YourBotName /start
-@YourBotName /status
-@YourBotName /cwd
-```
+#### 2. In Channels
+- Use `/start` to begin
+- The bot creates threads to organize conversations
+- All responses appear in the thread
-#### 3. Direct Message Commands
-In DMs with the bot, use commands directly:
-```
-/start
-/status
-/cwd
-```
+### Using the Bot
+
+#### Primary Command
+- `/start` - Opens the main menu with interactive buttons:
+ - **Current Dir** - Display current working directory
+ - **Change Work Dir** - Open modal to change working directory
+ - **Reset Session** - Clear conversation context and start fresh
+ - **Settings** - Configure message visibility preferences
+ - **How it Works** - Display help information
-### In Channels
-- Mention the bot: `@YourBotName your message here`
-- The bot will create a thread for the conversation
-
-### In Direct Messages
-- Send any message directly to the bot
-- No mention needed in DMs
-
-### Commands
-All commands work the same as in Telegram:
-- `/start` - Show welcome message
-- `/execute` - Manually process queue
-- `/clear` - Clear message queue
-- `/status` - Show current status
-- `/queue` - Show messages in queue
-- `/cwd` - Show working directory
-- `/set_cwd <path>` - Set working directory
-- `/settings` - Configure message visibility
+#### Additional Command
+- `/stop` - Stop the current Claude Code session
+
+#### Sending Messages to Claude
+After using `/start`, simply type your message in the channel. The bot will:
+1. Send your message to Claude Code
+2. Stream the response back in real-time
+3. Maintain conversation context for follow-ups
## Thread Support
@@ -482,74 +332,13 @@ If you see `cannot_reply_to_message` error:
### Slash Command Issues
-#### Slash commands not appearing in autocomplete
-**Symptoms:** When typing `/claude-`, no autocomplete suggestions appear
-**Solutions:**
-1. Verify slash commands were created successfully in app settings
-2. Check that the bot is installed in the workspace
-3. Try reinstalling the app to workspace
-4. Ensure you're in a channel where the bot is invited
-
-#### "Command not found" error
-**Symptoms:** Slack shows "Sorry, `/claude-start` didn't work. You might be looking for something else?"
-**Solutions:**
-1. Double-check command spelling in Slack App settings
-2. Ensure Socket Mode is enabled and connected
-3. Verify `SLACK_APP_TOKEN` is set correctly
-4. Check bot logs for connection errors
-5. Try restarting the bot application
-
-#### Slash commands timeout
-**Symptoms:** Slack shows "Timeout: Command failed to respond"
-**Solutions:**
-1. Check bot application is running and connected
-2. Verify Socket Mode connection is stable
-3. Look for errors in bot logs during command execution
-4. Ensure the bot responds within 3 seconds (handled automatically by our code)
-
-#### Commands work in DMs but not in channels
-**Symptoms:** Slash commands work in direct messages but fail in channels
-**Solutions:**
-1. Ensure bot is invited to the channel: `/invite @YourBotName`
-2. Check bot has necessary channel permissions
-3. Verify `channels:history` and `channels:read` scopes are added
-
-#### "This app doesn't have permission to respond" error
-**Symptoms:** Bot receives command but can't respond
-**Solutions:**
-1. Add missing OAuth scopes: `chat:write`, `im:write`
-2. Reinstall app to workspace after adding scopes
-3. Check `SLACK_BOT_TOKEN` is correctly set
-
-#### Slash commands show but execute as text
-**Symptoms:** Commands appear as regular messages instead of executing
-**Solutions:**
-1. Verify Socket Mode is enabled (not webhook mode)
-2. Check `_handle_slash_command` method is being called in logs
-3. Ensure command mapping in `slack_bot.py` is correct
-4. Restart the bot application
-
-### Debug Commands
-
-Use these methods to test if slash commands are working:
-
-#### Test in Direct Message
-1. Send a DM to the bot
-2. Try `/claude-start`
-3. Should work without @ mention
-
-#### Test in Channel with @ Mention
-1. In a channel where bot is invited
-2. Try `@YourBotName /start`
-3. Should create a thread with response
-
-#### Check Bot Status
-1. Look for "🟢 Online" indicator next to bot name
-2. If offline, check connection and tokens
-3. Restart bot if needed
-
-#### Verify Command Registration
-Check the bot logs for these messages on startup:
+If slash commands not working:
+1. Verify commands created in app settings
+2. Check Socket Mode is enabled
+3. Ensure bot is invited to channel: `/invite @YourBotName`
+4. Restart bot if needed
+
+Check bot logs for startup confirmation:
```
INFO - Starting Slack bot in Socket Mode...
INFO - A new session has been established
diff --git a/docs/SLACK_SETUP_ZH.md b/docs/SLACK_SETUP_ZH.md
new file mode 100644
index 000000000..ee4922d83
--- /dev/null
+++ b/docs/SLACK_SETUP_ZH.md
@@ -0,0 +1,369 @@
+# Slack 机器人设置指南
+
+本指南将指导你为 Claude Code 远程控制机器人设置 Slack 机器人。
+
+## 前置条件
+
+- Slack 工作区的管理员权限
+- 已安装 Python 3.6 或更高版本
+- 已克隆 Claude Code 远程控制机器人并安装依赖
+
+## 步骤 1:创建 Slack 应用
+
+1. 访问 [https://api.slack.com/apps](https://api.slack.com/apps)
+2. 点击 **"Create New App"** → **"From scratch"**
+3. 输入应用名称(例如 "Claude Code Bot")
+4. 选择你的工作区
+5. 点击 **"Create App"**
+
+## 步骤 2:配置机器人令牌权限范围
+
+1. 在应用设置中,导航到侧边栏的 **"OAuth & Permissions"**
+2. 向下滚动到 **"Scopes"** → **"Bot Token Scopes"**
+3. 添加以下所有 OAuth 权限范围以避免权限问题:
+
+### 基础权限范围(必需)
+ - `channels:history` - 查看公共频道中的消息
+ - `channels:read` - 查看公共频道的基本信息
+ - `chat:write` - 作为机器人发送消息
+ - `app_mentions:read` - 查看提及你的机器人的消息
+ - `users:read` - 查看用户的基本信息
+ - `commands` - 使用斜杠命令(自动添加)
+
+### 私有频道支持
+ - `groups:read` - 查看私有频道的基本信息
+ - `groups:history` - 查看私有频道中的消息
+ - `groups:write` - 向私有频道发送消息
+
+### 增强功能
+ - `chat:write.public` - 无需加入即可向频道发送消息
+ - `chat:write.customize` - 使用自定义用户名和头像发送消息
+ - `files:read` - 查看频道中共享的文件(用于未来的文件处理)
+ - `files:write` - 上传文件(用于未来的文件上传支持)
+ - `reactions:read` - 查看表情反应
+ - `reactions:write` - 添加表情反应
+ - `users:read.email` - 查看电子邮件地址(用于增强用户信息)
+ - `team:read` - 查看团队/工作区信息
+
+**注意**:现在添加所有权限比以后多次重新安装应用要好。未使用的权限不会影响机器人的性能。
+
+### 快速权限检查清单
+为确保完整功能,请确保已添加:
+- ✅ 所有基础权限范围(6 个权限)
+- ✅ 所有私有频道权限(3 个权限)
+- ✅ 任何你想要的增强功能(最多 8 个额外权限)
+
+**推荐的权限总数:约 17 个权限**,可实现完整功能。
+
+## 步骤 3:将应用安装到工作区
+
+1. 仍在 **"OAuth & Permissions"** 页面,滚动到顶部
+2. 点击 **"Install to Workspace"**
+3. 查看权限并点击 **"Allow"**
+4. 复制 **Bot User OAuth Token**(以 `xoxb-` 开头)
+ - 将其保存为 `.env` 文件中的 `SLACK_BOT_TOKEN`
+
+## 步骤 4:启用 Socket 模式(推荐)
+
+Socket 模式允许你的机器人连接而无需暴露公共 URL。
+
+1. 转到侧边栏的 **"Socket Mode"**
+2. 将 **"Enable Socket Mode"** 切换为开启
+3. 系统会提示你生成应用级令牌:
+ - 令牌名称:"Socket Mode Token"
+ - 添加权限:`connections:write`
+ - 点击 **"Generate"**
+4. 复制 **App-Level Token**(以 `xapp-` 开头)
+ - 将其保存为 `.env` 文件中的 `SLACK_APP_TOKEN`
+
+## 步骤 5:配置事件订阅
+
+1. 转到侧边栏的 **"Event Subscriptions"**
+2. 将 **"Enable Events"** 切换为开启
+3. 在 **"Subscribe to bot events"** 下,添加所有这些事件:
+
+### 消息事件
+ - `message.channels` - 公共频道中的消息
+ - `message.groups` - 私有频道中的消息
+ - `app_mention` - 有人提及你的机器人时
+
+### 其他事件(可选但推荐)
+ - `member_joined_channel` - 机器人加入频道时
+ - `member_left_channel` - 机器人离开频道时
+ - `channel_created` - 创建新频道时
+ - `channel_renamed` - 频道重命名时
+ - `team_join` - 新成员加入工作区时
+
+4. 点击 **"Save Changes"**
+
+**注意**:现在添加所有事件可以避免以后扩展机器人功能时需要重新配置。
+
+## 步骤 6:配置原生斜杠命令(推荐)
+
+原生 Slack 斜杠命令提供最佳用户体验,带有自动完成和帮助文本。以下是详细的分步指南:
+
+### 6.1 访问斜杠命令配置
+
+1. 导航到 [https://api.slack.com/apps](https://api.slack.com/apps)
+2. 登录你的 Slack 账户(如果尚未登录)
+3. 在"Your Apps"列表中找到你的 Claude Code Bot 应用
+4. 点击应用名称进入管理界面
+5. 在左侧边栏中,找到 **"Features"** 部分并点击 **"Slash Commands"**
+6. 你将看到"Slash Commands"页面,显示任何现有命令
+
+**页面概览**:
+- 新应用会显示"You haven't created any slash commands yet"
+- 绿色的 **"Create New Command"** 按钮位于右上角
+- 现有命令以列表形式显示,带有编辑选项
+
+### 6.2 创建命令
+
+**每个命令的步骤**:
+1. 点击 **"Create New Command"** 按钮
+2. 填写命令表单(见下方具体配置)
+3. 点击 **"Save"** 保存命令
+4. 等待确认 - Slack 会显示"Your slash command was saved!"消息
+5. 返回命令列表验证创建
+
+**重要说明**:
+- 命令必须逐个创建
+- 命令名称不能重复或包含空格
+- 所有字段都区分大小写
+
+### 6.3 必需的命令
+
+**配置指南**:
+- 所有命令的 **Request URL** 留空(我们使用 Socket 模式)
+- 为所有命令勾选 **"Escape channels, users, and links"**
+- 复制并粘贴下面的配置
+
+---
+
+#### 命令 1:`/start`
+```
+Command: /start
+Request URL: (留空)
+Short Description: 打开带有交互按钮的主菜单
+Usage Hint: 启动 Claude Code 机器人并显示菜单
+```
+**步骤**:
+1. 点击 **"Create New Command"**
+2. 填写 **"Command"** 字段:`/start`
+3. **"Request URL"** 留空
+4. 填写 **"Short Description"**:`打开带有交互按钮的主菜单`
+5. 填写 **"Usage Hint"**:`启动 Claude Code 机器人并显示菜单`
+6. ✅ 勾选"Escape channels, users, and links"
+7. 点击 **"Save"**
+8. 返回 Slash Commands 页面
+
+#### 命令 2:`/stop`
+```
+Command: /stop
+Request URL: (留空)
+Short Description: 停止 Claude Code 机器人会话
+Usage Hint: 停止当前机器人会话
+```
+**步骤**:
+1. 点击 **"Create New Command"**
+2. 填写 **"Command"** 字段:`/stop`
+3. **"Request URL"** 留空
+4. 填写 **"Short Description"**:`停止 Claude Code 机器人会话`
+5. 填写 **"Usage Hint"**:`停止当前机器人会话`
+6. ✅ 勾选"Escape channels, users, and links"
+7. 点击 **"Save"**
+
+**✅ 完成**:创建两个命令后,你应该在 Slash Commands 页面看到它们的列表。
+
+### 6.4 重要配置说明
+
+- **Request URL**:使用 Socket 模式时始终留空(推荐)
+- **需要 Socket 模式**:这些命令仅在启用 Socket 模式时工作(步骤 4)
+- **区分大小写**:命令名称区分大小写
+- **无自动化**:目前,Slack 不提供 API 来以编程方式创建斜杠命令 - 必须通过 Web 界面手动创建
+- **3 秒响应**:机器人有 3 秒时间确认斜杠命令(自动处理)
+
+### 6.5 验证
+
+创建两个命令后:
+1. 返回主"Slash Commands"页面
+2. 你应该看到 `/start` 和 `/stop` 命令都列出
+3. 每个命令应显示"✅ Configured"状态
+
+### 6.6 设置检查清单
+
+**验证你的配置**:
+- [ ] 访问 [https://api.slack.com/apps](https://api.slack.com/apps) 并选择你的应用
+- [ ] 导航到"Features" > "Slash Commands"页面
+- [ ] 创建 `/start` 命令
+- [ ] 创建 `/stop` 命令
+- [ ] 所有命令的 **Request URL** 为空
+- [ ] 所有命令都勾选了 **"Escape channels, users, and links"**
+- [ ] 两个命令都出现在 Slash Commands 页面
+
+### 6.7 斜杠命令故障排除
+
+如果命令不在自动完成中显示:
+- 通过"OAuth & Permissions"页面重新安装应用到工作区
+- 验证 Socket 模式已启用
+- 确保机器人被邀请到频道:`/invite @YourBotName`
+
+如果命令执行但无响应:
+- 检查机器人进程正在运行
+- 验证 `SLACK_APP_TOKEN` 和 `SLACK_BOT_TOKEN` 配置正确
+
+## 步骤 7:配置你的环境
+
+使用以下内容更新你的 `.env` 文件:
+
+```env
+# 设置平台为 slack
+IM_PLATFORM=slack
+
+# Slack 配置
+SLACK_BOT_TOKEN=xoxb-your-bot-token-here
+SLACK_APP_TOKEN=xapp-your-app-token-here
+
+# 可选:允许的频道 ID 白名单(null = 所有频道)
+SLACK_TARGET_CHANNEL=[C1234567890,C0987654321]
+```
+
+### 查找频道 ID
+
+要查找频道 ID:
+1. 在 Slack 中右键点击频道名称
+2. 选择 **"View channel details"**
+3. 滚动到底部
+4. 公共频道的频道 ID 以 `C` 开头
+
+## 步骤 8:邀请机器人到频道
+
+在机器人可以与频道交互之前,你需要邀请它:
+
+1. 在 Slack 中,转到频道
+2. 输入 `/invite @YourBotName`
+3. 按 Enter
+
+## 步骤 9:启动机器人
+
+```bash
+python main.py
+```
+
+## 使用方法
+
+### 命令方法
+
+机器人支持多种交互方式:
+
+#### 1. 斜杠命令(推荐)
+```
+/start
+/stop
+```
+- 提供自动完成和帮助文本
+- 在机器人被邀请的任何频道中工作
+- 最友好的用户体验
+
+#### 2. 在频道中
+- 使用 `/start` 开始
+- 机器人创建线程来组织对话
+- 所有响应都出现在线程中
+
+### 使用机器人
+
+#### 主要命令
+- `/start` - 打开带有交互按钮的主菜单:
+ - **Current Dir** - 显示当前工作目录
+ - **Change Work Dir** - 打开模态框更改工作目录
+ - **Reset Session** - 清除对话上下文并重新开始
+ - **Settings** - 配置消息可见性偏好
+ - **How it Works** - 显示帮助信息
+
+#### 附加命令
+- `/stop` - 停止当前 Claude Code 会话
+
+#### 向 Claude 发送消息
+使用 `/start` 后,只需在频道中输入你的消息。机器人将:
+1. 将你的消息发送到 Claude Code
+2. 实时流式传输响应
+3. 为后续消息维护对话上下文
+
+## 线程支持
+
+Slack 机器人自动使用线程来组织对话:
+- 每个用户的消息都分组在一个线程中
+- Claude Code 的响应出现在同一线程中
+- 这使频道历史记录保持整洁有序
+
+## 故障排除
+
+### 机器人无响应
+1. 检查机器人是否在线(Slack 中的绿点)
+2. 验证机器人是否被邀请到频道
+3. 检查日志中的任何错误消息
+
+### 权限错误
+1. 确保添加了所有必需的权限范围(包括私有频道的 `groups:read`)
+2. **重要**:添加新权限范围后,你必须重新安装应用到工作区:
+ - 转到 **"OAuth & Permissions"** 页面
+ - 点击顶部的 **"Reinstall to Workspace"** 按钮
+ - 查看并批准新权限
+3. 验证令牌在 `.env` 中正确设置
+
+### 私有频道访问问题
+如果你看到 `missing_scope` 错误与 `groups:read`:
+1. 添加所有私有频道权限范围:`groups:read`、`groups:history`、`groups:write`
+2. 点击 **"Reinstall to Workspace"**(这是强制性的!)
+3. 复制新的 Bot Token 并更新你的 `.env` 文件
+4. 重启机器人
+5. 确保机器人被邀请到私有频道:`/invite @YourBotName`
+
+### 线程回复问题
+如果你看到 `cannot_reply_to_message` 错误:
+1. 这通常意味着机器人正在尝试回复不存在的消息或在错误的上下文中
+2. 确保机器人对频道类型有 `channels:history` 或 `groups:history` 权限
+3. 检查消息时间戳(thread_ts)是否有效
+4. 验证机器人是它尝试回复的频道的成员
+
+### Socket 模式问题
+1. 确保 `SLACK_APP_TOKEN` 设置正确
+2. 检查应用级令牌是否有 `connections:write` 权限范围
+3. 验证应用设置中已启用 Socket 模式
+
+### 斜杠命令问题
+
+如果斜杠命令不工作:
+1. 验证命令在应用设置中已创建
+2. 检查 Socket 模式已启用
+3. 确保机器人被邀请到频道:`/invite @YourBotName`
+4. 如需要重启机器人
+
+检查机器人日志的启动确认:
+```
+INFO - Starting Slack bot in Socket Mode...
+INFO - A new session has been established
+```
+
+## 替代方案:Webhook 模式
+
+如果你更喜欢使用 webhook 而不是 Socket 模式:
+
+1. 设置公共 HTTPS 端点
+2. 在事件订阅中配置请求 URL
+3. 将 `SLACK_SIGNING_SECRET` 添加到你的 `.env`
+4. 删除或留空 `SLACK_APP_TOKEN`
+
+注意:Webhook 模式需要公开可访问的 HTTPS 端点,设置更复杂。
+
+## 安全注意事项
+
+- 永远不要将令牌提交到版本控制
+- 对所有敏感数据使用环境变量
+- 定期轮换你的令牌
+- 仅向机器人授予必要的权限
+
+## 其他资源
+
+- [Slack API 文档](https://api.slack.com/)
+- [Python Slack SDK](https://slack.dev/python-slack-sdk/)
+- [Socket 模式指南](https://api.slack.com/apis/connections/socket)
\ No newline at end of file