频道和语音
Anda 可以只待在终端里,也可以接入团队频道。频道会把上下文带回同一套运行时和记忆系统。
支持的频道
- Telegram
- Discord
- Lark / 飞书
频道配置位于 ~/.anda/config.yaml 的 channels 下。
多用户
一个 daemon 可以让多个可信用户通过同一个 Anda agent 接入。先创建用户 key,再在 channel 条目的 user 中引用该 id。未配置 user 时,该 channel 使用 ~/.anda/keys/user.key 对应的本地 owner。
anda user create alice
anda user list
命令会把新用户的公钥写入顶层 users,并把匹配的私钥保存到 ~/.anda/keys/users/:
users:
- id: alice
pubkey: "ALICE_ED25519_PUBLIC_KEY"
- id: ops
pubkey: "OPS_ED25519_PUBLIC_KEY"
Telegram 示例
channels:
telegram:
- id: personal
user: alice
bot_token: "YOUR_TELEGRAM_BOT_TOKEN"
username: "YOUR_TELEGRAM_BOT_USERNAME"
allowed_users:
- "*"
mention_only: false
WeChat 示例
channels:
wechat:
- id: personal
user: alice
# 留空时,可以运行 anda channel init wechat,扫码登录并获得 token。
bot_token: ""
username: anda-wechat
allowed_users:
- "*"
Discord 示例
Discord 使用 bot token 和 Gateway 连接。先创建并安装 bot,再改 config.yaml:
- 打开 Discord Developer Portal,创建或打开你的 app。
- 在 app 的 Bot 页面复制或重置 bot token。同时在 Privileged Gateway Intents 下打开 Message Content Intent,这样 Anda 才能读取普通消息正文。
- 在 Installation 页面,让 Guild Install 包含
botscope。没有botscope 时,app 可能会出现在 Discord Apps 里,但不会作为服务器 bot 成员出现。 - 至少授予
View Channels、Send Messages和Read Message History。如果要让 Anda 发送文件,加Attach Files;如果ack_reactions: true,加Add Reactions。 - 把 app 安装到你的服务器。服务器安装成功后,bot 应该会出现在服务器成员列表里。
channels:
discord:
- id: server
user: ops
bot_token: "YOUR_DISCORD_BOT_TOKEN"
username: anda-discord
# 可选。限制这个条目只处理一个 Discord 服务器。
guild_id: "YOUR_DISCORD_GUILD_ID"
allowed_users:
- "YOUR_DISCORD_USER_ID"
mention_only: true
ack_reactions: true
配置校验层面只有 bot_token 是必填。为了实际可用并更安全,建议把 allowed_users 设为 Discord 用户 ID;当 allowed_users 为空且 allow_external_users: false 时,非 allowlist 发送者会被忽略。只有确实要让不可信外部用户以 $external_user 身份对话时,才设置 allow_external_users: true。
保存配置后运行:
anda channel list
anda restart
在服务器频道里,@ 这个 bot:
@anda-discord 总结一下这个讨论
在 bot 私信里,直接发送普通消息即可,不需要 @。如果看不到 bot,先确认 Guild Install 包含 bot scope,并确认 daemon 正在运行。
Lark / 飞书示例
channels:
lark:
- id: work
user: ops
app_id: "cli_xxx"
app_secret: "YOUR_APP_SECRET"
platform: feishu
receive_mode: websocket
mention_only: true
频道安全检查
allowed_users决定谁能触发 Anda;只有可接受开放访问时才使用"*"。user决定这个 channel 条目的会话、资源和记忆由哪个可信 Anda caller 拥有。- Telegram 和 Discord 通常需要
bot_token。 - WeChat 可以使用已保存 token,也可以在
bot_token为空时走扫码登录。 - Lark / 飞书需要
app_id和app_secret;飞书端点使用platform: feishu。 - 频道路由会被持久化,方便后续回复回到原线程、房间或联系人。
语音输入和播放
语音输入需要配置 transcription.enabled: true。启动一次语音会话:
anda voice --record-secs 8
如果还希望 Anda 播放回答,需要配置 tts.enabled: true。只需要麦克风输入和文字输出时:
anda voice --record-secs 8 --no-playback
音频附件也可以在转写启用后进入上下文,这让频道里的语音消息可以成为同一条记忆线索的一部分。