惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
爱范儿
爱范儿
罗磊的独立博客
V
V2EX
量子位
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
Jina AI
Jina AI
博客园 - 叶小钗
小众软件
小众软件
博客园 - 【当耐特】
Y
Y Combinator Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
博客园 - 聂微东
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - woody.wu

在Ubuntu 24.04中安装openclaw全过程 配置qwen-code实现AI智能体编程,从此轻松让AI帮你写代码 使用spire.pdf绘制表格,当表格的内容超过一定长度会触发Index and length must refer to a location within the string AI写代码-window11安装claude code,以及在vs code中使用插件。 sqlserver 日志空间太满,导致磁盘空间不够的处理 在c#中利用MagickImage来实现图片的留白清除功能 利用扣子创建AI智能体大合集,智能体中包含有调用外部接口、意图识别、图片生成、大模型调用等 .NET8作为VUE打包项目宿主部署的配置 myql 8.0 安装随笔 SkiaSharp 在 Linux 上依赖一些系统级的库,需要确保这些库已经安装 2024 年年终总结 Quartz.NET学习笔记四->批量处理JOB 不同的JOB不同的时间执行不同的事情 真正实现可以编辑选择的下拉框--jquery 实现 jquery 实现图片轮换功能 - woody.wu - 博客园 在SQL Navigator 中做 oracle pl/sql SQL分析 [instant message]用asp.net+ jquery实现comet即时消息机制 ORACLE DBA学习笔记--使用LOGON TRIGGER限制用户登陆 ORACLE DBA学习笔记--管理归档日志文件 [简单分页]C#+JQUERY+ORACLE分页效果
开发我的第一个openclaw插件,接入本地查询客户信息的api接口。
woody.wu · 2026-03-11 · via 博客园 - woody.wu
{
  "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.