diff --git a/channel/web/web_channel.py b/channel/web/web_channel.py index 2a5e71b8..766c7126 100644 --- a/channel/web/web_channel.py +++ b/channel/web/web_channel.py @@ -713,8 +713,9 @@ class WebChannel(ChatChannel): logger.info("[WebChannel] 5. dingtalk - 钉钉") logger.info("[WebChannel] 6. wecom_bot - 企微智能机器人") logger.info("[WebChannel] 7. wechatcom_app - 企微自建应用") - logger.info("[WebChannel] 8. wechatmp - 个人公众号") - logger.info("[WebChannel] 9. wechatmp_service - 企业公众号") + logger.info("[WebChannel] 8. wechatcom_kf - 微信客服") + logger.info("[WebChannel] 9. wechatmp - 个人公众号") + logger.info("[WebChannel] 10. wechatmp_service - 企业公众号") logger.info("[WebChannel] ✅ Web控制台已运行") logger.info(f"[WebChannel] 🌐 本地访问: http://localhost:{port}") if is_public_bind: @@ -1271,6 +1272,19 @@ class ChannelsHandler: {"key": "wechatcomapp_port", "label": "Port", "type": "number", "default": 9898}, ], }), + ("wechatcom_kf", { + "label": {"zh": "微信客服", "en": "WeCom Customer Service"}, + "icon": "fa-headset", + "color": "emerald", + "fields": [ + # wechatcom_corp_id is shared with wechatcom_app — same key, same value. + {"key": "wechatcom_corp_id", "label": "Corp ID", "type": "text"}, + {"key": "wechatcom_kf_secret", "label": "Secret", "type": "secret"}, + {"key": "wechatcom_kf_token", "label": "Token", "type": "secret"}, + {"key": "wechatcom_kf_aes_key", "label": "AES Key", "type": "secret"}, + {"key": "wechatcom_kf_port", "label": "Port", "type": "number", "default": 9888}, + ], + }), ("wechatmp", { "label": {"zh": "公众号", "en": "WeChat MP"}, "icon": "fa-comment-dots", diff --git a/docs/channels/wecom-kf.mdx b/docs/channels/wecom-kf.mdx index db6fa0bb..42a13991 100644 --- a/docs/channels/wecom-kf.mdx +++ b/docs/channels/wecom-kf.mdx @@ -45,30 +45,41 @@ description: 将 CowAgent 接入微信客服(WeCom Customer Service) ## 三、配置和运行 -在 `config.json` 中添加以下配置(各参数与企业微信后台的对应关系见上方截图): +填入上一步收集到的 4 个字段(Corp ID / Secret / Token / EncodingAESKey): -```json -{ - "channel_type": "wechatcom_kf", - "wechatcom_corp_id": "YOUR_CORP_ID", - "wechatcom_kf_secret": "YOUR_SECRET", - "wechatcom_kf_token": "YOUR_TOKEN", - "wechatcom_kf_aes_key": "YOUR_AES_KEY", - "wechatcom_kf_port": 9888 -} -``` + + + 启动 Cow 项目后打开 Web 控制台,选择 **通道** 菜单,点击 **接入通道**,选择 **微信客服**,依次填入 Corp ID / Secret / Token / AES Key(端口默认 9888,可改),点击接入即可。 -| 参数 | 说明 | -| --- | --- | -| `wechatcom_corp_id` | 企业 ID | -| `wechatcom_kf_secret` | 绑定到微信客服的那个企微自建应用的 Secret | -| `wechatcom_kf_token` | API 接收配置中的 Token | -| `wechatcom_kf_aes_key` | API 接收配置中的 EncodingAESKey | -| `wechatcom_kf_port` | 监听端口,默认 9888 | + + + + 在 `config.json` 中添加以下配置(各参数与企业微信后台的对应关系见上方截图): -配置完成后启动程序。当日志中出现 `Listening on http://0.0.0.0:9888/wxkf/` 时,说明程序运行成功,需要将该端口对外开放(如在云服务器安全组中放行)。 + ```json + { + "channel_type": "wechatcom_kf", + "wechatcom_corp_id": "YOUR_CORP_ID", + "wechatcom_kf_secret": "YOUR_SECRET", + "wechatcom_kf_token": "YOUR_TOKEN", + "wechatcom_kf_aes_key": "YOUR_AES_KEY", + "wechatcom_kf_port": 9888 + } + ``` -程序启动后,回到企业微信「接收消息 → 设置API接收」,将回调 URL 填为 `http://:9888/wxkf/`,点击保存。保存成功后还需将服务器 IP 添加到 **企业可信IP** 中,否则无法收发消息: + | 参数 | 说明 | + | --- | --- | + | `wechatcom_corp_id` | 企业 ID | + | `wechatcom_kf_secret` | 绑定到微信客服的那个企微自建应用的 Secret | + | `wechatcom_kf_token` | API 接收配置中的 Token | + | `wechatcom_kf_aes_key` | API 接收配置中的 EncodingAESKey | + | `wechatcom_kf_port` | 监听端口,默认 9888 | + + + +接入完成后启动程序(Web 控制台方式会自动重启),日志中出现 `Listening on http://0.0.0.0:9888/wxkf/` 表示运行成功,需要将该端口对外开放(如在云服务器安全组中放行)。 + +接着回到企业微信「接收消息 → 设置API接收」,将回调 URL 填为 `http://:9888/wxkf/`,点击保存。保存成功后还需将服务器 IP 添加到 **企业可信IP** 中,否则无法收发消息: diff --git a/docs/en/channels/wecom-kf.mdx b/docs/en/channels/wecom-kf.mdx index 541becac..1dd973ce 100644 --- a/docs/en/channels/wecom-kf.mdx +++ b/docs/en/channels/wecom-kf.mdx @@ -45,30 +45,41 @@ Required resources: ## 3. Configuration and Run -Add the following configuration to `config.json` (each parameter maps to a field shown in the screenshots above): +Fill in the 4 fields collected from the previous step (Corp ID / Secret / Token / EncodingAESKey): -```json -{ - "channel_type": "wechatcom_kf", - "wechatcom_corp_id": "YOUR_CORP_ID", - "wechatcom_kf_secret": "YOUR_SECRET", - "wechatcom_kf_token": "YOUR_TOKEN", - "wechatcom_kf_aes_key": "YOUR_AES_KEY", - "wechatcom_kf_port": 9888 -} -``` + + + Start the Cow project and open the Web Console. Go to the **Channels** menu, click **Connect**, choose **WeCom Customer Service**, fill in Corp ID / Secret / Token / AES Key (port defaults to 9888, configurable), and click Connect. -| Parameter | Description | -| --- | --- | -| `wechatcom_corp_id` | Corp ID | -| `wechatcom_kf_secret` | Secret of the WeCom custom app bound to Customer Service | -| `wechatcom_kf_token` | Token from the API reception config | -| `wechatcom_kf_aes_key` | EncodingAESKey from the API reception config | -| `wechatcom_kf_port` | Listening port, default 9888 | + + + + Add the following configuration to `config.json` (each parameter maps to a field shown in the screenshots above): -After configuration, start the program. When the log shows `Listening on http://0.0.0.0:9888/wxkf/`, the program is running successfully. You need to open this port externally (e.g., allow it in the cloud server security group). + ```json + { + "channel_type": "wechatcom_kf", + "wechatcom_corp_id": "YOUR_CORP_ID", + "wechatcom_kf_secret": "YOUR_SECRET", + "wechatcom_kf_token": "YOUR_TOKEN", + "wechatcom_kf_aes_key": "YOUR_AES_KEY", + "wechatcom_kf_port": 9888 + } + ``` -Once the program is running, go back to **Receive Messages → Set API Reception** in the WeCom console and set the callback URL to `http://:9888/wxkf/`, then click Save. After saving successfully, you also need to add the server IP to **Enterprise Trusted IPs**, otherwise messages cannot be sent or received: + | Parameter | Description | + | --- | --- | + | `wechatcom_corp_id` | Corp ID | + | `wechatcom_kf_secret` | Secret of the WeCom custom app bound to Customer Service | + | `wechatcom_kf_token` | Token from the API reception config | + | `wechatcom_kf_aes_key` | EncodingAESKey from the API reception config | + | `wechatcom_kf_port` | Listening port, default 9888 | + + + +After connecting, start the program (the Web Console method restarts the channel automatically). When the log shows `Listening on http://0.0.0.0:9888/wxkf/`, the program is running successfully. You need to open this port externally (e.g., allow it in the cloud server security group). + +Then go back to **Receive Messages → Set API Reception** in the WeCom console and set the callback URL to `http://:9888/wxkf/`, then click Save. After saving successfully, you also need to add the server IP to **Enterprise Trusted IPs**, otherwise messages cannot be sent or received: diff --git a/docs/ja/channels/wecom-kf.mdx b/docs/ja/channels/wecom-kf.mdx index bcf63c04..25de67ff 100644 --- a/docs/ja/channels/wecom-kf.mdx +++ b/docs/ja/channels/wecom-kf.mdx @@ -45,30 +45,41 @@ WeCom の自建アプリを「微信客服(WeCom Customer Service)」アカ ## 3. 設定と起動 -`config.json` に以下の設定を追加します(各パラメータと WeCom コンソールの対応関係は上のスクリーンショットを参照してください): +前のステップで収集した 4 つのフィールド(Corp ID / Secret / Token / EncodingAESKey)を入力します: -```json -{ - "channel_type": "wechatcom_kf", - "wechatcom_corp_id": "YOUR_CORP_ID", - "wechatcom_kf_secret": "YOUR_SECRET", - "wechatcom_kf_token": "YOUR_TOKEN", - "wechatcom_kf_aes_key": "YOUR_AES_KEY", - "wechatcom_kf_port": 9888 -} -``` + + + Cow プロジェクトを起動した後、Web コンソールを開きます。**チャネル** メニューを選択し、**接入チャネル** をクリックし、**微信客服** を選択して、Corp ID / Secret / Token / AES Key を入力し(ポートはデフォルト 9888、変更可能)、接入をクリックします。 -| パラメータ | 説明 | -| --- | --- | -| `wechatcom_corp_id` | 企業 ID | -| `wechatcom_kf_secret` | カスタマーサービスにバインドした企業微信自建アプリの Secret | -| `wechatcom_kf_token` | API 受信設定の Token | -| `wechatcom_kf_aes_key` | API 受信設定の EncodingAESKey | -| `wechatcom_kf_port` | リスンポート、デフォルトは 9888 | + + + + `config.json` に以下の設定を追加します(各パラメータと WeCom コンソールの対応関係は上のスクリーンショットを参照してください): -設定後、プログラムを起動します。ログに `Listening on http://0.0.0.0:9888/wxkf/` と表示されれば、プログラムは正常に動作しています。このポートを外部に公開する必要があります(例:クラウドサーバーのセキュリティグループで許可します)。 + ```json + { + "channel_type": "wechatcom_kf", + "wechatcom_corp_id": "YOUR_CORP_ID", + "wechatcom_kf_secret": "YOUR_SECRET", + "wechatcom_kf_token": "YOUR_TOKEN", + "wechatcom_kf_aes_key": "YOUR_AES_KEY", + "wechatcom_kf_port": 9888 + } + ``` -プログラム起動後、WeCom 管理コンソールの **メッセージ受信 → API 受信設定** に戻り、コールバック URL に `http://:9888/wxkf/` を入力して保存します。保存が成功したら、サーバー IP を **企業の信頼済み IP** に追加する必要もあります。追加しないとメッセージの送受信ができません: + | パラメータ | 説明 | + | --- | --- | + | `wechatcom_corp_id` | 企業 ID | + | `wechatcom_kf_secret` | カスタマーサービスにバインドした企業微信自建アプリの Secret | + | `wechatcom_kf_token` | API 受信設定の Token | + | `wechatcom_kf_aes_key` | API 受信設定の EncodingAESKey | + | `wechatcom_kf_port` | リスンポート、デフォルトは 9888 | + + + +接入完了後、プログラムを起動します(Web コンソール方式ではチャネルが自動的に再起動されます)。ログに `Listening on http://0.0.0.0:9888/wxkf/` と表示されれば、プログラムは正常に動作しています。このポートを外部に公開する必要があります(例:クラウドサーバーのセキュリティグループで許可します)。 + +続いて、WeCom 管理コンソールの **メッセージ受信 → API 受信設定** に戻り、コールバック URL に `http://:9888/wxkf/` を入力して保存します。保存が成功したら、サーバー IP を **企業の信頼済み IP** に追加する必要もあります。追加しないとメッセージの送受信ができません: