Skip to content

Commit 96d1829

Browse files
committed
feat: add Unified Webhook Mode support and update related documentation
1 parent 5ebc11a commit 96d1829

File tree

14 files changed

+186
-42
lines changed

14 files changed

+186
-42
lines changed

.vitepress/config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export default defineConfig({
170170
{ text: "知识库", link: "/knowledge-base" },
171171
{ text: "自定义规则", link: "/custom-rules" },
172172
{ text: "Agent 执行器", link: "/agent-runner" },
173+
{ text: "统一 Webhook 模式", link: "/unified-webhook" },
173174
{ text: "沙箱化代码执行器(beta)", link: "/code-interpreter" },
174175
],
175176
},
@@ -389,6 +390,7 @@ export default defineConfig({
389390
{ text: "Knowledge Base", link: "/knowledge-base" },
390391
{ text: "Custom Rules", link: "/custom-rules" },
391392
{ text: "Agent Runner", link: "/agent-runner" },
393+
{ text: "Unified Webhook Mode", link: "/unified-webhook" },
392394
{ text: "Sandboxed Code Interpreter (beta)", link: "/code-interpreter" },
393395
],
394396
},

en/deploy/platform/slack.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,29 @@ Slack supports two connection methods: `Webhook` and `Socket`. If you don't have
5151

5252
## Start the Platform Adapter
5353

54-
The configuration is now complete. If you're using Socket mode, simply click the Save button in the bottom right corner of the configuration. If you're using Webhook mode, you can also configure the Slack Webhook Host, Slack Webhook Port, and Slack Webhook Path according to your needs. Generally, using the default values is sufficient.
54+
The configuration is now complete. If you're using Socket mode, simply click the Save button in the bottom right corner of the configuration.
55+
56+
If you're using Webhook mode, please keep `Unified Webhook Mode (unified_webhook_mode)` enabled.
57+
58+
> [!TIP]
59+
> Before v4.8.0, there is no `Unified Webhook Mode`. You need to fill in the following configuration items:
60+
> Slack Webhook Host, Slack Webhook Port, and Slack Webhook Path
5561
5662

5763
## Enable Event Subscriptions
5864

5965
After successfully creating the platform adapter, return to the Slack settings. In the Event Subscriptions page on the left sidebar, click Enable Events to enable event reception.
6066

61-
If you're using Webhook mode, enter `https://your-domain/astrbot-slack-webhook/callback` in the `Request URL` field that appears.
67+
If you're using Webhook mode:
68+
69+
- If `Unified Webhook Mode` is enabled, after clicking save, AstrBot will automatically generate a unique Webhook callback URL for you. You can find it in the logs or on the bot card in the WebUI's Bots page. Enter this URL in the `Request URL` field.
70+
71+
![unified_webhook](/source/images/use/unified-webhook.png)
72+
73+
- If `Unified Webhook Mode` is not enabled, enter `https://your-domain/astrbot-slack-webhook/callback` in the `Request URL` field.
6274

6375
> [!TIP]
64-
> In Webhook mode, you need to first set up your domain with your DNS provider, then use reverse proxy software to proxy the Slack Webhook Port you configured in the previous step to your domain. Alternatively, you can use Cloudflare Tunnel. For detailed tutorials, please refer to online resources; this tutorial will not cover these in detail.
76+
> In Webhook mode, you need to first set up your domain with your DNS provider, then use reverse proxy software to forward requests to port `6185` on the AstrBot server (if Unified Webhook Mode is enabled) or the port specified in your configuration (if Unified Webhook Mode is not enabled). Alternatively, you can use Cloudflare Tunnel. For detailed tutorials, please refer to online resources; this tutorial will not cover these in detail.
6577
6678
After enabling, under Subscribe to bot events below, click Add Bot User Event and add the following events:
6779

en/deploy/platform/wecom.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ AstrBot 支持接入企业微信应用和微信客服。
3535

