Query, analyze, and export WeChat chat data, providing AI-driven smart insights and beautifully visualized pages.
⚠️ Important Notice
- This Skill depends on Wetrace service
- Only supports the Windows platform(the WeChat database is located on the Windows system)
- The Wetrace service must be installed and running before this Skill can be used
Prerequisites
- Wetrace service: must first be installed and running Wetrace
- Service address: The Wetrace service runs at
http://127.0.0.1:5200 - WeChat database: decrypted and loaded
- Operating system:Windows 10/11
- If the service is not running, first prompt the user to start the Wetrace service
Core Workflow
1. Understand user intent
Classify the user request into the following categories:
- Query: view messages, sessions, contacts, group chats
- Search: find messages by keyword
- Analysis: analyze patterns, generate statistics
- Export: export data in multiple formats
- Insight: comprehensive analysis and recommendations
- Visualization: generate beautiful HTML pages
2. Extract parameters
Identify key parameters from the user request:
- Contact name: extract the person or group name
- Time range: extract the time period
- Keyword: extract the search term
- Format: extract the export format
3. Call the API
This Skill provides a Python script tool to call the Wetrace API, which is more convenient than using WebFetch directly.
Method 1: Use the Python script (recommended)
Use wetrace_api.py script, located at scripts/wetrace_api.py:
# 查询会话
python scripts/wetrace_api.py sessions --keyword "张三" --limit 20
# 获取消息
python scripts/wetrace_api.py messages --talker wxid_abc123 --limit 50
# 搜索关键词
python scripts/wetrace_api.py search --keyword "项目" --limit 30
# 分析数据
python scripts/wetrace_api.py analysis hourly wxid_abc123
python scripts/wetrace_api.py analysis daily wxid_abc123
# 导出聊天记录
python scripts/wetrace_api.py export chat --talker wxid_abc123 --format html
Full script documentation: see scripts/README.md
Method 2: Call the API directly
Base URL:http://127.0.0.1:5200/api/v1
Full API documentation: refer to references/api.md
Common API Patterns
GET /sessions?keyword={名称}&limit=50
GET /messages?talker_id={id}&time_range={范围}&limit=100
GET /search?keyword={关键词}&time_range={范围}&limit=50
GET /analysis/hourly/{session_id}
GET /analysis/daily/{session_id}
GET /export/chat?talker={id}&format={格式}&time_range={范围}
4. Process and present data
Simple query/search
Present the data in a clear, structured format.
Analysis tasks
- Get raw data from the analysis API
- Use references/analysis-prompts.md template in to generate an AI summary
- Present in a clear structure
Export tasks
Call the export API and inform the user of the download information.
Insight tasks
- Collect data from multiple APIs
- Synthesize the information
- Generate comprehensive insights and recommendations
- Use the appropriate template in analysis-prompts.md
5. Error handling
- API returned 404: The database may not be loaded, or the contact/conversation may not exist
- API returned 500: Server error; it is recommended to check the logs
- No data returned: Verify the time range and contact name
- Server not responding: Prompt the user to start the Wetrace service
🎨 Intelligent Web Page Generation Feature
Wetrace provides 8 core visualization features, and each feature will:
- Call the Wetrace API to retrieve data
- Use AI analysis to generate a summary
- Use a unified design system to generate a polished HTML page
- Save the HTML file to
~/wetrace-exports/and provide an access link
Available Visualization Features
When the user requests generation of a visualization page, select the corresponding feature based on the trigger keywords:
-
Intelligent Summary Generation - Trigger words: summarize chat history, generate summary, intelligent summary
-
To-Do Item Extraction - Trigger words: extract to-dos, find tasks, to-do items
-
Chat Activity Heatmap - Trigger words: activity heatmap, chat time distribution
-
Interaction Trend Analysis - Trigger words: trend analysis, interaction trends
-
Intelligent Weekly and Monthly Reports - Trigger words: generate weekly report, generate monthly report
-
Data Dashboard - Trigger words: generate dashboard, data overview
-
Intelligent Conversation Summary - Trigger words: conversation summary, intelligent summary, categorized summary
-
Customer Relationship Health - Trigger words: customer health, CRM dashboard
Design System
All generated HTML pages follow a unified design system, see references/design-system.md, including:
- Color system: HSL-based CSS variables
- Component library: Card, Badge, Button, Separator, Input, etc.
- Layout system: responsive containers and unified spacing
- Data visualization: Chart.js configuration and color schemes
HTML Page Features
All generated HTML pages:
- ✅ Standalone operation: No server required; double-click to open in a browser
- ✅ Responsive design: Adapts to all devices (desktop/tablet/mobile)
- ✅ Modern styling: Uses Tailwind CSS
- ✅ Interactive charts: Uses Chart.js for data visualization
- ✅ Clear hierarchy: Card layout, unified spacing, semantic colors
- ✅ Easy to share: Can be sent directly to others for viewing
Usage Workflow
When the user requests web page generation:
- Identify the feature: Match the corresponding feature based on trigger keywords
- Read the detailed documentation: Read the corresponding .md file from the references directory
- Collect parameters: Ask the user for the necessary parameters (session ID, time range, etc.)
- Call API: Retrieve the required data
- AI analysis: Use the templates in analysis-prompts.md to generate a summary
- Generate HTML: Use the design-system.md style to generate a polished page
- Save file: Save to
~/wetrace-exports/directory - Provide link: Return the file path and access link
Advanced features
Time range parsing
Supports multiple formats:
- Chinese: last week, last month, this year
- English: last week, last month, this year
- Absolute time: 2024-01-01~2024-01-31
- Relative days: last 7 days, last 30 days
Convert to API format:YYYY-MM-DD~YYYY-MM-DD
Contact name matching
- First try an exact match in the session
- If not found, search in contacts
- If there are multiple matches, ask the user to clarify
- Supports both the NickName and Remark fields
Pagination strategy
For large datasets:
- From
limit=50start - If the user needs more, increase limit or use offset
- Inform the user of the total count
- If the dataset is very large, suggest exporting
Usage tips
- Always verify the server is running before calling the API
- Use the appropriate analysis template to keep output consistent
- Provide actionable insights, not just raw statistics
- Respect user privacy - do not make assumptions about relationships
- Provide next steps or follow-up actions
- Handle Chinese and English queries equally
- When generating an HTML page: Always refer to the design system in design-system.md
- File save location: Save uniformly to
~/wetrace-exports/directory - Provide access link: After generation, provide the full path with the
file://protocol
🐍 Python script tools
Quick start
Script location:scripts/wetrace_api.py
Install dependencies
cd scripts
pip install -r requirements.txt
Common commands
# 查看帮助
python wetrace_api.py --help
# 查询会话
python wetrace_api.py sessions --keyword "张三" --limit 20
# 获取消息(需要会话ID)
python wetrace_api.py messages --talker wxid_abc123 --limit 50
# 按时间范围查询
python wetrace_api.py messages --talker wxid_abc123 --time-range "2024-01-01~2024-01-31"
# 全文搜索
python wetrace_api.py search --keyword "项目" --limit 30
# 数据分析
python wetrace_api.py analysis hourly wxid_abc123
python wetrace_api.py analysis daily wxid_abc123
python wetrace_api.py analysis type wxid_abc123
# 获取总览
python wetrace_api.py dashboard
# 导出聊天记录
python wetrace_api.py export chat --talker wxid_abc123 --format html
Use in code
from scripts.wetrace_api import WetraceAPI
# 创建API客户端
api = WetraceAPI()
# 查询会话
sessions = api.get_sessions(keyword="张三", limit=10)
for session in sessions:
print(f"{session['NickName']}: {session['MessageCount']} 条消息")
# 获取消息
messages = api.get_messages(talker_id="wxid_abc123", limit=50)
for msg in messages:
print(f"[{msg['CreateTime']}] {msg['Content']}")
# 搜索
result = api.search(keyword="项目", limit=20)
print(f"找到 {result['Total']} 条相关消息")
Full documentation: View scripts/README.md