mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-20 05:27:59 +08:00
docs: make English the default docs language and fix link paths
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
---
|
||||
title: Slack
|
||||
description: 将 CowAgent 接入 Slack App
|
||||
description: Integrate CowAgent with a Slack App
|
||||
---
|
||||
|
||||
> 通过 Slack App 的 **Socket Mode** 接入 CowAgent,支持私聊(DM)与频道(@机器人 / 线程内回复触发)。Socket Mode 基于长连接,无需公网 IP 与回调地址,开箱即用。
|
||||
> Integrate CowAgent into Slack via a Slack App in **Socket Mode**. Supports direct messages (DM) and channels (triggered by @mention or replying within a thread). Socket Mode uses a persistent WebSocket connection — no public IP or callback URL required, works out of the box.
|
||||
|
||||
## 一、接入步骤
|
||||
## 1. Setup
|
||||
|
||||
### 步骤一:创建 Slack App
|
||||
### Step 1: Create a Slack App
|
||||
|
||||
1. 打开 [Slack API 应用管理页](https://api.slack.com/apps),点击 **Create New App** → **From scratch**。
|
||||
2. 填写 **App Name**(如 `CowAgent`),选择要安装的 **Workspace**,点击创建。
|
||||
1. Open the [Slack API apps page](https://api.slack.com/apps), click **Create New App** → **From scratch**.
|
||||
2. Enter an **App Name** (e.g. `CowAgent`), pick the **Workspace** to install into, and create it.
|
||||
|
||||
### 步骤二:开启 Socket Mode 并获取 App Token
|
||||
### Step 2: Enable Socket Mode and get the App Token
|
||||
|
||||
1. 左侧菜单进入 **Settings → Socket Mode**,打开 **Enable Socket Mode**。
|
||||
2. 系统会提示生成一个 **App-Level Token**,作用域勾选 `connections:write`,生成后保存这串以 `xapp-` 开头的 Token。
|
||||
1. In the left sidebar go to **Settings → Socket Mode** and turn on **Enable Socket Mode**.
|
||||
2. You will be prompted to generate an **App-Level Token** with the `connections:write` scope. Save this token starting with `xapp-`.
|
||||
|
||||
<Tip>
|
||||
Socket Mode 通过 WebSocket 长连接接收事件,无需在公网暴露回调 URL,适合本地或内网部署。
|
||||
Socket Mode receives events over a WebSocket connection, so you don't need to expose a public callback URL — ideal for local or intranet deployments.
|
||||
</Tip>
|
||||
|
||||
### 步骤三:配置 Bot 权限并安装
|
||||
### Step 3: Configure bot scopes and install
|
||||
|
||||
1. 进入 **Features → OAuth & Permissions**,在 **Bot Token Scopes** 中点击 **Add an OAuth Scope**,逐项添加以下权限:
|
||||
1. Go to **Features → OAuth & Permissions**, click **Add an OAuth Scope** under **Bot Token Scopes**, and add the following scopes one by one:
|
||||
|
||||
```
|
||||
app_mentions:read
|
||||
@@ -39,10 +39,10 @@ description: 将 CowAgent 接入 Slack App
|
||||
```
|
||||
|
||||
<Note>
|
||||
`files:read` / `files:write` 用于图片、文件的收发;若仅需文本对话可省略。
|
||||
`files:read` / `files:write` are used for sending/receiving images and files; omit them if you only need text conversations.
|
||||
</Note>
|
||||
|
||||
2. 进入 **Features → Event Subscriptions**,打开 **Enable Events**,在 **Subscribe to bot events** 中点击 **Add Bot User Event** 添加以下事件:
|
||||
2. Go to **Features → Event Subscriptions**, turn on **Enable Events**, and under **Subscribe to bot events** click **Add Bot User Event** to add:
|
||||
|
||||
```
|
||||
app_mention
|
||||
@@ -51,23 +51,23 @@ description: 将 CowAgent 接入 Slack App
|
||||
```
|
||||
|
||||
<Note>
|
||||
如需在私有频道使用,再添加 `message.groups`。
|
||||
Add `message.groups` if you need to use the bot in private channels.
|
||||
</Note>
|
||||
3. 进入 **Features → App Home**,在 **Show Tabs** 区域勾选 **Messages Tab**,并勾选下方的 **Allow users to send Slash commands and messages from the messages tab**(允许用户从消息标签页发送消息),否则私聊输入框会被关闭、无法给机器人发消息。
|
||||
4. 回到 **OAuth & Permissions**,点击 **Install to Workspace** 完成安装,安装后获取以 `xoxb-` 开头的 **Bot User OAuth Token**。
|
||||
3. Go to **Features → App Home**, enable **Messages Tab** under **Show Tabs**, and check **Allow users to send Slash commands and messages from the messages tab**. Otherwise the DM input box is disabled and users cannot message the bot.
|
||||
4. Back in **OAuth & Permissions**, click **Install to Workspace**. After installing, copy the **Bot User OAuth Token** starting with `xoxb-`.
|
||||
|
||||
<Tip>
|
||||
若 Slack 客户端仍提示「向此应用发送消息的功能已关闭」,请确认已完成上一步的 App Home 设置,并刷新或重启 Slack 客户端(必要时把 App 从对话列表移除后重新打开)。
|
||||
If the Slack client still shows "Sending messages to this app has been turned off", make sure you completed the App Home step above, then refresh or restart the Slack client (remove the app from your conversations and reopen it if needed).
|
||||
</Tip>
|
||||
|
||||
### 步骤四:接入 CowAgent
|
||||
### Step 4: Connect to CowAgent
|
||||
|
||||
<Tabs>
|
||||
<Tab title="Web 控制台(推荐)">
|
||||
打开 Web 控制台(本地链接:http://127.0.0.1:9899 ),选择 **通道** 菜单,点击 **接入通道**,选择 **Slack**,分别填入 Bot Token(`xoxb-`)和 App Token(`xapp-`),点击接入即可。
|
||||
<Tab title="Web Console (Recommended)">
|
||||
Open the Web Console (default `http://127.0.0.1:9899`), go to **Channels**, click **Add Channel**, choose **Slack**, paste the Bot Token (`xoxb-`) and App Token (`xapp-`), and click connect.
|
||||
</Tab>
|
||||
<Tab title="配置文件">
|
||||
在 `config.json` 中添加以下配置后启动:
|
||||
<Tab title="Config File">
|
||||
Add the following to `config.json` and start Cow:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -78,41 +78,41 @@ description: 将 CowAgent 接入 Slack App
|
||||
}
|
||||
```
|
||||
|
||||
| 参数 | 说明 | 默认值 |
|
||||
| Key | Description | Default |
|
||||
| --- | --- | --- |
|
||||
| `slack_bot_token` | Bot User OAuth Token,形如 `xoxb-...` | - |
|
||||
| `slack_app_token` | App-Level Token(开启 Socket Mode 后生成),形如 `xapp-...` | - |
|
||||
| `slack_group_trigger` | 频道触发方式:`mention_or_reply`(@或线程内回复)/ `mention_only`(仅@) / `all`(所有消息) | `mention_or_reply` |
|
||||
| `slack_bot_token` | Bot User OAuth Token, like `xoxb-...` | - |
|
||||
| `slack_app_token` | App-Level Token (generated after enabling Socket Mode), like `xapp-...` | - |
|
||||
| `slack_group_trigger` | Channel trigger: `mention_or_reply` (@ or reply in thread) / `mention_only` (@ only) / `all` (all messages) | `mention_or_reply` |
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
启动 Cow 后,日志中出现以下输出即表示接入成功:
|
||||
The integration is ready when you see logs like:
|
||||
|
||||
```
|
||||
[Slack] Bot logged in as user_id=U0XXXXXXX, team=Txxxxxxxx
|
||||
[Slack] ✅ Slack bot ready, listening for events
|
||||
```
|
||||
|
||||
## 二、功能说明
|
||||
## 2. Capabilities
|
||||
|
||||
| 功能 | 支持情况 |
|
||||
| Feature | Support |
|
||||
| --- | --- |
|
||||
| 私聊(DM) | ✅ |
|
||||
| 频道(@机器人 / 线程内回复) | ✅ |
|
||||
| 文本消息 | ✅ 收发 |
|
||||
| 图片消息 | ✅ 收发 |
|
||||
| 文件消息 | ✅ 收发(PDF / Word / Excel 等) |
|
||||
| 线程回复 | ✅ 回复发送至触发消息所在线程 |
|
||||
| Direct message (DM) | ✅ |
|
||||
| Channel (@bot / reply in thread) | ✅ |
|
||||
| Text messages | ✅ send / receive |
|
||||
| Image messages | ✅ send / receive |
|
||||
| File messages | ✅ send / receive (PDF / Word / Excel, etc.) |
|
||||
| Thread replies | ✅ replies are posted to the thread of the triggering message |
|
||||
|
||||
<Note>
|
||||
Slack 通过线程(Thread)组织对话。机器人会把回复发送到触发消息所在的线程,频道内更整洁。
|
||||
Slack organizes conversations into threads. The bot posts replies into the thread of the triggering message, keeping channels tidy.
|
||||
</Note>
|
||||
|
||||
## 三、使用
|
||||
## 3. Usage
|
||||
|
||||
完成接入后:
|
||||
Once connected:
|
||||
|
||||
- **私聊(DM)**:在 Slack 左侧 **Apps** 中找到你的 App,直接发消息对话。
|
||||
- **频道**:把 App 邀请进频道(`/invite @你的App`),使用 `@你的App 你好` 触发对话;后续在同一线程内直接回复即可继续对话。
|
||||
- **Direct message (DM)**: find your App under **Apps** in the Slack sidebar and message it directly.
|
||||
- **Channel**: invite the App into a channel (`/invite @your-app`), then trigger it with `@your-app hello`; continue the conversation by replying within the same thread.
|
||||
|
||||
发送图片或文件时,可以在附件的输入框中 **添加文字说明**(描述/问题)一并发送,机器人会结合附件回答。也支持先发附件再发问题,两条消息会自动合并提问。
|
||||
When sending an image or file, you can **add a text caption** (description / question) in the attachment input — the bot will answer based on both. Sending an attachment first and then a follow-up question also works; the two messages are merged automatically.
|
||||
|
||||
Reference in New Issue
Block a user