3636
如果您之前使用过微信客服机器人,那么在 `开发配置` 中直接找到 `回调配置`,点击修改。
3737

38-
回调 URL 填写: `http://你的带公网地址的服务器ip:6195/callback/command`
38+
点击下方的两个随机获取,得到 `Token``EncodingAESKey`,复制到 AstrBot 配置的 `token``encoding_aes_key` 处。请保持 `统一 Webhook 模式 (unified_webhook_mode)` 为开启状态。然后点击保存配置,等待适配器加载完成。
3939

40-
> 请注意放行端口
40+
回调 URL 填写:
4141

42-
点击下方的两个随机获取,得到 `Token``EncodingAESKey`,复制到 AstrBot 配置的 `token``encoding_aes_key` 处,然后点击保存配置,等待适配器加载完成。
42+
- 如果开启了 `统一 Webhook 模式`,点击保存之后,AstrBot 将会自动为你生成唯一的 Webhook 回调链接,你可以在日志中或者 WebUI 的机器人页的卡片上找到,将该链接填入回调 URL 处。
43+
44+
![unified_webhook](/source/images/use/unified-webhook.png)
45+
46+
- 如果没有开启 `统一 Webhook 模式`,填写 `http://你的带公网地址的服务器ip:6195/callback/command`
47+
48+
> 请注意放行端口。如果开启了统一 Webhook 模式,需要将请求转发到 AstrBot 所在服务器的 `6185` 端口;如果没有开启,则转发到配置指定的端口(默认 `6195`)。
4349
4450
回到微信客服 `回调配置`,点击 `完成`。如果一切无误,将会显示 `已完成`(否则会显示类似 `openapi 回调不通过` 类似的文本)。
4551

@@ -81,13 +87,19 @@ AstrBot 支持接入企业微信应用和微信客服。
8187

8288
![image](/source/images/wecom/image-9.png)
8389

84-
在 URL 处填入 `http://你的带公网地址的服务器ip:6195/callback/command`
90+
并且点击下方的两个随机获取,得到 `Token``EncodingAESKey`,复制到 AstrBot 配置的 `token``encoding_aes_key` 处。建议保持 `统一 Webhook 模式 (unified_webhook_mode)` 为开启状态。
91+
92+
现在应该已经填完 AstrBot 连接到企业微信的所有配置项。点击 AstrBot 配置页右下角保存,等待 AstrBot 重启。
8593

86-
> 请注意放行端口
94+
在 URL 处填入回调地址:
8795

88-
并且点击下方的两个随机获取,得到 `Token``EncodingAESKey`,复制到 AstrBot 配置的 `token``encoding_aes_key` 处。
96+
- 如果开启了 `统一 Webhook 模式`,点击保存之后,AstrBot 将会自动为你生成唯一的 Webhook 回调链接,你可以在日志中或者 WebUI 的机器人页的卡片上找到,将该链接填入 URL 处。
8997

90-
现在应该已经填完 AstrBot 连接到企业微信的所有配置项。点击 AstrBot 配置页右下角保存,等待 AstrBot 重启。
98+
![unified_webhook](/source/images/use/unified-webhook.png)
99+
100+
- 如果没有开启 `统一 Webhook 模式`,填入 `http://你的带公网地址的服务器ip:6195/callback/command`
101+
102+
> 请注意放行端口。如果开启了统一 Webhook 模式,需要将请求转发到 AstrBot 所在服务器的 `6185` 端口;如果没有开启,则转发到配置指定的端口(默认 `6195`)。
91103
92104
接下来配置企业可信 IP。
93105

en/deploy/platform/wecom_ai_bot.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ AstrBot 在 v4.3.5 版本开始支持接入企业微信智能机器人平台。
2222

2323
![新增适配器](/source/images/wecom_ai_bot/image-2.png)
2424

