Channel Integrations — via OpenClaw
AI4Meta talks to WeChat, WhatsApp, Discord, and other messengers through your existing OpenClaw instance. OpenClaw owns the platform-specific tokens (Meta Cloud API, WeChat OA, Discord bot, etc.); AI4Meta receives normalized messages from OpenClaw and returns a reply that OpenClaw delivers on the originating channel. No Meta business app, no WeChat OA AppID/AppSecret, no Discord bot token to configure inside AI4Meta.
This is the recommended setup since 2026-05-08. The earlier per-vendor approach (registering AI4Meta directly with Meta’s Graph API or WeChat OA) is described at the bottom as “Direct API (advanced)” — keep that only if you cannot run OpenClaw.
Prerequisites
- OpenClaw is running on your host or server. The runoob walkthrough — OpenClaw 接入微信 — covers the WeChat side end-to-end (install OpenClaw, install the
@tencent-weixin/openclaw-weixinplugin, scan the QR code inside the WeChat app, confirm the channel appears in OpenClaw’s control UI). For WhatsApp, the equivalent plugin is@openclaw/whatsapp. - You can reach the AI4Meta backend from wherever OpenClaw runs. The inbound webhook is HTTPS in production (
https://ai4meta.net/api/…), HTTP in local dev (http://localhost:8000/…). - You are a project owner or instructor and have the Channel Commands module enabled on the project (Project → Settings → Modules → toggle on).
How the round-trip works
- The user sends a message in WeChat / WhatsApp / Discord to a peer that OpenClaw is bound to.
- OpenClaw forwards a normalized JSON payload to AI4Meta’s lean inbound endpoint:
POST /api/v1/openclaw/<project_id>/inboundwithAuthorization: Bearer <webhook_token>. - AI4Meta verifies the bearer in constant time, runs the project chat agent, and returns the reply in the HTTP response body:
{"reply": "...", "agent": "...", "channel": "...", "peer": "..."}. - OpenClaw posts the reply back to the user via the same channel.
- The full audit trail still happens inside AI4Meta — channel commands are not a side door around the workspace.
Setup (5 minutes)
1. Generate the bridge token in AI4Meta
Open the project page → click the gear/Settings icon → in theModules tab, toggle Channel Commands on. TheOpenClaw bridge card appears below the module list with two pieces of information:
- Inbound URL (auto-generated for your project, e.g.
https://ai4meta.net/api/v1/openclaw/42/inbound) — there is a Copy URL button next to it. - Webhook token (shared secret) — click Generate to mint a 48-character random string, or paste your own. AI4Meta stores this server-side; OpenClaw stores it client-side.
Tick Enabled, save the project settings.
2. Wire OpenClaw to that URL
OpenClaw needs to call the inbound URL whenever a message arrives on a bound channel/peer. Two common ways to do that:
A. Bind a channel to a webhook agent (recommended)
Define an OpenClaw agent whose handler is “HTTP webhook” pointing at AI4Meta’s URL. Then bind the WeChat / WhatsApp peer you care about to that agent:
# Replace with your actual project_id and token.
openclaw agents add ai4meta-bridge \
--runtime http \
--endpoint https://ai4meta.net/api/v1/openclaw/42/inbound \
--header "Authorization: Bearer <webhook_token>"
# Bind a WeChat peer (or any channel/peer combination):
openclaw agents bind ai4meta-bridge \
--channel openclaw-weixin \
--peer "<wechat_openid_or_alias>"From now on, every message sent to that WeChat / WhatsApp peer is forwarded to AI4Meta and the reply is delivered back through the platform automatically.
B. Use a small adapter (when OpenClaw doesn’t expose the http runtime directly)
On the same host as OpenClaw, run a 20-line Node script that listens on a local port, calls AI4Meta over HTTP, then runs openclaw agent --channel ... --to ... --message ... --deliver with the reply text. OpenClaw’s plugin then handles delivery. Useful when you need to translate signatures or media payloads in flight.
Security model
- Per-project bearer. Every project carries its own
webhook_token. AI4Meta uses constant-time comparison. Rotate the token by clicking Generate in the bridge card; the old token is invalidated immediately. - Module gate. The endpoint returns
403when the Channel Commands module is off, even if the token matches. - Role gate. The actor that AI4Meta resolves (
sender_user_mapordefault_user_id) must be a project owner / instructor. - OpenClaw owns the platform credentials. Meta tokens, WeChat AppSecrets, and Discord bot tokens never enter AI4Meta. This is the entire reason the bridge exists.
- Audit trail. Every channel-driven action lands in the project’s normal action history; there is no separate “bot lane”.
Inbound payload shape (what OpenClaw sends)
The endpoint accepts the canonical OpenClaw webhook envelope plus a permissive set of synonyms so a hand-rolled curl, n8n, or Make scenario can hit it without translation. Minimum body:
{
"channel": "openclaw-weixin", // OpenClaw channel id
"peer": "<openid or E.164>", // platform-side sender id
"message": "What is the screening status for project 42?"
}Synonyms accepted on each field: channel / provider / source; peer / sender_id / from / openid / user; message / text / content / body. Optional fields: session_id for multi-turn threading, workspace_context to steer the agent toward a specific workspace tab, and token as a body-side fallback for the bearer when the platform won’t set headers.
Response shape (what OpenClaw delivers)
{
"reply": "Screening completed: 42 papers, 8 pending review.",
"agent": "coordinator",
"delivered": false,
"channel": "openclaw-weixin",
"peer": "<openid>",
"session_id": "<echoed if provided>",
"steps": []
}delivered: false is intentional — AI4Meta does not call the platform itself; OpenClaw handles delivery. If your OpenClaw plugin for some reason swallows the reply, set up the optional outbound bridge (next section).
Optional outbound (proactive notifications)
For events that AI4Meta wants to push without a user prompt (autopilot finished, screening conflict surfaced, …), set two environment variables on the backend container so the openclaw_bridge.send_text helper can call your gateway:
AI4META_OPENCLAW_GATEWAY_URL=http://host.docker.internal:18789
AI4META_OPENCLAW_GATEWAY_TOKEN=<gateway bearer from openclaw.json>Without those variables, AI4Meta still works fine for the request / response flow above; only the proactive push path is disabled.
Not yet implemented
- Image and file payloads. Both directions round-trip plain text only. OpenClaw can carry media; AI4Meta’s bridge endpoint ignores attachments today.
- Streaming replies. AI4Meta returns the agent reply as a single HTTP body. Streaming would require the SSE flow used in the workspace chat panel — useful but not yet wired here.
- Telegram, Slack, Signal, … already supported by OpenClaw plugins; AI4Meta’s bridge endpoint accepts whatever OpenClaw sends, so no AI4Meta changes are needed once you add an OpenClaw plugin for the new channel.
Direct API (no OpenClaw required)
If you cannot run OpenClaw, AI4Meta supports talking to the platforms directly. The credential forms live under Project → Settings → Channel Commands → OpenClaw bridge → Advanced: Direct API (no OpenClaw required) (collapsed by default because the OpenClaw path is recommended).
WhatsApp Cloud API (Meta)
Inbound URL: POST /api/projects/<project_id>/integrations/whatsapp/chat
- Phone number ID — numeric ID from the Meta business app dashboard (not the phone number itself).
- Access token — Meta Graph API token with
whatsapp_business_messaging. - Webhook token — any random string; paste into Meta’s Verify Token field.
- Minimum role —
owner/instructorrecommended.
Then in Meta business app → WhatsApp → Configuration:
- Callback URL: the inbound URL above.
- Verify token: the webhook token you saved.
- Subscribe to the
messagesfield.
WeChat Official Account (kefu API)
Inbound URL: POST /api/projects/<project_id>/integrations/wechat/chat
- AppID + AppSecret — from the WeChat OA admin console.
- Webhook token — the Token you set in 开发 → 基本配置 → 服务器配置.
Then in WeChat OA’s 服务器配置 panel:
- URL: the inbound URL above.
- Token: same value as the webhook token.
- EncodingAESKey: leave on plain text — encrypted mode is not supported in AI4Meta yet.
The server’s outbound IP must be on your OA’s whitelist or every send returns errcode 40164.
Trade-offs
| OpenClaw bridge | Direct API | |
|---|---|---|
| Setup time | ~5 min | ~30 min per platform |
| Platform credentials in AI4Meta | None | Meta token / WeChat AppSecret |
| WeChat works with personal accounts | ✓ via QR scan | ✗ Official Account only |
| WhatsApp works with personal accounts | ✓ via QR scan | ✗ Cloud API only |
| Adds a moving piece | OpenClaw process | Nothing extra |
| Image / file payloads | depends on OpenClaw plugin | Depends on AI4Meta route (currently text only) |
Related
- OpenClaw 接入微信 — runoob walkthrough
- Admin → Outbound webhooks — for Slack / Asana / Linear / Discord notifications, separate from messenger bridging.
- API reference — every endpoint, including the lean OpenClaw inbound POST.