| name | feishu-literature-manager |
| description | Automated literature retrieval and Feishu Bitable management. Use when user requests to create a literature database, search PubMed for specific topics, or manage research papers in Feishu tables. Triggers on phrases like "create a literature table", "search papers and add to Feishu", "build a research database", "补充文献", "添加文献到表格", or "检索文献并建立表格". Supports complete workflow from topic definition to populated Feishu table with all required fields including Chinese translations, impact factors, and reference formatting. Also supports supplementing existing databases with new papers. |
Feishu Literature Manager
Overview
This skill automates the complete workflow of creating a literature database in Feishu Bitable, from PubMed search to fully populated table with all required metadata including Chinese translations, impact factors, and formatted references.
Two Main Workflows:
- Create New Database: Create a new Feishu Bitable from scratch
- Supplement Existing Database: Add new papers to an existing table (avoiding duplicates)
Workflow Decision Tree
Workflow A: Create New Database
User provides: topic + number of papers
↓
1. Create Feishu Bitable
↓
2. Create all 17 required fields
↓
3. Search PubMed for papers
↓
4. Parse and validate results
↓
5. Extract complete metadata
↓
6. Translate titles and abstracts
↓
7. Add papers to table (PARALLEL CALLS)
↓
8. Set table permissions (full_access)
↓
9. Report completion
Workflow B: Supplement Existing Database ⭐ NEW
User provides: research topic + specific focus + table URL + number of papers
↓
1. Parse table URL to get app_token and table_id
↓
2. Get existing records to extract current PMIDs
↓
3. Search PubMed with focused keywords
↓
4. Filter out existing PMIDs (deduplication)
↓
5. Score and rank papers by relevance
↓
6. Select top N papers
↓
7. Fetch XML data for selected papers
↓
8. Parse metadata and translate
↓
9. Add papers to table (PARALLEL CALLS - 5-10 at a time)
↓
10. Report completion with summary
Batch Processing for Large Tasks
IMPORTANT: When retrieving more than 5 papers, process in batches!
Why Batch Processing is Necessary:
- Token limitations - Large numbers of papers require extensive translation work
- Quality assurance - Each batch ensures complete field information before proceeding
- Better user experience - Users receive regular progress updates
- Error recovery - Easier to resume if interrupted
Batch Processing Workflow:
User requests: topic + N papers (N > 5)
↓
Calculate batches: ceil(N / 5)
↓
For each batch (5 papers):
1. Fetch PMIDs for this batch
2. Retrieve XML data
3. Parse metadata
4. Translate titles and abstracts
5. Add all 5 papers to table with COMPLETE fields
6. Report batch completion
↓
Continue to next batch
↓
All batches complete → Report final status
Example: User requests 10 papers
Batch 1 (Papers 1-5):
- Fetch PMIDs 1-5
- Get XML data
- Parse and translate
- Add 5 papers with complete fields (including 摘要)
- Report: "第一批完成,已添加5篇文献"
Batch 2 (Papers 6-10):
- Fetch PMIDs 6-10
- Get XML data
- Parse and translate
- Add 5 papers with complete fields (including 摘要)
- Report: "第二批完成,已添加5篇文献"
Final Report: "任务全部完成!共添加10篇文献"
Critical Rules:
-
Never start a new batch until current batch is COMPLETE
- COMPLETE means ALL 17 fields filled, including 摘要(英文)and 摘要(中文)
- Report completion before starting next batch
-
Progress Reporting:
- After each batch: "第X批完成,已添加Y篇文献,剩余Z篇"
- Keep user informed of progress
-
Token Management:
- Monitor token usage
- If running low, inform user and continue in next conversation
- Save state (PMIDs retrieved, current batch) for resumption
-
Quality over Speed:
- Better to complete fewer papers with full information
- Than many papers with incomplete fields
⭐ PARALLEL API CALLS - BEST PRACTICE
CRITICAL: Always use parallel API calls when adding multiple papers!
Why Parallel Calls?
Sequential API calls are SLOW. Each call waits for response before next call.
Parallel calls submit multiple requests simultaneously, dramatically improving efficiency.
How to Make Parallel Calls
In tool calls, submit MULTIPLE feishu_bitable_create_record calls in the SAME function_calls block:
// CORRECT: Parallel calls (5-10 papers at once)
<function_calls>
<invoke name="feishu_bitable_create_record">
<parameter name="app_token">xxx</parameter>
<parameter name="table_id">xxx</parameter>
<parameter name="fields">{paper 1 data}</parameter>
</invoke>
<invoke name="feishu_bitable_create_record">
<parameter name="app_token">xxx</parameter>
<parameter name="table_id">xxx</parameter>
<parameter name="fields">{paper 2 data}</parameter>
</invoke>
<invoke name="feishu_bitable_create_record">
<parameter name="app_token">xxx</parameter>
<parameter name="table_id">xxx</parameter>
<parameter name="fields">{paper 3 data}</parameter>
</invoke>
... (up to 10 calls at once)
</function_calls>
// WRONG: Sequential calls (SLOW!)
<function_calls>
<invoke name="feishu_bitable_create_record">...</invoke>
</function_calls>
// Wait for response...
<function_calls>
<invoke name="feishu_bitable_create_record">...</invoke>
</function_calls>
// Wait for response...
Recommended Batch Size
- 5-10 papers per parallel call - Optimal balance of speed and reliability
- Maximum 10 papers - Avoid overwhelming the API
Example: Adding 10 Papers Efficiently
papers_data = [prepare_paper_data(p) for p in papers[:10]]
results = parallel_add_papers(papers_data)
print(f"Successfully added {len(results)} papers in one batch!")
⭐ SUPPLEMENTING EXISTING DATABASE - Step by Step
Overview
When user provides:
- Research topic: e.g., "胃神经内分泌肿瘤"
- Specific focus: e.g., "药物临床研究", "手术治疗", "诊断方法"
- Table URL: Feishu Bitable link
- Number of papers: How many to add
Step 1: Parse Table URL and Get Existing PMIDs
records = feishu_bitable_list_records(
app_token=app_token,
table_id=table_id,
page_size=500
)
existing_pmids = set()
for record in records['records']:
pmid = record['fields'].get('PMID')
if pmid:
existing_pmids.add(pmid)
print(f"Existing records: {len(records['records'])}, Unique PMIDs: {len(existing_pmids)}")
Step 2: Build Focused Search Query
FOCUS_KEYWORDS = {
"药物临床研究": [
"chemotherapy", "targeted therapy", "PRRT", "somatostatin analog",
"everolimus", "sunitinib", "octreotide", "lanreotide", "immunotherapy",
"PD-1", "PD-L1", "temozolomide", "capecitabine", "177Lu", "Lutetium",
"clinical trial", "phase", "randomized", "treatment"
],
"手术治疗": [
"surgery", "resection", "gastrectomy", "endoscopic resection",
"lymph node dissection", "surgical outcome"
],
"诊断方法": [
"diagnosis", "biomarker", "PET/CT", "endoscopy", "pathology",
"immunohistochemistry", "molecular marker"
],
"预后评估": [
"prognosis", "survival", "outcome", "risk factor", "nomogram"
]
}
search_query = f"({topic}) AND ({' OR '.join(focus_keywords)})"
Step 3: Search PubMed and Filter
response = curl(f"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term={search_query}&retmax=50&retmode=json&sort=pub_date")
new_pmids = [pmid for pmid in response['idlist'] if pmid not in existing_pmids]
print(f"Found {len(response['idlist'])} papers, {len(new_pmids)} are new")
Step 4: Score and Rank Papers by Relevance
xml_data = curl(f"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id={','.join(new_pmids)}&retmode=xml")
def score_paper(paper, focus):
score = 0
title = paper['title'].lower()
abstract = paper['abstract'].lower()[:500]
for kw in FOCUS_KEYWORDS.get(focus, []):
if kw.lower() in title:
score += 3
if kw.lower() in abstract:
score += 1
if 'neuroendocrine' in title or 'net' in title:
score += 2
if 'trial' in title or 'phase' in title:
score += 2
return score
scored_papers = [(score_paper(p, focus), p) for p in papers]
scored_papers.sort(reverse=True, key=lambda x: x[0])
selected_papers = [p for score, p in scored_papers[:number_requested]]
Step 5: Add Papers with Parallel Calls
papers_data = [prepare_full_paper_data(p) for p in selected_papers]
results = parallel_add_papers(papers_data)
print(f"✅ Added {len(results)} papers successfully!")
Core Capabilities
1. Table Field Structure (17 Required Fields)
Primary Field:
- 文献标题(中文) - Text (主字段, use Chinese title as primary field)
Basic Information:
- 文献题目(英文) - Text
- 文献题目(中文) - Text
- 发表年月 - DateTime (timestamp in milliseconds)
- 第一作者 - Text
- 第一作者单位 - Text
- 通讯作者 - Text
- 期刊名称 - Text
Abstracts:
- 摘要(英文) - Text (structured with BACKGROUND, METHODS, RESULTS, CONCLUSION)
- 摘要(中文) - Text (structured with 【背景】【目的】【方法】【结果】【结论】)
Identifiers:
Metadata:
- 免费全文链接 - URL (format:
{"link": "URL", "text": "PMC免费全文"} or {"link": "DOI_URL", "text": "DOI链接"})
- SCI分区 - Text (e.g., "JCR Q1", "JCR Q2", "中文核心期刊")
- 中科院分区 - Text (e.g., "医学1区", "医学2区", "中文核心期刊")
- 影响因子 - Number (MUST be numeric, not string!)
- 国标参考文献格式 - Text (GB/T 7714-2015 format)
2. Step-by-Step Workflow
Step 1: Create Feishu Bitable
app = feishu_bitable_create_app(
name="文献库标题",
folder_token="optional_folder_token"
)
Step 2: Create Fields
feishu_bitable_create_field(
app_token=app_token,
table_id=table_id,
field_name="文献题目(英文)",
field_type=1
)
Step 3: Search PubMed
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=SEARCH_TERM&retmax=NUMBER&retmode=json&sort=pub_date"
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=PMID1,PMID2,...&retmode=xml"
Step 4: Parse PubMed XML
Step 5: Translate to Chinese
Step 6: Get Journal Metadata
Step 7: Format Reference
Step 8: Add to Feishu Table
record = feishu_bitable_create_record(
app_token=app_token,
table_id=table_id,
fields={
"PMID": pmid,
"文献题目(英文)": english_title,
"文献题目(中文)": chinese_title,
"发表年月": timestamp_ms,
"第一作者": first_author,
"第一作者单位": first_affiliation,
"通讯作者": corresponding_author,
"期刊名称": journal,
"摘要(英文)": english_abstract,
"摘要(中文)": chinese_abstract,
"DOI": doi,
"免费全文链接": {"link": url, "text": text},
"SCI分区": sci_partition,
"中科院分区": cas_partition,
"影响因子": impact_factor,
"国标参考文献格式": reference,
"文献标题(中文)": chinese_title
}
)
Step 9: Set Table Permissions
feishu_perm(
action="add",
token=app_token,
type="bitable",
member_type="openid",
member_id=user_open_id,
perm="full_access"
)
3. User Reporting Requirements
Report after each step:
- ✅ Table Created: "已创建飞书多维表格,表格名称:[名称],表格ID:[ID]"
- ✅ Fields Created: "已创建所有必填字段"
- ✅ PubMed Search: "已从PubMed检索到 [N] 篇文献"
- ✅ Deduplication: "去重后剩余 [N] 篇新文献"
- ✅ Metadata Extraction: "正在提取第 [X]/[N] 篇文献的详细信息..."
- ✅ Translation: "正在翻译中文标题和摘要..."
- ✅ Adding to Table: "正在添加第 [X]/[N] 篇文献到表格..."
- ✅ Permissions Set: "已为您设置表格管理权限"
- ✅ Completion: "✅ 任务完成!共添加 [N] 篇文献到表格中,表格现有 [M] 条记录,您拥有完全管理权限"
4. Common Pitfalls to Avoid
❌ WRONG:
- String impact factor:
"影响因子": "15.3"
- Plain URL:
"免费全文链接": "https://..."
- Missing Chinese translation
- Incomplete abstract (missing sections)
✅ CORRECT:
- Numeric impact factor:
"影响因子": 15.3
- JSON URL:
"免费全文链接": {"link": "https://...", "text": "PMC免费全文"}
- Complete translations
- Structured abstracts with all sections
5. Quality Checklist
Before adding each paper, verify:
6. Permission Management
IMPORTANT: Always set table permissions for the user after creating the table.
Configuration Required:
The feishu_perm tool must be enabled in the OpenClaw configuration:
openclaw config set channels.feishu.tools.perm true
openclaw gateway restart
Why It's Important:
- Without proper permissions, users cannot fully manage tables they create
full_access permission allows users to:
- View and edit table content
- Manage permissions (add/remove collaborators)
- Delete the table
- Export and share the table
How to Get User's open_id:
The user's open_id is available in the inbound context metadata:
{
"sender_id": "ou_xxxxxxxxxxxx",
"sender": "User Name"
}
Permission Levels:
view: Read-only access
edit: Can view and edit content
full_access: Full management access (recommended for table owners)
Resources
scripts/
pubmed_search.py - PubMed E-utilities API wrapper
parse_pubmed_xml.py - XML parsing utilities
references/
field_mapping.md - Complete field definitions and types
impact_factors.md - Common journal impact factors and partitions
reference_format.md - GB/T 7714-2015 formatting rules