跳到主要内容

设置消息平台

当你要让一个外部聊天平台接入 resident Anyy gateway 时,从这页开始。平台字段细节见 Messaging Platforms 下的对应页面。

Channels 是 gateway 功能

Channels 不在一次性的 CLI 调用里运行。要让入站消息、出站回复、cron deliveries 或 background-job notifications 通过消息平台流转,需要先启动 resident gateway。

先选一个已实现 Channel

一次先配置一个平台,并完成端到端验证后再添加更多。

已实现的 channel names:

NamePlatform
telegramTelegram
discordDiscord
slackSlack
whatsappWhatsApp
facebookFacebook Messenger
emailEmail (IMAP/SMTP)
smsSMS through Twilio
dingtalkDingTalk
feishuFeishu / Lark
weixinWeixin / WeChat
qqbotQQ Bot
ircIRC
lineLINE

Catalog 命令会显示本地 setup 状态:

anyy setup channels

它会打印支持的 catalog,并提示你运行 anyy setup channels CHANNEL --write-config。Planned catalog entries 可能会出现,但在 runtime adapter 发布前,只会返回 planned-status JSON payload。

创建平台凭据

先在外部平台创建凭据。Anyy 通常需要以下几类:

类型示例
Bot tokenTelegram、Discord、Slack、Weixin
App id plus secretFeishu、DingTalk、QQ Bot
Webhook token 或 secretLINE、SMS、Facebook
Bridge URL/tokenWhatsApp
Host/login secretEmail、IRC

--secret NAME=VALUE 保存 secrets。Setup command 会写 profile-local secret files,并只把 secret: references 写入 config.yaml

写入 Channel Config

使用 direct setup form:

anyy setup channels CHANNEL \
--account-id ACCOUNT_ID \
--secret NAME=VALUE \
--set FIELD=VALUE \
--write-config

示例:

anyy setup channels discord \
--secret bot_token='discord-bot-token' \
--write-config

命令会输出 JSON,其中包含 config path、redacted secret refs、写入的 secret names 和 doctor command。只有传入 --write-config 时,才会写入 channels.<name>

allow_fromallow_groupschannelsmention_aliases 这类 list 字段,应在 setup 后按 YAML list 编辑:

channels:
discord:
dm_policy: allowlist
allow_from:
- "user-id"

启动或 Reload Gateway

Channels 运行在 resident gateway 里:

anyy gateway start

gateway 运行期间改了 channel config 后:

anyy channels reload

如果 reload 失败,确认 gateway 使用的是同一个 profile/home:

anyy gateway status
anyy status

运行 Channel Doctor

同时运行 channel-specific doctor 和 general doctor:

anyy channels doctor CHANNEL
anyy doctor

channels doctor 是离线 config check。它验证 config shape、必填字段、secret refs 和已知 readiness gates。它不会创建外部平台 app、注册 webhook,也不会调用平台 API。

大范围使用前先收紧访问

把 bot 邀进群组或大 workspace 前,先配置 admission policy:

channels:
slack:
dm_policy: allowlist
group_policy: mention
allow_from:
- "U0123456789"
allow_groups:
- "C0123456789"

常用 policy:

Policy用途
open无需 pairing,接受匹配的 sender 或 group。
pairingadapter 支持时允许初次 pairing。
allowlist只接受配置的 ids。
mention群组里需要 mention 才响应。
disabled忽略对应 scope 的入站消息。

Channel access 控制谁能接触 Anyy。它不会给高风险工具额外权限。Approvals、ChangePlans、audit 和 tool policy 仍然生效。

验证真实消息

从目标平台发送一条小命令:

/status

再发送一条普通消息:

Say hello in one short sentence.

如果命令可用但普通 chat 不可用,检查 provider/model config。如果两者都不可用,检查 gateway logs、channel policy、anyy channels doctor CHANNEL,以及平台 setup 页里的故障排查。