Chat History Local
/install chat-history-local
Chat History Search
Search and reference past conversations from the audit log database.
⚠️ Two Databases — Know the Difference
There are TWO PostgreSQL databases on port 15432:
| Database | Table | Purpose | Use when |
|---|---|---|---|
openclaw_audit |
messages |
WhatsApp/chat messages — who said what, when, in which chat | Searching conversations, finding what someone said, quoting messages |
openclaw_audit |
audit_log |
LLM API costs — model usage, tokens, cost per call | Checking spending, model usage stats, cost analysis |
For message search: always use the messages table.
Database Connection
- Host: 127.0.0.1, Port: 15432, User: postgres, DB: openclaw_audit
- psql:
LC_ALL=C /opt/homebrew/Cellar/postgresql@18/18.2/bin/psql -h 127.0.0.1 -p 15432 -U postgres -d openclaw_audit - Important: Must use PG 18 binary and
LC_ALL=Cprefix
Messages Table Schema
| Column | Type | Description |
|---|---|---|
| id | bigint | Auto-increment PK |
| ts | timestamptz | Message timestamp |
| message_id | text | WhatsApp message ID (use for reply_to) |
| chat_id | text | Chat identifier (+972... for direct, [email protected] for groups) |
| chat_type | text | direct / group / device / unknown |
| chat_name | text | Group name or chat label |
| sender_phone | text | Sender phone number |
| sender_name | text | Sender display name / 'assistant' for Nova |
| body | text | Message text content |
| media_type | text | image/audio/etc or null |
| is_from_me | boolean | true = assistant's messages |
| session_key | text | OpenClaw session UUID |
| tokens_in | integer | Input tokens (assistant msgs only) |
| tokens_out | integer | Output tokens (assistant msgs only) |
| cost_usd | numeric | Cost of response |
| model | varchar(80) | Model used |
Indexes
- Full-text search:
idx_messages_body_fts(GIN onto_tsvector('simple', body)) - By chat + time:
idx_messages_chat(chat_id, ts) - By sender:
idx_messages_sender(sender_phone) - By time:
idx_messages_ts(ts) - Unique message_id:
idx_messages_unique_id
How to Run Queries
LC_ALL=C /opt/homebrew/Cellar/postgresql@18/18.2/bin/psql -h 127.0.0.1 -p 15432 -U postgres -d openclaw_audit -c "QUERY"
Always add LIMIT. Start with 20, increase if needed.
Query Patterns
Full-text search (preferred for keyword searches)
SELECT id, ts, chat_name, sender_name, is_from_me, LEFT(body, 200), message_id
FROM messages
WHERE to_tsvector('simple', body) @@ plainto_tsquery('simple', 'search terms')
ORDER BY ts DESC LIMIT 20;
Search by chat
-- Roy's direct messages
SELECT id, ts, LEFT(body, 200) FROM messages
WHERE chat_id = '+972542440470' AND chat_type = 'direct'
ORDER BY ts DESC LIMIT 20;
-- A specific group
SELECT id, ts, sender_name, LEFT(body, 200) FROM messages
WHERE chat_id = '[email protected]'
ORDER BY ts DESC LIMIT 20;
Search by date range
SELECT id, ts, chat_name, sender_name, is_from_me, LEFT(body, 200)
FROM messages WHERE ts BETWEEN '2026-02-20' AND '2026-02-21'
ORDER BY ts LIMIT 50;
ILIKE search (for phrases or partial matches)
SELECT id, ts, chat_name, sender_name, is_from_me, LEFT(body, 200)
FROM messages WHERE body ILIKE '%exact phrase%'
ORDER BY ts DESC LIMIT 20;
Get conversation context around a message
SELECT id, ts, chat_name, sender_name, is_from_me, LEFT(body, 300)
FROM messages WHERE id BETWEEN (TARGET_ID - 5) AND (TARGET_ID + 5)
ORDER BY ts;
List all chats
SELECT chat_id, chat_type, chat_name, COUNT(*) as msgs,
MIN(ts) as first_msg, MAX(ts) as last_msg
FROM messages GROUP BY chat_id, chat_type, chat_name
ORDER BY msgs DESC;
Replying to Past Messages
When you find a message to reference, use message_id:
- Include
[[reply_to:\x3Cmessage_id>]]in your response for a native WhatsApp reply
Known Limitations
- Messages before Feb 18, 2026 use old ingest format (chat_id from JSONL metadata)
- Messages from Feb 18+ use ingest-v2 (chat_id from gateway.log correlation)
- Sub-agent sessions show as
unknown-*chat_id (no gateway log match) NO_REPLY/HEARTBEAT_OKmessages are filtered out during ingest
Tips
is_from_me = true→ Nova sent itis_from_me = false→ a human sent it- For group chats,
chat_namehas the group name sender_name = 'assistant'→ Nova's outbound messages- Always respect child safety rules — never reveal info about Ben
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install chat-history-local - 安装完成后,直接呼叫该 Skill 的名称或使用
/chat-history-local触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Chat History Local 是什么?
Search past WhatsApp/chat conversations stored in the audit log PostgreSQL database. Use when the user asks about past conversations, what was discussed, wha... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 108 次。
如何安装 Chat History Local?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install chat-history-local」即可一键安装,无需额外配置。
Chat History Local 是免费的吗?
是的,Chat History Local 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Chat History Local 支持哪些平台?
Chat History Local 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Chat History Local?
由 Netanel Abergel(@netanel-abergel)开发并维护,当前版本 v1.0.0。