企业微信配置LangBot通信机器人
1. 安装 LangBot
GitHub 地址:https://github.com/langbot-app/LangBot?tab=readme-ov-file
官方文档 : https://docs.langbot.app/zh/insight/guide
1.1 下载安装
在远程服务器中下载安装
$ docker --version
Docker version 27.5.1, build 27.5.1-0ubuntu3~22.04.2
$ docker-compose version
Docker Compose version v2.39.0
$ git clone https://github.com/langbot-app/LangBot
$ cd LangBot
$ docker-compose up -d
WARN[0000] /home/ubuntu/LangBot/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
[+] Running 1/1✔ Container langbot Started $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
69838295f8b6 rockchin/langbot:latest "uv run main.py" 33 minutes ago Up 6 minutes 0.0.0.0:2280-2290->2280-2290/tcp, :::2280-2290->2280-2290/tcp, 0.0.0.0:5300->5300/tcp, :::5300->5300/tcp langbot
0e3e85e53288 ghcr.io/open-webui/open-webui:ollama "bash start.sh" 2 weeks ago Up 2 weeks (healthy) 0.0.0.0:3001->8080/tcp, [::]:3001->8080/tcp open-webui
19a9eb355ece postgres:15 "docker-entrypoint.s…" 4 weeks ago Up 4 weeks 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp my-postgres
...
查看日志:
$ docker-compose logs -f langbot
WARN[0000] /home/ubuntu/LangBot/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
langbot | /app/.venv/lib/python3.12/site-packages/nakuru/misc.py:50: SyntaxWarning: invalid escape sequence '\['
langbot | for m in re.compile("(\[CQ:(.+?)])").finditer(text):
langbot | [08-28 16:13:16.044] mgr.py (39) - [INFO] : Initializing database...
langbot | [08-28 16:13:16.208] mgr.py (57) - [INFO] : Creating initial metadata...
langbot | [08-28 16:13:16.234] mgr.py (71) - [INFO] : Creating default pipeline...
langbot | [08-28 16:13:16.255] mgr.py (118) - [INFO] : Migration 1 completed.
langbot | [08-28 16:13:16.269] mgr.py (118) - [INFO] : Migration 2 completed.
langbot | [08-28 16:13:16.280] mgr.py (118) - [INFO] : Migration 3 completed.
langbot | [08-28 16:13:16.292] mgr.py (118) - [INFO] : Migration 4 completed.
langbot | [08-28 16:13:16.303] mgr.py (118) - [INFO] : Migration 5 completed.
langbot | [08-28 16:13:16.304] mgr.py (120) - [INFO] : Successfully upgraded database to version 5.
langbot | [08-28 16:13:16.305] manager.py (73) - [INFO] : Loading all plugins...
langbot | [08-28 16:13:16.348] modelmgr.py (61) - [INFO] : Loading models from db...
langbot | [08-28 16:13:16.984] botmgr.py (202) - [INFO] : Loading bots from db...
langbot | [08-28 16:13:16.988] pipelinemgr.py (239) - [INFO] : Loading pipelines from db...
langbot | [08-28 16:13:16.990] kbmgr.py (162) - [INFO] : Loading knowledge bases from db...
langbot | [08-28 16:13:17.439] app.py (197) - [INFO] : =======================================
langbot | [08-28 16:13:17.440] app.py (197) - [INFO] : ✨ Access WebUI / 访问管理面板
langbot | [08-28 16:13:17.441] app.py (197) - [INFO] :
langbot | [08-28 16:13:17.441] app.py (197) - [INFO] : 🏠 Local Address: http://127.0.0.1:5300/
langbot | [08-28 16:13:17.442] app.py (197) - [INFO] : 🌐 Public Address: http://<Your Public IP>:5300/
langbot | [08-28 16:13:17.443] app.py (197) - [INFO] :
langbot | [08-28 16:13:17.444] app.py (197) - [INFO] : 📌 Running this program in a container? Please ensure that the 5300 port is exposed
langbot | [08-28 16:13:17.444] app.py (197) - [INFO] : =======================================
langbot | [08-28 16:13:18.042] show_notes.py (32) - [INFO] : New version available:
langbot | 有新版本可用,根据文档更新:
langbot | https://docs.langbot.app/zh/deploy/update.html
langbot | [08-28 16:13:18.043] show_notes.py (32) - [INFO] : Current Version: v4.2.1
langbot | [2025-08-28 16:13:18 +0800] [11] [INFO] Running on http://0.0.0.0:5300 (CTRL + C to quit)
langbot |
langbot | _ ___ _
langbot | | | __ _ _ _ __ _| _ ) ___| |_
langbot | | |__/ _` | ' \/ _` | _ \/ _ \ _|
langbot | |____\__,_|_||_\__, |___/\___/\__|
langbot | |___/
langbot |
langbot | ⭐️ Open Source 开源地址: https://github.com/langbot-app/LangBot
langbot | 📖 Documentation 文档地址: https://docs.langbot.app
langbot |
langbot | [Startup] Prechecking plugin dependencies...
langbot | 以下文件不存在,已自动生成:
langbot | Following files do not exist and have been automatically generated:
langbot | - plugins/__init__.py
langbot | - data/config.yaml
langbot | [2025-08-28 16:22:41 +0800] [11] [INFO] 223.104.83.85:9881 GET /login 1.1 200 16419 7060
...
1.2 登录
1.2.1 放开端口
服务器防火墙中 放开端口
1.2.2 登录
浏览器登录:http://49.51.197.197:5300/
其中49.51.197.197为服务器公网 IP
本地登录为:http://127.0.0.1:5300/
注册:
输入邮箱、密码后登录如下图:
成功登录:
2. 搭建企业微信机器人
部署企业微信机器人官网文档:https://docs.langbot.app/zh/deploy/platforms/wecom/wecom.html
2.1 配置参数
打开企业微信后台:
2.1.1 企业ID
My Company --> Company information --> Company ID(在页面最下端)
2.1.2 通讯录密钥:
Security and Management --> Management Tool --> Sync of Contacts --> Secret --> View --> Send
通讯录密钥在企业微信:
信息–>企业微信团队–> View Now
2.1.3 密钥
App Management --> Apps --> Self-built–> Create an app
App(小白虎) --> Secret -->View -->Send
密钥在企业微信:
信息–>企业微信团队–> View Now
2.1.4 令牌、消息加解密密钥
App(小白虎)—>Company’s Trusted IP(在页面最下端) --> Set the server URL for receiving messages
接着:
点击 Token 和 EncodingAESKey 旁边的 Get randomly 按钮,然后出现
Token 下面的字符复制到 LangBot 令牌
EncodingAESKey 下面的字符复制到 LangBot 消息加解密密钥
URL 输入:
http://49.51.197.197:2290/callback/command
顺序:
-
先在LangBot 创建的机器人填入五个配置参数后点提交,然后点击启用,最后点击保存
-
然后再这个企业微信后台页面点击 保存
-
此时出现下面这个页面,就表示配置成功
企业微信成功回掉LangBot
4. 验证
在LangBot服务器日志中;
$ docker-compose logs -f langbot
...
langbot | [2025-08-28 18:56:05 +0800] [9] [INFO] 14.116.241.251:36878 GET /callback/command 1.1 200 19 33479
...
14.116.241.251 为企业微信服务器的地址
$ curl -s https://ipinfo.io/14.116.241.251
{"ip": "14.116.241.251","city": "Shenzhen","region": "Guangdong","country": "CN","loc": "22.5455,114.0683","org": "AS4134 CHINANET-BACKBONE","postal": "518000","timezone": "Asia/Shanghai","readme": "https://ipinfo.io/missingauth"
$ whois 14.116.241.251 | grep -E "netname|descr|organization|country"
netname: CHINANET-GD
descr: CHINANET Guangdong province network
descr: Data Communication Division
descr: China Telecom
country: CN
country: ZZ
country: CN
country: CN
2.2 测试
2.2.1 LangBot 配置内置模型
2.2.2 LangBot 配置流水线
基础信息默认
2.2.3 对话
在企业微信 工作台 中找到创建的 App, 点击对话:
不回应
查看日志,报错:
...
langbot | [08-28 20:04:47.166] pipelinemgr.py (212) - [ERROR] : 处理请求时出错 query_id=2 stage=SendResponseBackStage : Failed to send message: {'errcode': 60020, 'errmsg': 'not allow to access from your ip, hint: [1756382686347801122384167], from ip: 49.51.197.197, more info at https://open.work.weixin.qq.com/devtool/query?e=60020'}
langbot | ERROR: 处理请求时出错 query_id=2 stage=SendResponseBackStage : Failed to send message: {'errcode': 60020, 'errmsg': 'not allow to access from your ip, hint: [1756382686347801122384167], from ip: 49.51.197.197, more info at https://open.work.weixin.qq.com/devtool/query?e=60020'}
not allow to access from your ip ,没有添加可信任 IP
解决问题:
App(小白虎)—>Company’s Trusted IP(在页面最下端)
重新测试:
搭建成功!!!