Feishu Group Memory
Architecture
Scripts handle data only — no LLM calls inside scripts:
- -
onboarding.py — read/write industry knowledge pack config - INLINECODE1 — fetch raw messages from Feishu; save analyzed records
- INLINECODE2 — keyword search over stored records
- INLINECODE3 — SkillPay charge/balance/payment-link
All AI analysis is done by you (the OpenClaw model): deciding what to record, extracting structured fields, generating advice, writing summaries.
Quick Reference
| Operation | Script | Billed |
|---|
| Check industry config | INLINECODE4 | Free |
| Load built-in industry pack |
onboarding.py setup --industry | Free |
| Save custom industry pack |
onboarding.py save --content | Free |
| Find group by name |
listener.py find_chat --name | Free |
| Fetch raw messages |
listener.py fetch_raw | Free |
| Save analyzed records |
listener.py save_records | Free |
| Search records |
query.py search | Free |
| List records by period |
query.py list_records | Free |
| Fetch + analyze messages | (fetch
raw → you analyze → saverecords) | 0.005 USDT |
| Get AI advice | (query → you advise) | 0.003 USDT |
| Generate summary report | (list_records → you summarize) | 0.005 USDT |
First Use: Onboarding
At the start of every session, check whether an industry pack is configured:
CODEBLOCK0
- -
{"configured": true, "context": "..."} → load the context field and proceed - INLINECODE14 → run onboarding before anything else
Onboarding conversation
Ask the user:
"Before we start, I'd like to understand what your group is mainly used for so I can record and analyze the right things.
Choose one, or describe it in your own words:
- 1. 📈 Sales tracking (leads, quotes, deals)
- 🎧 Customer support (tickets, issues, complaints)
- ⚖️ Legal matters (contracts, risks, cases)
- 📋 Project management (tasks, milestones, blockers)
- ✍️ Describe my own use case"
Saving the config
Built-in industry (options 1–4):
python3 {baseDir}/scripts/onboarding.py setup \
--industry sales \
--workspace ~/.openclaw/workspace
Valid slugs:
sales /
customer-service /
legal / INLINECODE18
Custom description (option 5):
Using the user's description and the template at {baseDir}/templates/context-template.md, generate the knowledge pack yourself, then save it:
CODEBLOCK2
Confirm with the user: "Got it! I'll use this context going forward. Which group would you like me to start recording?"
Feature: Record Group Messages
Trigger: "record X group", "fetch messages from X", "capture what's been discussed in X"
Step 1 — Find the group
python3 {baseDir}/scripts/listener.py find_chat --name "KEYWORD"
If multiple results, show them and ask the user to pick one.
Step 2 — Fetch raw messages
python3 {baseDir}/scripts/listener.py fetch_raw \
--chat_id CHAT_ID \
--limit 100 \
--workspace ~/.openclaw/workspace
Returns an array of
{msg_id, time, sender, text} objects.
Step 3 — You analyze
Using the loaded industry knowledge pack (from
onboarding check), go through each message and decide:
- - Is it worth recording?
- What category does it belong to?
- Who or what is the key entity (person, company, project)?
- What structured fields can be extracted?
- What is the urgency (
high / medium / low)?
Step 4 — Save the records
CODEBLOCK5
Step 5 — Report to user
Summarize what was found, e.g.:
"Analyzed 100 messages. Saved 12 items:
- - 3 customer intent signals (Li, Wang, Chen)
- 5 follow-up actions
- 4 pricing discussions
2 high-urgency items — want me to walk through them?"
Billing
python3 {baseDir}/scripts/billing.py charge \
--user_id USER_ID --amount 0.005 --label "message analysis"
If
payment_required is returned, show the top-up link and stop.
Feature: Query Records
Trigger: "how is Wang doing", "what happened with Acme last week", "show me recent follow-ups"
CODEBLOCK7
Returns matching records as raw JSON. You turn them into a natural-language answer, e.g.:
"Here's what I have on Wang (Wang Zong):
- - Jan 15: Said he can sign next week (high priority)
- Jan 12: Asked about discount options, still considering
Last contact was 3 days ago — worth reaching out today."
No charge for queries.
Feature: AI Advice
Trigger: "how should I follow up with X", "give me some advice", "help me think through this"
First, search for relevant records:
CODEBLOCK8
Then reload the industry pack if needed:
CODEBLOCK9
Using the "Advice Templates" section of the knowledge pack and the retrieved records, give the user concrete, actionable advice directly.
CODEBLOCK10
Feature: Summary Report
Trigger: "summarize today", "weekly report", "what happened this week"
CODEBLOCK11
You write the summary. Example structure:
Weekly Summary (Jan 13–19)
28 items recorded across 7 customers.
Action required (3)
- - Li Zong: ready to sign — prepare draft contract
- Wang Zong: price sticking point — request special approval
By category
- - Customer intent: 12 | Follow-ups: 8 | Pricing: 5 | Other: 3
Suggestion: 2 customers haven't been contacted in 5+ days.
CODEBLOCK12
Error Handling
| Situation | Response |
|---|
| No industry pack configured | Run onboarding first |
| Group not found |
"I couldn't find a group called 'X'. Could you give me the full name?" |
| No records yet | "Nothing recorded yet. Want me to fetch messages from that group now?" |
|
payment_required | Show the top-up link from
message field, stop, wait for user |
| Missing Feishu credentials | Ask user to configure
channels.feishu.accounts in
openclaw.json |
飞书群聊记忆
架构
脚本仅处理数据——脚本内部不调用大语言模型:
- - onboarding.py — 读取/写入行业知识包配置
- listener.py — 从飞书获取原始消息;保存分析记录
- query.py — 对存储记录进行关键词搜索
- billing.py — SkillPay 扣费/余额/支付链接
所有AI分析由您完成(OpenClaw模型):决定记录内容、提取结构化字段、生成建议、撰写摘要。
快速参考
| 操作 | 脚本 | 计费 |
|---|
| 检查行业配置 | onboarding.py check | 免费 |
| 加载内置行业包 |
onboarding.py setup --industry | 免费 |
| 保存自定义行业包 | onboarding.py save --content | 免费 |
| 按名称查找群聊 | listener.py find_chat --name | 免费 |
| 获取原始消息 | listener.py fetch_raw | 免费 |
| 保存分析记录 | listener.py save_records | 免费 |
| 搜索记录 | query.py search | 免费 |
| 按时间段列出记录 | query.py list_records | 免费 |
| 获取+分析消息 | (fetch
raw → 您分析 → saverecords) | 0.005 USDT |
| 获取AI建议 | (query → 您提供建议) | 0.003 USDT |
| 生成摘要报告 | (list_records → 您撰写摘要) | 0.005 USDT |
首次使用:初始化
每次会话开始时,检查是否已配置行业包:
bash
python3 {baseDir}/scripts/onboarding.py check --workspace ~/.openclaw/workspace
- - {configured: true, context: ...} → 加载context字段并继续
- {configured: false} → 先运行初始化流程
初始化对话
询问用户:
在开始之前,我想了解一下您的群聊主要用途,这样我才能正确记录和分析相关内容。
请选择一项,或用您自己的话描述:
- 1. 📈 销售跟踪(线索、报价、交易)
- 🎧 客户支持(工单、问题、投诉)
- ⚖️ 法律事务(合同、风险、案件)
- 📋 项目管理(任务、里程碑、障碍)
- ✍️ 描述我自己的使用场景
保存配置
内置行业(选项1–4):
bash
python3 {baseDir}/scripts/onboarding.py setup \
--industry sales \
--workspace ~/.openclaw/workspace
有效标识:sales / customer-service / legal / project
自定义描述(选项5):
使用用户的描述和{baseDir}/templates/context-template.md模板,自行生成知识包,然后保存:
bash
python3 {baseDir}/scripts/onboarding.py save \
--content 您生成的内容 \
--workspace ~/.openclaw/workspace
向用户确认:已收到!我将使用此上下文继续。您希望我开始记录哪个群聊?
功能:记录群聊消息
触发词:记录X群聊、从X获取消息、捕获X中讨论的内容
第1步 — 查找群聊
bash
python3 {baseDir}/scripts/listener.py find_chat --name 关键词
如果返回多个结果,展示给用户并请其选择一个。
第2步 — 获取原始消息
bash
python3 {baseDir}/scripts/listener.py fetch_raw \
--chat
id CHATID \
--limit 100 \
--workspace ~/.openclaw/workspace
返回{msg_id, time, sender, text}对象数组。
第3步 — 您进行分析
使用已加载的行业知识包(来自onboarding check),逐条检查每条消息并决定:
- - 是否值得记录?
- 属于哪个类别?
- 关键实体是谁/什么(人员、公司、项目)?
- 可以提取哪些结构化字段?
- 紧急程度如何(high / medium / low)?
第4步 — 保存记录
bash
python3 {baseDir}/scripts/listener.py save_records \
--chat
id CHATID \
--workspace ~/.openclaw/workspace \
--records [{msg
id:...,time:...,sender:...,rawtext:...,category:...,key_entity:...,summary:...,fields:{...},urgency:high}]
第5步 — 向用户报告
总结发现的内容,例如:
分析了100条消息。保存了12个项目:
- - 3个客户意向信号(李总、王总、陈总)
- 5个跟进动作
- 4个价格讨论
2个高紧急项目——需要我逐一说明吗?
计费
bash
python3 {baseDir}/scripts/billing.py charge \
--user
id USERID --amount 0.005 --label 消息分析
如果返回payment_required,显示充值链接并停止。
功能:查询记录
触发词:王总怎么样了、上周Acme发生了什么、显示最近的跟进
bash
python3 {baseDir}/scripts/query.py search \
--query 关键词 \
--workspace ~/.openclaw/workspace
返回匹配记录的原始JSON。您将其转化为自然语言回答,例如:
关于王总,我这里有这些记录:
- - 1月15日:表示下周可以签约(高优先级)
- 1月12日:询问折扣方案,仍在考虑中
上次联系是3天前——今天值得跟进一下。
查询不收费。
功能:AI建议
触发词:我该怎么跟进X、给我一些建议、帮我思考一下
首先,搜索相关记录:
bash
python3 {baseDir}/scripts/query.py search \
--query 关键词 \
--workspace ~/.openclaw/workspace
然后,如有需要重新加载行业包:
bash
python3 {baseDir}/scripts/onboarding.py check --workspace ~/.openclaw/workspace
使用知识包中的建议模板部分和检索到的记录,直接向用户提供具体、可操作的建议。
bash
python3 {baseDir}/scripts/billing.py charge \
--userid USERID --amount 0.003 --label AI建议
功能:摘要报告
触发词:总结今天、周报、这周发生了什么
bash
python3 {baseDir}/scripts/query.py list_records \
--period today|week|all \
--workspace ~/.openclaw/workspace
您撰写摘要。 示例结构:
周报(1月13日–19日)
共记录28个项目,涉及7个客户。
需要处理(3项)
- - 李总:准备签约——起草合同草案
- 王总:价格分歧——申请特殊审批
按类别统计
- - 客户意向:12 | 跟进:8 | 定价:5 | 其他:3
建议: 2个客户已超过5天未联系。
bash
python3 {baseDir}/scripts/billing.py charge \
--userid USERID --amount 0.005 --label 摘要报告
错误处理
我找不到名为X的群聊。您能提供完整名称吗? |
| 尚无记录 | 暂无记录。需要我现在从该群聊获取消息吗? |
| payment_required | 显示message字段中的充值链接,停止,等待用户 |
| 缺少飞书凭证 | 请用户在openclaw.json中配置channels.feishu.accounts |