Messaging bindings and remote actions¶
The platform supports Feishu/Lark application bots, personal WeChat through Tencent iLink, and WeCom AI Bots. The background gateway receives authorized commands and sends recorded task results and alerts while the browser is closed. The platform process or standalone gateway must remain running.
Channels are disabled initially. Installation does not connect an account. Real delivery requires local credentials, platform permissions, a QR scan where applicable, and an observed account test.
Installation¶
Install egs/requirements/channels.txt into the platform's isolated Python environment. For a complete base runtime plus messaging with hashes, use egs/requirements/channels.lock.txt with pip's --require-hashes option. Model, numeric and tracing extras retain their independent profiles. Python support remains 3.10.1 through 3.14. During this development session optional packages, caches and temporary artifacts use the E drive; global installation is unnecessary.
Store credentials only in local .env. Configure non-secret policy, templates, limits and interface text in egs/config/operations/channels.yaml.
| Channel | Local environment values | Provider setup |
|---|---|---|
| Feishu/Lark | FEISHU_APP_ID, FEISHU_APP_SECRET |
Create an app with bot capability, receive-message events, long connection mode and send-as-bot permission. Publish permission changes and add the bot to the intended conversation. Select the domain in YAML. |
QR login saves WEIXIN_BOT_TOKEN and WEIXIN_BOT_ID. |
Use an eligible account and complete QR login. This is the iLink bot channel, not desktop client automation or access to arbitrary contacts. | |
| WeCom | WECOM_BOT_ID, WECOM_BOT_SECRET |
Create an AI Bot with long-connection capability and the necessary conversation permissions. |
These modes need no new public inbound webhook. Management remains behind the existing platform access boundary.
Bind and authorize¶
- Open the administration module, then System configuration → 消息渠道.
- Configure Feishu/WeCom credentials locally. For WeChat, request a QR code, scan it, then check the login result. Cancel abandoned flows; expired codes require a new flow.
- Enable the selected channel and enable the gateway. The master switch is saved locally as
ALL_IN_ONE_CHANNELS_ENABLED. A configured credential is separate from an online connection. - Send a private message to the bot. When the channel can reply, it returns a short-lived pairing code. Refresh management, select the exact pending binding ID, and enter the code from that private chat.
- Grant required permissions and resource names, then approve. Send
/helpor/statusagain. - For a binding with push permission, the administrator can deliberately request a test message. Verify receipt in the actual chat; queue acceptance is not proof that a person read it.
Binding includes channel, sender and conversation. A remote chat cannot approve itself. Empty grants permit nothing. Updating grants invalidates outstanding confirmations and queued messages from the previous revision. Revocation blocks new work and delivery, without silently cancelling an already running task. Network sends already in progress cannot be recalled.
Feishu groups require approval for the exact sender/group pair and a verified mention of the bot itself. Mentioning another person is insufficient. WeChat groups are disabled. WeCom private conversations are the supported initial setup; group callbacks are rejected without a verified provider mention flag.
Commands¶
| Command | Grant | Result |
|---|---|---|
/help, /status |
query |
Commands and this binding's request counts. |
/jobs |
query |
Granted template names. |
/task <request-id>, /report <request-id> |
query |
Own recorded status, domain task ID and bounded response. |
/ask <question> or ordinary text |
ask |
Configured model with isolated chat history. Ordinary text never becomes mutation authority. |
/kb <library-name> <question> |
ask, named library |
Existing scoped retrieval, answer and citation titles. Use library names without spaces for this command. |
/run <template-name> |
run, named template |
Preview a saved backtest, research review or permitted job. |
/cancel <request-id> |
cancel |
Preview cancellation of an own request. |
/enable <job-id>, /disable <job-id> |
schedule, matching job template |
Preview a change to an existing approved schedule. |
/confirm <code> |
Original grant | Consume one short-lived confirmation for the exact unchanged action. |
Mutations require preview and confirmation. Source, parameters, template, schedule or permission changes require a new preview. Oversized previews are rejected rather than truncated into unreviewable approvals. Commands do not accept arbitrary scripts, filesystem paths, live orders, or schedule deletion.
Long operations return a request ID immediately and execute in bounded disposable processes. Results arrive asynchronously from actual persisted outcomes. Failures and partial research results remain failed/partial. Cancellation is a request until the worker stops. An interrupted process may leave an uncertain request; inspect its referenced platform task before deciding what to do. Uncertain work is not automatically rerun.
Saved templates¶
Define actual administrator-reviewed entries under templates in YAML. The default mapping is empty; no invented resource IDs are supplied.
| Kind | Payload |
|---|---|
backtest |
Existing saved strategy_id, dates, symbols and the ordinary backtest parameter/profile fields. |
research |
Real backtest_id, objective, optional model_id, and workflow backtest_review or etf_review. |
job |
Real saved job_id; its type must also appear in safe_job_types. |
Grant template names to each binding. The initial safe job types are news fetching and system health checks. A custom executor or live-trading job is not enabled merely by granting a template name. Gateway policy reloads during its cycle; restart the gateway after transport/SDK configuration changes.
Delivery and recovery¶
Backtest and scheduler completion publish after state commits; reports retain their existing hook. Background reconciliation reads factor, system and research records without fetching new market data or calling a model. Reconciliation-only sources retain their configured discovery interval and source-window limitations.
Each binding has a persistent notification watermark and independent outbox records. Approval skips already recorded reminders. Previously undiscovered source records can still appear when reconciliation first observes them. Source discovery, local dispatch and provider delivery are different measurements.
| State | Meaning |
|---|---|
pending |
Awaiting an adapter, retry timing or WeChat context. |
sending |
A gateway claimed a network attempt. |
accepted |
Provider acceptance according to its protocol. |
failed |
Definite rejection or exhausted retries. |
ambiguous |
Untrustworthy send outcome; no blind retry. |
revoked, expired |
Grants changed, binding revoked or delivery lifetime elapsed. |
WeChat context can expire or exhaust its send budget. A fresh inbound message restores eligible pending delivery; expired authorization needs QR login again. Unrestricted proactive push after inactivity is not guaranteed. Other channels must have their own explicit subscriptions; private content is not silently forwarded elsewhere.
Management shows dependency/configuration readiness separately from live state, plus queue counts, pending age, last provider acceptance and safe error categories. Message bodies have bounded retention; hashed message identifiers and audit metadata remain as replay tombstones. Runtime databases and environment files stay private and untracked.
An enabled gateway starts with the API. Alternatively run python egs/entrypoints/messaging_gateway.py with the same environment and database. A shared lease elects one owner; other processes wait as standby. Stop owned services after tests.
Monitoring and acceptance¶
Model operations reuse HTTP/OpenAI/LiteLLM configuration, RPM limits and optional Langfuse observations. Default tracing contains metadata. Transport credentials and reply context never become model input. Outbound text masks known credentials, common private paths and recognizable internal URLs.
See channel principles, Langfuse monitoring, and notification center. Local tests verify actual HTTP/WebSocket exchanges, SDK parsing and platform state. They cannot replace account login, permission setup and an explicitly requested real-message receipt check.
Other common client channels¶
The adapter contract can support additional clients without changing the command, permission, worker or outbox layers. The following roadmap separates bidirectional chat channels from notification-only webhooks:
| Client | Typical transport | Fit for this platform | Priority |
|---|---|---|---|
| Telegram | Bot API long polling or HTTPS webhook | Best next global channel; simple private-chat pairing, groups and reliable outbound notifications. | P0 |
| Slack | Events API with Socket Mode or HTTPS | Strong enterprise choice. Socket Mode avoids a public inbound URL during local deployment; production HTTP needs signature verification and fast acknowledgement. | P0 |
| Discord | Gateway WebSocket plus REST | Good for research communities and group commands. Requires intent review, heartbeat/resume handling, guild permissions and strict message-content scope. | P1 |
| DingTalk | Stream/WebSocket or callback | Good for China enterprise teams and DingTalk cards. Stream mode is preferable for a local gateway; callback mode needs reachable HTTPS. | P1 |
| QQ / NapCat | Official bot WebSocket/callback or local bridge | Useful for domestic personal/community users. Prefer the official bot path; bridge integrations need a separate trust and update review. | P1 |
| LINE Official Account | HTTPS webhook and Messaging API | Relevant for Japan, Taiwan and Southeast Asia. Requires public HTTPS and HMAC signature verification. | P1 |
| Matrix | Client-Server API or application service | Best for self-hosted and privacy-sensitive deployments. Homeserver tokens, room ACLs and optional encryption add operational work. | P2 |
| Mattermost | REST, outgoing webhooks or slash commands | Good for self-hosted engineering teams. Interactive commands need request validation and a response deadline. | P2 |
| Microsoft Teams / Google Chat | HTTPS bot/webhook APIs | Useful for enterprise customers with existing identity and compliance controls; tenant/app configuration is required. | P2 |
| WhatsApp Business Cloud | HTTPS webhook and Graph API | Appropriate for business accounts, with Meta app review and public HTTPS. Personal-account QR bridges should not be enabled by default. | P2 |
Telegram and Slack are the recommended next additions. Telegram supports either getUpdates long polling or setWebhook; the modes are mutually exclusive for one bot. Slack Socket Mode provides a WebSocket connection without a public request URL. Discord Gateway requires heartbeat and resume handling. LINE webhooks require signature verification before parsing the body. These constraints come from the vendors' current documentation and should remain explicit in each adapter design.
Notification-only connectors can be added sooner when remote control is unnecessary: Feishu/Lark custom webhook, WeCom group robot webhook, DingTalk custom webhook, Slack incoming webhook, email/SMTP and generic signed HTTPS. They should use a separate push-only permission and must never become bidirectional command channels merely because they can post text.