25-
2. 在弹出的配置项中将 `企业微信智能机器人的名字``token``encoding_aes_key` 从上一步创建智能机器人时填写的值复制粘贴到对应的输入框中。ID 可以随意填写,用于区分不同的消息平台实例。`port` 默认为 `6198`,可以根据需要修改,但请确保该端口未被占用。点击 `保存`
25+
2. 在弹出的配置项中将 `企业微信智能机器人的名字``token``encoding_aes_key` 从上一步创建智能机器人时填写的值复制粘贴到对应的输入框中。ID 可以随意填写,用于区分不同的消息平台实例。`port` 默认为 `6198`,可以根据需要修改,但请确保该端口未被占用。请保持 `统一 Webhook 模式 (unified_webhook_mode)` 为开启状态。点击 `保存`
2626

27-
3. 回到企业微信智能机器人创建页面,填写 `URL``http://IP:port/webhook/wecom-ai-bot`,其中 `IP` 替换为你的 AstrBot 服务器的公网 IP 地址,`port` 替换为上一步填写的端口号。
27+
3. 回到企业微信智能机器人创建页面,填写 `URL`
2828

29-
> 建议有能力的用户自行配置域名和反向代理,并使用 HTTPS 协议。如果没有域名,也可以使用 [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/)
29+
- 如果开启了 `统一 Webhook 模式`,点击保存之后,AstrBot 将会自动为你生成唯一的 Webhook 回调链接,你可以在日志中或者 WebUI 的机器人页的卡片上找到,将该链接填入 `URL` 处。
30+
31+
![unified_webhook](/source/images/use/unified-webhook.png)
32+
33+
- 如果没有开启 `统一 Webhook 模式`,填写 `http://IP:port/webhook/wecom-ai-bot`,其中 `IP` 替换为你的 AstrBot 服务器的公网 IP 地址,`port` 替换为上一步填写的端口号。
34+
35+
> 建议有能力的用户自行配置域名和反向代理,将请求转发到 AstrBot 所在服务器的 `6185` 端口(如果开启了统一 Webhook 模式)或配置指定的端口(如果没有开启统一 Webhook 模式),并使用 HTTPS 协议。如果没有域名,也可以使用 [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/)
3036
3137
4. 点击 `创建` 按钮,如果一切无误,将进入智能机器人详情页面。如果报错 `服务没有正确响应,请确认后重试`,请检查 AstrBot 的配置、服务器防火墙端口放行规则等。
3238

en/deploy/platform/weixin-official-account.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,23 @@ AstrBot 支持接入微信公众平台(版本 >= v3.5.8),并以微信公
3636
找到下方的服务器配置,然后点击修改配置。
3737

3838

39-
`URL` 请填入 `http://你的域名/callback/command`
40-
41-
> 注意⚠️:仅支持 80 或者 443 端口。您可能需要购买域名,然后反向代理 6194 端口的流量,或者将 6194 端口改成 80 端口(注意服务器需要没有软件在占用 80 端口)。
42-
4339
`Token` 由自己填写,请随意填写一个字符串,长度 3-32 位。并同样填入 AstrBot 配置的 `token` 处(一定要相同)。
4440

4541
`EncodingAESKey` 请点击随机生成,然后复制到 AstrBot 配置的 `encoding_aes_key` 处。
4642

