跳到主要内容
此模块已弃用且不再受支持。以下文档不适用于 0.2.0 或更高版本。
完整文档请参见此处:https://nla.zapier.com/start/ Zapier 自然语言操作 (Natural Language Actions, NLA) 通过自然语言 API 接口,让您可以使用 Zapier 平台上的 5000 多个应用程序和 20000 多个操作。 NLA 支持 Gmail、Salesforce、Trello、Slack、Asana、HubSpot、Google Sheets、Microsoft Teams 以及数千个其他应用程序:https://zapier.com/apps Zapier NLA 处理所有底层的 API 身份验证和从自然语言 -> 底层 API 调用 -> 返回简化输出以供 LLM 使用的转换。关键思想是您或您的用户通过类似 oauth 的设置窗口公开一组操作,然后您可以通过 REST API 查询和执行这些操作。 NLA 为 NLA API 请求签名提供 API Key 和 OAuth 两种方式。 服务器端(API Key):用于快速入门、测试和生产场景,其中 LangChain 将仅使用开发者 Zapier 账户中公开的操作(并将使用开发者在 Zapier.com 上连接的账户)。 面向用户(OAuth):用于生产场景,您正在部署面向最终用户的应用程序,并且 LangChain 需要访问最终用户公开的操作和在 Zapier.com 上连接的账户。 通过环境变量(ZAPIER_NLA_OAUTH_ACCESS_TOKENZAPIER_NLA_API_KEY)附加 NLA 凭据,或参考 API 参考中 ZapierNLAWrapper 的 params 参数。 有关更多详细信息,请查阅身份验证文档 以下示例演示了如何将 Zapier 集成用作 Agent:
有关安装 LangChain 软件包的一般说明,请参阅此部分
npm
npm install @langchain/openai @langchain/core
import { OpenAI } from "@langchain/openai";
import { ZapierNLAWrapper } from "@langchain/classic/tools";
import {
  initializeAgentExecutorWithOptions,
  ZapierToolKit,
} from "@langchain/classic/agents";

const model = new OpenAI({ temperature: 0 });
const zapier = new ZapierNLAWrapper();
const toolkit = await ZapierToolKit.fromZapierNLAWrapper(zapier);

const executor = await initializeAgentExecutorWithOptions(
  toolkit.tools,
  model,
  {
    agentType: "zero-shot-react-description",
    verbose: true,
  }
);
console.log("Loaded agent.");

const input = `Summarize the last email I received regarding Silicon Valley Bank. Send the summary to the #test-zapier Slack channel.`;

console.log(`Executing with input "${input}"...`);

const result = await executor.invoke({ input });

console.log(`Got output ${result.output}`);

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.