Objective
Support sales in quickly retrieving CRM data: self, customers, leads, opportunities, business records, contacts, tags, users, notifications, presales itineraries, contracts, payments.
When not to use this skill
- Creating/modifying data - This skill is only for retrieval, not for creating or updating. If you need to create customers, enter business records, etc., use the corresponding specialized skill (such as lcrm-business-record)
- Complex data analysis - If you need to generate reports or perform in-depth analysis, use data analysis-related skills
Script entry point
Main script (recommended)
node scripts/search.mjs <action> [options]
Each action corresponds to a data type; see the sections below for usage.
Environment variables
Ensure the API key is set before execution:
export LCRM_API_KEY="your-api-key"
Why an API key is needed:
All API calls require authentication,LCRM_API_KEY used to identify and verify the current user's identity.
Execution flow
Core principles
When retrieving data, first determine the object type, then choose the corresponding retrieval method. This allows you to quickly locate the correct API and avoid unnecessary duplicate queries.
Steps
- Identify the object type - Determine from the user's question whether they want to query: self, customers, leads, opportunities, business records, contacts, tags, users, notifications, presales itineraries, contracts, or payments
- Choose the corresponding action - Choose the optimal retrieval method based on the object type:
- Query self →
meaction - Query users →
usersorsales-presales-usersaction - Query tags →
tagsaction - Query customer-related data (opportunities, contacts, business records) → first confirm the customer ID, then use the corresponding action
- Query self →
- Execute retrieval - Call
search.mjsthe corresponding action - Handle multiple results - If multiple matches are found and the unique object cannot be determined, display the list and let the user choose
- Return results - First display the core fields, then provide parameter suggestions for further filtering
Resource retrieval guide
Each resource module includes filtering parameters and specific usage. Usage principles:First determine the object type, then choose the corresponding action。
| Action | Object | Common scenarios |
|---|---|---|
me |
Self | Get the current user's identity information |
customers |
Customer | Filter customers by company name/status/region |
business-records |
Business record | Query by lead/opportunity/recorder/time |
customer-business-records |
Customer business record | Query business records by customer |
customer-opportunities |
Customer opportunity | Query all opportunities for a customer |
customer-contacts |
Contact | Query contacts for a customer |
leads |
Lead | Query by keyword/status/tag/source |
opportunities |
Opportunities | Query by customer name/status/amount/date |
users |
Users | Query all user information |
sales-presales-users |
Sales/pre-sales | Query only sales or pre-sales users |
tags |
Tags | Query tag list (mainly used for leads) |
notifications |
Notifications | Query active/historical notifications |
presales-itineraries |
Pre-sales trips | Query by time period/user/opportunity |
contracts |
Contracts | Query by title/number/customer/date |
contract-payments |
Payments | Query by status/contract/date |
1) Self (me)
Get the basic information and permissions of the currently logged-in user.
node scripts/search.mjs me
Core output fields: id, name, email, roles
2) Customers (customers)
Filter parameters
| Parameter | Optional values | Description |
|---|---|---|
customerType[] |
直接客户、合作伙伴 |
Customer type (multiple selection) |
customerSource[] |
官方渠道、自办活动、三方活动、名单导入、内部资源、客户推荐、生态伙伴、销售自拓 |
Customer source (multiple selection, consistent with lead source criteria) |
customerStatus[] |
潜在客户、跟进客户、商机客户、合作客户、无效客户 |
Customer status (multiple selection) |
region[] |
上海、北京、华南、华东、海外、其他 |
Region (multiple selection) |
followUpSalesId[] |
ID | Follow-up sales ID (multiple selection) |
companyName |
string | Company name (fuzzy search) |
Usage examples
Basic query - by company name:
node scripts/search.mjs customers --company-name "<客户名>" --limit 5
Complex filtering - multiple condition combination:
node scripts/search.mjs customers \
--query 'customerStatus[]=跟进客户' \
--query 'region[]=华东'
My customers vs public pool customers:
# 我的客户
node scripts/search.mjs customers --query 'followUpSalesId[]=<我的用户ID>'
# 公海客户(需先获取公海用户ID,见"公海概念"章节)
node scripts/search.mjs customers --query 'followUpSalesId[]=<公海用户ID>'
Note:
followUpSalesId[]is a search parameter used when querying special scenarios such as "my customers / public pool customers", not the "customer ownership" field entered on the frontend.
Core output fields: id, companyName, customerStatus, customerSource
3) Business records (business-records / customer-business-records)
Filter parameters
| Parameter | Description |
|---|---|
customer-id |
Customer ID (specific to customer-business-records) |
lead-id |
Lead ID |
opportunity-id |
Opportunity ID |
recorder-id |
Recorder ID |
start-date / end-date |
Record time range (YYYY-MM-DD) |
Business record field enumeration
| Field | Optional values | Description |
|---|---|---|
followUpType |
微信、电话、线上会议、邮件、现场拜访、商务活动、其他 |
Follow-up method |
Usage examples
Query by customer:
node scripts/search.mjs customer-business-records --customer-id "<customerId>"
Query by lead:
node scripts/search.mjs business-records --lead-id "<leadId>"
Query by opportunity:
node scripts/search.mjs business-records --opportunity-id "<opportunityId>"
By recorder and time:
node scripts/search.mjs business-records \
--recorder-id "<userId>" \
--start-date 2026-02-01 \
--end-date 2026-02-28
Core output fields: recordTime, followUpType, contactedPerson, description
4) Customer opportunities (customer-opportunities)
Filter parameters
| Parameter | Description |
|---|---|
customer-id |
Customer ID (exact match) |
customer-name |
Customer name (fuzzy match) |
Usage examples
# 已知客户ID
node scripts/search.mjs customer-opportunities --customer-id "<customerId>"
# 已知客户名
node scripts/search.mjs customer-opportunities --customer-name "<客户名>"
Core output fields: id, name, status, amount, estimatedCloseDate
5) Customer contacts (customer-contacts)
Filter parameters
| Parameter | Description |
|---|---|
customer-id |
Customer ID (required) |
Usage examples
node scripts/search.mjs customer-contacts --customer-id "<customerId>"
Core output fields: name, phone, position, roles
6) Leads (leads)
Filter parameters
| Parameter | Optional values | Description |
|---|---|---|
keyword |
string | Keyword search |
status[] |
待处理、已跟进、已转化 |
Lead status (multiple selection) |
classification[] |
公司、市场、销售 |
Lead category (multiple selection) |
source[] |
官方渠道、自办活动、三方活动、名单导入、内部资源、客户推荐、生态伙伴、销售自拓 |
Lead source (multi-select) |
tags[] |
string | Tag name (multi-select, AND matching) |
mine |
boolean | Only query my leads |
publicOnly |
boolean | Only query public pool leads |
Note:
tags[]Only used for lead retrieval. Customers and opportunities currently have no tag field.
Usage examples
Keyword search:
node scripts/search.mjs leads --query keyword="<关键词>" --query limit=20
Complex filtering - status + category + my leads:
node scripts/search.mjs leads \
--query 'status[]=已跟进' \
--query 'classification[]=销售' \
--query mine=true
Filter by tags (AND relationship):
node scripts/search.mjs leads \
--query 'tags[]=重点客户' \
--query 'tags[]=AI'
Public pool vs my leads:
# 公海线索
node scripts/search.mjs leads --query publicOnly=true
# 我的线索
node scripts/search.mjs leads --query mine=true
Note:
mine/publicOnlyis a retrieval toggle, used to query "my leads / public pool leads", and does not correspond to the "lead ownership" field entered on the frontend.
Output core fields: id, companyName, status, classification, source, importedAt
7) Opportunities (opportunities)
Filter parameters
| Parameter | Type/Optional values | Description |
|---|---|---|
name |
string | Opportunity name (fuzzy search) |
customerName |
string | Customer name (fuzzy search) |
status |
需求引导、客户立项、客户选定、客户成交、机会失败(multiple values separated by commas) |
Opportunity status |
minAmount / maxAmount |
number | Amount range |
startDate / endDate |
YYYY-MM-DD | Expected close date range |
startYear / startMonth / endYear / endMonth |
number | Year-month filter |
createdAtStartDate / createdAtEndDate |
YYYY-MM-DD | Creation time range |
opportunitySalesId / opportunityPreSalesId |
ID | Sales/pre-sales ID (multiple values separated by commas) |
lastFollowUpStartDate / lastFollowUpEndDate |
YYYY-MM-DD | Last follow-up time range |
sortBy |
Field name | Sort field |
sortOrder |
asc / desc |
Sort direction |
Sort field optional values: id, name, amount, estimatedCloseDate, status, customerName, customer.companyName, opportunitySales.name, opportunityPreSales.name, lastFollowUpTime
Usage examples
By customer and status:
node scripts/search.mjs opportunities \
--query customerName="<客户名>" \
--query status=需求引导,客户立项
By amount and date range:
node scripts/search.mjs opportunities \
--query minAmount=100000 \
--query maxAmount=500000 \
--query startDate=2026-02-01 \
--query endDate=2026-03-31
Output core fields: id, name, status, amount, estimatedCloseDate, customer
8) Users (users / sales-presales-users)
Filter parameters
| Parameter | Description |
|---|---|
search |
Name or email keyword (fuzzy search) |
limit |
Return count limit |
Usage examples
Regular user search:
node scripts/search.mjs users --search "<姓名或邮箱>" --limit 20
Only query sales/pre-sales:
node scripts/search.mjs sales-presales-users --search "<姓名或邮箱>"
Output core fields: id, name, email, roles, createdAt
9) Tags (tags)
Filter parameters
| Parameter | Optional values | Description |
|---|---|---|
category |
LEAD |
Tag category (currently mainly uses LEAD) |
search |
string | Keyword (search name/description/category) |
Note: Currently in the business, only leads use the tag field; customers and opportunities currently have no tag field
Usage examples
# 全部标签
node scripts/search.mjs tags
# 按分类
node scripts/search.mjs tags --category LEAD
# 按关键词
node scripts/search.mjs tags --category LEAD --search "<关键词>"
Output core fields: id, name, category, description, sortOrder, isActive
10) Notifications (notifications)
Note: You can only query notifications under the current username
Filter parameters
| Parameter | Optional values | Description |
|---|---|---|
status |
active / history |
active=pending (ACTIVE/OVERDUE), history=historical (DONE/OVERDUE) |
category |
LEAD_TIMEOUT etc. |
Notification category |
page |
number | Page number |
limit |
number | Number per page |
Usage examples
# 待处理通知(ACTIVE/OVERDUE)
node scripts/search.mjs notifications --status active
# 历史通知(DONE/OVERDUE)
node scripts/search.mjs notifications --status history
# 按分类+分页
node scripts/search.mjs notifications \
--category LEAD_TIMEOUT \
--status active \
--page 2 \
--limit 20
Output core fields: id, category, title, message, status, isRead, createdAt
11) Pre-sales itineraries (presales-itineraries)
Filter parameters
| Parameter | Description |
|---|---|
start-date / end-date |
Time period (YYYY-MM-DD) |
user-id |
Pre-sales personnel ID |
opportunity-id |
Opportunity ID |
Usage examples
# 按时间段
node scripts/search.mjs presales-itineraries \
--start-date 2026-02-10 \
--end-date 2026-02-16
# 按售前人员
node scripts/search.mjs presales-itineraries \
--user-id <userId> \
--start-date 2026-02-10 \
--end-date 2026-02-16
# 按机会
node scripts/search.mjs presales-itineraries --opportunity-id <opportunityId>
Output core fields: id, title, startTime, endTime, tripType, deliveryMode, status, opportunity, customer
12) Contracts (contracts)
Filter parameters
| Parameter | Type | Description |
|---|---|---|
title |
string | Contract title (fuzzy) |
contract-number |
string | Contract number (fuzzy) |
customer-name |
string | Customer name (fuzzy) |
signed-at-start-date / signed-at-end-date |
YYYY-MM-DD | Signing date range |
followUpSalesId |
ID | Follow-up sales ID (multiple values separated by commas, passed via --query) |
opportunity |
string | Associated opportunity name (fuzzy, passed via --query) |
sortBy |
Field name | Sort field |
sortOrder |
asc / desc |
Sort direction |
Available sort field values: contractNumber, title, totalAmount, signedAt, customerName, opportunityName, followUpSalesName, createdAt
Usage example
# 按标题
node scripts/search.mjs contracts --title "合同标题"
# 按合同编号
node scripts/search.mjs contracts --contract-number "C2025001"
# 按客户名称
node scripts/search.mjs contracts --customer-name "客户名"
# 按签约日期范围
node scripts/search.mjs contracts \
--signed-at-start-date 2026-01-01 \
--signed-at-end-date 2026-03-31
# 高级筛选(--query 支持任意 API 参数,多值用逗号分隔)
node scripts/search.mjs contracts \
--query "opportunity=机会名称" \
--query "followUpSalesId=sales-id-1,sales-id-2"
Output core fields: id, contractNumber, title, totalAmount, signedAt, customer, opportunity, receivedAmount
13) Contract payments (contract-payments)
Filter parameters
| Parameter | Type/Available values | Description |
|---|---|---|
title |
string | Contract title (fuzzy) |
contract-number |
string | Contract number (fuzzy) |
status |
已回款、待回款(multiple values separated by commas) |
Payment status |
expected-at-start-date / expected-at-end-date |
YYYY-MM-DD | Expected payment date range |
followUpSalesId |
ID | Follow-up sales ID (multiple values separated by commas, passed via --query) |
sortBy |
expectedAt, status, createdAt |
Sort field |
sortOrder |
asc / desc |
Default asc |
Usage example
# 按状态
node scripts/search.mjs contract-payments --status 待回款
node scripts/search.mjs contract-payments --status 已回款
# 按合同信息
node scripts/search.mjs contract-payments --title "合同标题"
node scripts/search.mjs contract-payments --contract-number "C2025001"
# 按日期范围
node scripts/search.mjs contract-payments \
--expected-at-start-date 2026-01-01 \
--expected-at-end-date 2026-03-31
# 高级筛选(--query 支持任意 API 参数,多值用逗号分隔)
node scripts/search.mjs contract-payments \
--query "status=待回款,已回款" \
--query "followUpSalesId=sales-id"
Output core fields: id, nodeName, expectedAmount, expectedAt, actualReceivedAmount, status, contract
Public pool concept description
Public poolis the pool of leads and customers in the CRM that are not assigned to a specific salesperson, held uniformly by a special "public pool user".
Here, "public pool / mine" is retrieval semantics and is not equivalent to the "lead ownership / customer ownership" business fields that have been removed from the frontend.
- Lead flow: New leads first enter the public pool, and salespeople can claim or assign them
- Customer recycling: Customers who have not been followed up for a long time may be returned to the public pool
Public pool query
Public pool leads:
node scripts/search.mjs leads --query publicOnly=true
Public pool customers:
# 先获取公海用户ID
node scripts/search.mjs me
# 从响应中获取 publicPoolUserEmail,然后查询用户ID
node scripts/search.mjs users --search "<公海用户邮箱>"
# 使用公海用户ID查询
node scripts/search.mjs customers --query 'followUpSalesId[]=<公海用户ID>'
Output suggestions
When displaying results to users, prioritize showing the core fields:
- Self:
id,name,email,roles - Customer:
id,companyName,customerStatus,followUpSales - Lead:
id,companyName,status,classification,owner,importedAt - Opportunity:
id,name,status,amount,estimatedCloseDate,customer - Business record:
recordTime,followUpType,contactedPerson,description - Contact:
name,phone,position,roles - User:
id,name,email,roles - Tag:
id,name,category,description - Notification:
id,category,title,message,status,isRead - Pre-sales itinerary:
id,title,startTime,endTime,tripType,deliveryMode,status - Contract:
id,contractNumber,title,totalAmount,signedAt,customer,opportunity - Payment:
id,nodeName,expectedAmount,expectedAt,actualReceivedAmount,status