Skip to content

Commit 215614c

Browse files
committed
docs: update lark webhook
1 parent 4355b5c commit 215614c

File tree

3 files changed

+86
-52
lines changed

3 files changed

+86
-52
lines changed

en/deploy/platform/lark.md

Lines changed: 63 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,101 @@
1-
# 接入飞书
1+
# Connecting to Lark
22

3-
## 常见问题
3+
## Creating a Bot
44

5-
如果发现 `加载平台适配器 lark 失败,原因:No module named 'lark_oapi'。请检查依赖库是否安装。提示:可以在 管理面板->控制台->安装Pip库 中安装依赖库。` 报错,说明没有安装 `lark_oapi` 库,请根据提示安装或者直接通过 pip 安装。
5+
Navigate to the [Developer Console](https://open.feishu.cn/app) and create a custom enterprise application.
66

7-
## 创建机器人
7+
![Create Custom Enterprise Application](/source/images/lark/image.png)
88

9-
前往 [开发者后台](https://open.feishu.cn/app) ,创建企业自建应用。
9+
Add the Bot capability to your application.
1010

11-
![创建企业自建应用](/source/images/lark/image.png)
11+
![Add Bot Capability](/source/images/lark/image-1.png)
1212

13-
添加应用能力——机器人。
13+
Click on "Credentials & Basic Info" to obtain your app_id and app_secret.
1414

15-
![添加应用能力](/source/images/lark/image-1.png)
15+
![Get app_id and app_secret](/source/images/lark/image-4.png)
1616

17-
点击凭证与基础信息,获取 app_id 和 app_secret。
17+
## Configuring AstrBot
1818

19-
![获取 app_id 和 app_secret](/source/images/lark/image-4.png)
19+
1. Access the AstrBot management panel
20+
2. Click on `Bots` in the left sidebar
21+
3. In the right panel, click `+ Create Bot`
22+
4. Select `lark`
2023

21-
## 配置 AstrBot
24+
Fill in the configuration fields as follows:
2225

23-
1. 进入 AstrBot 的管理面板
24-
2. 点击左边栏 `机器人`
25-
3. 然后在右边的界面中,点击 `+ 创建机器人`
26-
4. 选择 `lark(飞书)`
26+
- ID: Choose any identifier to distinguish between different messaging platform instances
27+
- Enable: Check this option
28+
- app_id: The app_id you obtained earlier
29+
- app_secret: The app_secret you obtained earlier
30+
- Bot name: Your Lark bot's name
2731

28-
弹出的配置项填写:
32+
For the domain field, if you're using Lark China, keep the default value. If you're using Lark International, set it to `https://open.larksuite.com`. If you're using a self-hosted enterprise Lark instance, enter your Lark instance's domain.
2933

30-
- ID(id):随意填写,用于区分不同的消息平台实例。
31-
- 启用(enable): 勾选。
32-
- app_id: 获取的 app_id
33-
- app_secret: 获取的 app_secret
34-
- 飞书机器人的名字
34+
For the subscription method, `socket` uses a long connection subscription approach, while `webhook` sends events to your developer server and requires a public server. Generally, `socket` is recommended. However, if you're using Lark International or a self-hosted Lark instance, choose `webhook`. The subsequent configuration steps will differ accordingly.
3535

36-
如果您正在用国际版飞书,请将 `domain` 设置为 `https://open.larksuite.com`
36+
If you selected the `webhook` method, navigate to the Lark Developer Console, click on "Events & Callbacks," then "Encryption Policy," and fill in the Encrypt Key. While not mandatory, AstrBot takes your data security seriously, so we strongly recommend setting this up. After filling it in, copy the `Encrypt Key` and `Verification Token` to the corresponding `encrypt_key` and `verification_token` fields in AstrBot's configuration.
3737

38-
点击 `保存`
38+
Click `Save`.
3939

40-
## 设置回调和权限
40+
## Setting up Callbacks and Permissions
4141

42-
接下来,点击事件与回调,使用长连接接收事件,点击保存。**如果上一步没有成功启动,那么这里将无法保存。**
42+
The following steps vary depending on the subscription method you selected above. Please proceed to the corresponding section based on your choice.
4343

44-
![设置事件与回调](/source/images/lark/image-6.png)
44+
### `socket` Long Connection Method
4545

46-
点击添加事件,消息与群组,下拉找到 `接收消息`,添加。
46+
Next, click on "Events & Callbacks," select "Receive events using long connection," and click Save. **If the previous step didn't start successfully, you won't be able to save here.**
4747

48-
![添加事件](/source/images/lark/image-7.png)
48+
![Configure Events & Callbacks](/source/images/lark/image-6.png)
4949

50-
点击开通以下权限。
50+
### `webhook` Send Events to Developer Server Method
5151

52-
![开通权限](/source/images/lark/image-8.png)
52+
> [!TIP]
53+
> To make better use of this method, please refer to [Unified Webhook Mode](/zh/use/unified-webhook.md#如何使用统一-webhook-模式) for the necessary configuration.
5354
54-
再点击上面的`保存`按钮。
55+
After clicking `Save`, the bot card will display "View Webhook URL." Click to view and copy the callback URL.
5556

56-
接下来,点击权限管理,点击开通权限,输入 `im:message:send,im:message,im:message:send_as_bot`。添加筛选到的权限。
57+
![](/source/images/lark/webhook.png)
5758

58-
再次输入 `im:resource:upload,im:resource` 开通上传图片相关的权限。
59+
Next, return to Lark's Events & Callbacks page, click "Event Configuration," select "Send events to developer server," enter the callback URL you just copied as the "Request URL," and click Save. If everything is correct, no errors will appear.
5960

60-
最终开通的权限如下图:
61+
### Setting up Events
6162

62-
![最终开通的权限](/source/images/lark/image-11.png)
63+
After completing the event configuration in the previous step, click "Add Event," navigate to "Messages & Groups," scroll down to find `Receive Message`, and add it.
6364

64-
## 创建版本
65+
![Add Event](/source/images/lark/image-7.png)
6566

66-
创建版本。
67+
Click to enable the following permissions.
6768

68-
![创建版本](/source/images/lark/image-2.png)
69+
![Enable Permissions](/source/images/lark/image-8.png)
6970

70-
填写版本号,更新说明,可见范围后点击保存,确认发布。
71+
Then click the `Save` button at the top.
7172

72-
## 拉入机器人到群组
73+
Next, click on "Permission Management," click "Enable Permissions," and enter `im:message:send,im:message,im:message:send_as_bot`. Add the filtered permissions.
7374

74-
进入飞书 APP(网页版飞书无法添加机器人),点进群聊,点击右上角按钮->群机器人->添加机器人。
75+
Enter `im:resource:upload,im:resource` again to enable image upload permissions.
7576

76-
搜索刚刚创建的机器人的名字。比如教程创建了 `AstrBot` 机器人:
77+
The final set of permissions should look like this:
7778

78-
![添加机器人](/source/images/lark/image-9.png)
79+
![Final Permissions](/source/images/lark/image-11.png)
7980

80-
## 🎉 大功告成
81+
## Creating a Version
8182

82-
在群内发送一个 `/help` 指令,机器人将做出响应。
83+
Create a new version.
8384

84-
![成功](/source/images/lark/image-13.png)
85+
![Create Version](/source/images/lark/image-2.png)
86+
87+
Fill in the version number, update notes, and visibility scope, then click Save and confirm the release.
88+
89+
## Adding the Bot to a Group
90+
91+
Open the Lark app (the web version doesn't support adding bots), enter a group chat, click the button in the upper right corner → Group Bots → Add Bot.
92+
93+
Search for the bot you just created. For example, if you created the `AstrBot` bot as shown in this tutorial:
94+
95+
![Add Bot](/source/images/lark/image-9.png)
96+
97+
## 🎉 All Done!
98+
99+
Send a `/help` command in the group, and the bot will respond.
100+
101+
![Success](/source/images/lark/image-13.png)

source/images/lark/webhook.png

41.4 KB
Loading

zh/deploy/platform/lark.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# 接入飞书
22

3-
## 常见问题
4-
5-
如果发现 `加载平台适配器 lark 失败,原因:No module named 'lark_oapi'。请检查依赖库是否安装。提示:可以在 管理面板->控制台->安装Pip库 中安装依赖库。` 报错,说明没有安装 `lark_oapi` 库,请根据提示安装或者直接通过 pip 安装。
6-
73
## 创建机器人
84

95
前往 [开发者后台](https://open.feishu.cn/app) ,创建企业自建应用。
@@ -33,17 +29,38 @@
3329
- app_secret: 获取的 app_secret
3430
- 飞书机器人的名字
3531

36-
如果您正在用国际版飞书,请将 `domain` 设置为 `https://open.larksuite.com`
32+
对于 domain,如果您使用国内版飞书,保持默认即可;如果您正在用国际版飞书,请设置为 `https://open.larksuite.com`;如果您使用企业自部署飞书,请填写您的飞书实例的域名。
33+
34+
对于订阅方式,`socket` 代表使用「长连接」订阅方式,`webhook` 代表「将事件发送至开发者服务器」的订阅方式,后者需要您拥有公网服务器。一般来说使用 `socket` 即可,如果您使用国际版飞书或者企业自部署飞书,请选择 `webhook`。相应地,接下来的配置也会有所不同。
35+
36+
如果您选择了 `webhook` 方式,选择了之后,前往飞书的开发者后台,点击事件与回调,点击加密策略,填写 Encrypt Key。这不是必须的,AstrBot 十分注重你的数据安全,所以请务必填写。填写后复制 `Encrypt Key``Verification Token` 到 AstrBot 配置的 `encrypt_key``verification_token` 处。
3737

3838
点击 `保存`
3939

4040
## 设置回调和权限
4141

42+
对于上面选择的订阅方式,接下来的步骤有所不同,请你根据实际选择的方式,跳转到对应的章节。
43+
44+
### `socket` 长连接方式
45+
4246
接下来,点击事件与回调,使用长连接接收事件,点击保存。**如果上一步没有成功启动,那么这里将无法保存。**
4347

4448
![设置事件与回调](/source/images/lark/image-6.png)
4549

46-
点击添加事件,消息与群组,下拉找到 `接收消息`,添加。
50+
### `webhook` 将事件发送至开发者服务器方式
51+
52+
> [!TIP]
53+
> 为了更好地使用这种方式,请先参考 [统一 Webhook 模式](/zh/use/unified-webhook.md#如何使用统一-webhook-模式) 做好相关配置。
54+
55+
在点击 `保存` 后,机器人卡片会显示「查看 Webhook 链接」,点击查看,复制回调 URL。
56+
57+
![](/source/images/lark/webhook.png)
58+
59+
接下来,回到飞书的事件与回调页,点击「事件配置」,选择「将事件发送至开发者服务器」,将“请求地址”填写为刚刚复制的回调 URL,点击保存。如果一切无误将不会报错。
60+
61+
### 设置事件
62+
63+
上一步事件配置完成后,点击添加事件,消息与群组,下拉找到 `接收消息`,添加。
4764

4865
![添加事件](/source/images/lark/image-7.png)
4966

0 commit comments

Comments
 (0)