











{
"name": "customer-query-plugin",
"version": "1.0.0",
"description": "客户信息查询插件",
"main": "index.ts",
"dependencies": {
"node-fetch": "^3.3.2"
}
}
{
"id": "customer-query-plugin",
"name": "customer-query-plugin",
"version": "1.0.0",
"description": "客户信息查询插件,根据客户名称调用内部 API 查询客户详细信息",
"configSchema": {
"type": "object",
"properties": {
"apiBaseUrl": {
"type": "string",
"description": "客户 API 服务地址,如 https://your-server/api"
},
"apiKey": {
"type": "string",
"description": "API 鉴权 Key(X-API-Key)"
},
"orgInfoId": {
"type": "number",
"description": "机构ID,默认为 2",
"default": 2
}
},
"required": []
},
"openclaw": {
"extensions": ["./index.ts"]
}
}
export default function register(api: any) {
api.registerTool(
(ctx: any) => ({
name: "query_customer",
description:
"根据客户名称查询客户信息。当用户询问某个公司或客户的资料、详情、档案时调用。" +
"支持模糊匹配,例如:'查询上海莫某科技公司'、'帮我看看北京某某有限公司的信息'。",
parameters: {
type: "object",
properties: {
customer_name: {
type: "string",
description: "客户名称,支持模糊匹配,如'上海莫某科技公司'",
},
org_info_id: {
type: "number",
description: "机构ID,默认为 2",
},
},
required: ["customer_name"],
},
execute: ({ customer_name, org_info_id = 2 }: { customer_name: string; org_info_id?: number }) => {
const baseUrl = "*****";
const apiKey = "abc123abc";
if (!baseUrl || !apiKey) {
return Promise.resolve({
content: [{ type: "text", text: "插件配置缺失,请检查 CUSTOMER_API_BASE_URL 和 CUSTOMER_API_KEY 环境变量" }],
});
}
return fetch(`${baseUrl}/api/AIAgent/PostGetCustomerInfoByName`, {
method: "POST",
headers: {
"X-API-Key": apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({ customer_name, org_info_id }),
})
.then((res) => {
if (res.status === 401 || res.status === 403) {
return { content: [{ type: "text", text: "API 鉴权失败,请检查 CUSTOMER_API_KEY 配置" }] };
}
return res.json();
})
.then((result: any) => {
if (!result.success || !result.data || result.data.length === 0) {
return { content: [{ type: "text", text: "未找到匹配的客户,请确认公司名称是否正确" }] };
}
const rows = result.data.map((c: any) =>
`客户ID: ${c.customer_info_id} | 名称: ${c.customer_name} | 税号: ${c.tax_code} | ${c.province}${c.city} | 服务公司: ${c.service_company}`
).join("\n");
return {
content: [{ type: "text", text: `共找到 ${result.data.length} 条记录:\n\n${rows}` }],
details: { data: result.data },
};
})
.catch((e: any) => ({
content: [{ type: "text", text: `无法连接到客户服务,请确认服务是否正常运行(${e.message})` }],
}));
},
}),
{ name: "query_customer" }
);
}
qh2@qh2-desktop:~/.openclaw/upload-file-plugin$ pwd
/home/qh2/.openclaw/upload-file-plugin
这个目录,在这个目录执行安装
qh2@qh2-desktop:~/.openclaw/upload-file-plugin$ openclaw plugins install /home/qh2/.openclaw/upload-file-plugin
16:14:31 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
16:14:31 [plugins] feishu_chat: Registered feishu_chat tool
16:14:31 [plugins] feishu_wiki: Registered feishu_wiki tool
16:14:31 [plugins] feishu_drive: Registered feishu_drive tool
16:14:31 [plugins] feishu_bitable: Registered bitable tools
16:14:31 [plugins] customer-query-plugin: loaded without install/load-path provenance; treat as untracked local code and pin trust via plugins.allow or install records (/home/qh2/.openclaw/extensions/customer-query-plugin/index.ts)
🦞 OpenClaw 2026.3.7 (42a1394) — I'll butter your workflow like a lobster roll: messy, delicious, effective.
Installing to /home/qh2/.openclaw/extensions/upload-file-plugin…
Installing plugin dependencies…
16:14:38 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
16:14:38 [plugins] feishu_chat: Registered feishu_chat tool
16:14:38 [plugins] feishu_wiki: Registered feishu_wiki tool
16:14:38 [plugins] feishu_drive: Registered feishu_drive tool
16:14:38 [plugins] feishu_bitable: Registered bitable tools
16:14:39 [plugins] customer-query-plugin: loaded without install/load-path provenance; treat as untracked local code and pin trust via plugins.allow or install records (/home/qh2/.openclaw/extensions/customer-query-plugin/index.ts)
Config overwrite: /home/qh2/.openclaw/openclaw.json (sha256 80961cafd273b45601746c66cba154479d621a7a547e696381dddb258f9f27a1 -> 83dbde9deceb12bea015a6b1036e719d1b55421c13f9352a96b91676e1313b8f, backup=/home/qh2/.openclaw/openclaw.json.bak)
Installed plugin: upload-file-plugin
Restart the gateway to load plugins.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。