Agent Auto-Setup
Auto-create a new OpenClaw Feishu agent from App ID + Secret. Full pipeline: validate → backup → detect model → write config → create workspace → restart+verify.
Step 0: Check prerequisites
This skill requires App ID + App Secret from Feishu Open Platform.
If not yet provided, send an interactive card to collect:
请提供新机器人凭证:
快速创建链接(手机/电脑均可):
https://open.feishu.cn/page/openclaw?form=multiAgent
App ID: [输入框]
App Secret: [输入框]
【确认创建】
Use feishu_ask_user_question with free-text inputs. Bot name is auto-detected from Feishu API — do NOT ask the user for a name.
IMPORTANT — Progress notifications: After EACH step completes, send a brief reply to the user so they know the pipeline is running. Do NOT stay silent. Reply format: ⚙️ Step X/Y: [doing...] then ✅ Step X/Y done: [result].
Step 1: Validate credentials
After done: reply
✅ Step 1/10: 凭证验证通过 → {{BOT_NAME}}
curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d '{"app_id": "{{APP_ID}}", "app_secret": "{{APP_SECRET}}"}'
Expected: code: 0. Extract tenant_access_token.
Then get bot name:
curl -s "https://open.feishu.cn/open-apis/bot/v3/info" \
-H "Authorization: Bearer $TOKEN"
Extract bot.app_name from the response. This is the canonical name — use it for both botName and name.
Step 2: Backup
After done: reply
✅ Step 2/10: 配置文件已备份
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak.$(date +%Y%m%d%H%M%S)
Step 3: Detect current model
After done: reply
✅ Step 3/10: 当前模型已识别 → {{PRIMARY_MODEL}}
python3 -c "
import json
d = json.load(open('/Users/zaihuilou/.openclaw/openclaw.json'))
m = d.get('agents', {}).get('defaults', {}).get('model', {})
print('PRIMARY=' + m.get('primary', 'minimax/MiniMax-M2.7-highspeed'))
print('FALLBACKS=' + json.dumps(m.get('fallbacks', [])))
"
Use detected values for the new agent's model config.
Step 4: Read existing accounts
After done: reply
✅ Step 4/10: 已有账号 {{ACCOUNT_LIST}} → 新账号 {{ACCOUNT_KEY}}
python3 -c "
import json
d = json.load(open('/Users/zaihuilou/.openclaw/openclaw.json'))
accounts = list(d.get('channels', {}).get('feishu', {}).get('accounts', {}).keys())
print(list(accounts))
"
Determine next account key (e.g. agent3 if default, planner, moltbook exist).
Step 5: Write secret to credentials store
After done: reply
✅ Step 5/10: 凭证已写入 secrets.json
Path: ~/.openclaw/credentials/secrets.json
Read existing file, add:
"channels": {
"feishu": {
"accounts": {
"{{ACCOUNT_KEY}}": {
"appSecret": "{{APP_SECRET}}"
}
}
}
}
Write back atomically.
Step 6: Write account to openclaw.json
After done: reply
✅ Step 6/10: 账号已注册 → {{ACCOUNT_KEY}}
Read openclaw.json, add under channels.feishu.accounts:
"{{ACCOUNT_KEY}}": {
"appId": "{{APP_ID}}",
"appSecret": {
"source": "file",
"provider": "local-secrets",
"id": "/channels/feishu/accounts/{{ACCOUNT_KEY}}/appSecret"
},
"botName": "{{BOT_NAME}}",
"dmPolicy": "allowlist",
"allowFrom": ["ou_5bcd7105a9d91b7dc63a76c42dfe1880"],
"groupPolicy": "disabled"
}
Step 7: Register agent
After done: reply
✅ Step 7/10: Agent 配置已写入
Read agents config, add:
{
"id": "{{ACCOUNT_KEY}}",
"name": "{{BOT_NAME}}",
"workspace": "/Users/zaihuilou/.openclaw/workspaces/feishu-{{ACCOUNT_KEY}}",
"model": {
"primary": "{{PRIMARY_MODEL}}",
"fallbacks": {{FALLBACK_ARRAY}}
}
}
Step 8: Create workspace
After done: reply
✅ Step 8/10: Workspace 已创建
mkdir -p /Users/zaihuilou/.openclaw/workspaces/feishu-{{ACCOUNT_KEY}}/memory
Create SOUL.md:
# SOUL.md - {{BOT_NAME}}
- **Name:** {{BOT_NAME}}
- **Role:** (由主控分配的角色描述)
- **Vibe:** 直接、务实
- **Emoji:** 🤖
## Collaboration
- 主控入口:飞书 direct → 智能管家
- 接受主控派发任务,完成后汇报给主控
- 不主动在群里发言
Create AGENTS.md:
# AGENTS.md
## {{BOT_NAME}}(本 agent)
- workspace: `~/.openclaw/workspaces/feishu-{{ACCOUNT_KEY}}`
- 接受主控派发,执行后收口
Create memory/.gitkeep.
Step 9: Grant exec permission
After done: reply
✅ Step 9/10: exec 权限已授权
openclaw approvals allowlist add "*" --agent "{{ACCOUNT_KEY}}"
openclaw approvals allowlist add "*" --agent "{{ACCOUNT_KEY}}:cron"
Step 10: Restart & Verify
After done: reply
✅ Step 10/10: 全部完成!{{BOT_NAME}} 已就绪 → 去飞书搜索它发消息测试吧
openclaw gateway restart
sleep 5
After restart:
- If bot responds in Feishu DM → all good
- If no response: check
openclaw logs --tail 30
Error handling
| Error | Action | |-------|--------| | Feishu credential invalid | Report error, stop — ask user to re-check | | Config write fails | Restore backup, report error | | Gateway restart fails | Restore backup, report error | | Workspace creation fails | Report error (partial state) |
Always restore backup on failure before reporting.
Post-setup
On success:
- Tell user the new bot name and DM link
- Remind user to add bot to any Feishu groups if needed
- Tell user group routing config can be updated separately via collab-setup skill
Scan to join WeChat group