47-
现在应该已经填完 AstrBot 连接到企业微信的所有配置项。点击 AstrBot 配置页右下角保存,等待 AstrBot 重启。
43+
建议保持 `统一 Webhook 模式 (unified_webhook_mode)` 为开启状态。
44+
45+
现在应该已经填完 AstrBot 连接到微信公众平台的所有配置项。点击 AstrBot 配置页右下角保存,等待 AstrBot 重启。
46+
47+
`URL` 填写:
48+
49+
- 如果开启了 `统一 Webhook 模式`,点击保存之后,AstrBot 将会自动为你生成唯一的 Webhook 回调链接,你可以在日志中或者 WebUI 的机器人页的卡片上找到,将该链接填入 URL 处。
50+
51+
![unified_webhook](/source/images/use/unified-webhook.png)
52+
53+
- 如果没有开启 `统一 Webhook 模式`,请填入 `http://你的域名/callback/command`
54+
55+
> 注意⚠️:仅支持 80 或者 443 端口。您可能需要购买域名,然后反向代理流量到 AstrBot 所在服务器的 `6185` 端口(如果开启了统一 Webhook 模式)或 `6194` 端口(如果没有开启统一 Webhook 模式),或者将端口改成 80 端口(注意服务器需要没有软件在占用 80 端口)。
4856
4957
消息加解密方式请选中 `安全模式`
5058

en/use/unified-webhook.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Unified Webhook Mode
2+
3+
Starting from v4.8.0, AstrBot supports Unified Webhook Mode (unified_webhook_mode). When this mode is enabled, all platform adapters that support it will use the same Webhook callback endpoint, simplifying reverse proxy and domain configuration. You no longer need to configure separate ports, domains, and reverse proxies for each bot adapter.
4+
5+
Platform adapters that support Unified Webhook Mode include:
6+
7+
- Slack Webhook Mode
8+
- WeChat Official Account
9+
- WeCom Application
10+
- WeCom AI Bot
11+
- WeChat Customer Service Bot
12+
- QQ Official Bot Webhook Mode
13+
- ...
14+
15+
## How to Use Unified Webhook Mode
16+
17+
1. Have a domain (e.g., example.com) and a server with a public IP
18+
2. Configure DNS resolution (e.g., astrbot.example.com)
19+
3. Configure reverse proxy to forward requests from port 80 or 443 of your domain to AstrBot's WebUI port (default is 6185)
20+
4. Go to AstrBot's `Configuration` page, click `System`, and set the `Externally Reachable Callback URL` to your configured URL (e.g., https://astrbot.example.com). Click save and wait for restart.
21+
22+
When configuring each platform adapter afterwards, enable `Unified Webhook Mode (unified_webhook_mode)`.
23+
24+
![unified_webhook](/source/images/use/unified-webhook-config.png)
25+
26+
Once this mode is enabled, AstrBot will generate a unique Webhook callback URL for you. You just need to fill this URL into each platform's callback address field.
27+
28+
![unified_webhook](/source/images/use/unified-webhook.png)
105 KB
Loading
19.4 KB
Loading

zh/deploy/platform/qqofficial/webhook.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
# 通过 QQ官方机器人 接入 QQ (Webhook)
33

4-
## 申请一个机器人
5-
64
> [!WARNING]
75
>
86
> 1. 截至目前,QQ 官方机器人需要设置 IP 白名单。
97
> 2. 支持群聊、私聊、频道聊天、频道私聊。
108
>
11-
> 需要一台带有公网 IP 的服务器和域名(如果没备案,需要服务器在海外或者中国港澳台)
9+
> **需要**一台带有公网 IP 的服务器和域名(如果没备案,需要服务器在海外或者中国港澳台地区)
10+
11+
## 申请一个机器人
1212

1313
首先,打开 [QQ官方机器人](https://q.qq.com) 并登录。
1414

@@ -51,16 +51,26 @@
5151
- 启用(enable): 勾选。
5252
- appid: QQ 官方机器人中获取的 appid。
5353
- secret: QQ 官方机器人中获取的 secret。
54+
- 统一 Webhook 模式 (unified_webhook_mode): 保持开启。
5455

5556
点击 `保存`
5657

58+
## 反向代理
59+
60+
保存之后,请根据你的服务器环境,配置域名 DNS 解析和反向代理,将请求转发到 AstrBot 所在服务器的 `6185` 端口 (如果没有开启统一 Webhook 模式,将请求转发到上一步配置指定的端口)。
61+
5762
## 设置回调地址
5863

59-
`开发->回调配置` 处,配置回调地址。这需要你拥有一个公网 IP 服务器和域名。
64+
`开发->回调配置` 处,配置回调地址。
65+
66+
上一步点击保存之后,AstrBot 将会自动为你生成唯一的 Webhook 回调链接,你可以在日志中或者 WebUI 的机器人页的卡片上找到。
67+
68+
![unified_webhook](/source/images/use/unified-webhook.png)
6069

61-
请求地址填写 `<你的域名>/astrbot-qo-webhook/callback`
70+
将请求地址填写为该地址。
6271

63-
你的域名应当通过 `Caddy`, `Nginx`, `Apache` 等 Web 服务器反向代理来自 AstrBot 暴露的 `6196` 端口的流量。
72+
> [!TIP]
73+
> v4.8.0 之前没有 `统一 Webhook 模式`,则请求地址填写 `<你的域名>/astrbot-qo-webhook/callback`
6474
6575
填写好之后,添加事件,四个事件类型都全选:单聊事件、群事件、频道事件等,如下图。
6676

zh/deploy/platform/slack.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,28 @@ Slack 支持两种接入方式:`Webhook` 与 `Socket`。如果您没有公网
5151

5252
## 启动平台适配器
5353

54-
现在,配置已经完成。如果您使用的是 Socket 模式,那么直接点击配置的右下角的保存按钮即可。如果您使用的是 Webhook 模式,还可以按照您的需要来设置配置中的 Slack Webhook Host、Slack Webhook Port 和 Slack Webhook Path。一般来说使用默认值已经足够。
54+
现在,配置已经完成。如果您使用的是 Socket 模式,那么直接点击配置的右下角的保存按钮即可。
5555

56+
如果您使用的是 Webhook 模式,请保持 `统一 Webhook 模式 (unified_webhook_mode)` 为开启状态。
57+
58+
> [!TIP]
59+
> v4.8.0 之前没有 `统一 Webhook 模式`,请填写以下配置项:
60+
> Slack Webhook Host、Slack Webhook Port 和 Slack Webhook Path
5661
5762
## 开启事件接收
5863

5964
新建平台适配器成功后,返回到 Slack 设置,在左边栏 Event Subscriptions 页下,点击 Enable Events 启用事件接收。
6065

61-
如果您使用的是 Webhook 模式,请在在出现的 `Request URL` 输入框中输入 `https://您的域名/astrbot-slack-webhook/callback`
66+
如果您使用的是 Webhook 模式:
67+
68+
- 如果开启了 `统一 Webhook 模式`,点击保存之后,AstrBot 将会自动为你生成唯一的 Webhook 回调链接,你可以在日志中或者 WebUI 的机器人页的卡片上找到,将该链接填入 `Request URL` 输入框中。
69+
70+
![unified_webhook](/source/images/use/unified-webhook.png)
71+
72+
- 如果没有开启 `统一 Webhook 模式`,请在 `Request URL` 输入框中输入 `https://您的域名/astrbot-slack-webhook/callback`
6273

6374
> [!TIP]
64-
> Webhook 模式下,您需要先在 DNS 服务商处设置好域名,然后使用反向代理软件将上一步中填写的 Slack Webhook Port 反向代理到您设置的域名。或者您可以使用 Cloudflare Tunnel。具体教程请参考网络资源,本教程不赘述。
75+
> Webhook 模式下,您需要先在 DNS 服务商处设置好域名,然后使用反向代理软件将请求转发到 AstrBot 所在服务器的 `6185` 端口(如果开启了统一 Webhook 模式)或配置指定的端口(如果没有开启统一 Webhook 模式)。或者您可以使用 Cloudflare Tunnel。具体教程请参考网络资源,本教程不赘述。
6576
6677
启用后,在下方的 Subscribe to bot events 处,点击 Add Bot User Event,添加如下事件:
6778

0 commit comments

Comments
 (0)