将 Zapier AI Actions 配置为 Tool
最新更新:2024-02-21

将 Zapier AI Actions 配置为 Tool

关于 Zapier

Zapier 是一个流行的在线自动化工具,它允许用户连接不同的应用程序、服务和 API ,以便它们可以协同工作,无需用户手动进行数据传输或执行任务。Zapier 的核心概念是「Zaps」,即用户定义的自动化工作流程。一个 Zap 由触发器(Trigger)和动作(Action)组成:当某个应用程序中的特定事件发生时(例如,收到一封新电子邮件),触发器就会被激活,然后 Zapier 可以自动执行一系列动作(例如,将电子邮件的内容添加到某个数据库中)。

Zapier 提供了成千上万的预构建集成,涵盖了各种流行的应用程序和服务,如 Gmail、Google Sheets、Slack、Trello、Salesforce 等。这使得即使是非技术用户也能够轻松设置自动化流程,提高工作效率,减少重复性工作。

使用 Zapier,用户可以创建简单的自动化流程,例如将电子邮件转换为任务,或者更复杂的流程,如跨多个应用程序和数据库自动同步和更新数据。Zapier 的平台灵活且易于使用,是企业和个人提高工作效率的强大工具。

强大的 Zapier AI Actions

Zapier AI Actions 是一个工具,让构建者能够为 AI 平台(或自定义集成)装备运行任何 Zapier 操作的能力!您所熟悉并喜爱的来自 Zapier 自动化平台的 20,000 多个 Actions 都可以与您喜欢的 AI 工具一起使用。

同时,在 Zapier AI 的加持下,使得 Actions 变得更加易用!

例如,当我们发送 Email 时,需要依次填写收件地址、邮件标题和正文。但现在,通过 AI Action,您仅需要通过一条「指令(Instruction)」,即可让 Zapier AI 为您完成后续的指令解析和 Action 调用动作。

例如,您的指令是:

Send an email to xxxxxx@126.com, ask him to come to my office.
          Send an email to xxxxxx@126.com, ask him to come to my office.

        
此代码块在浮窗中显示

Zapier AI 将自动进行意图识别,将您的指令解析为:

to: xxxxxx@126.com subject: Meeting Request body: Please come to my office.
          to: xxxxxx@126.com
subject: 	Meeting Request
body:	Please come to my office.

        
此代码块在浮窗中显示

并基于该解析结果,为您执行 Action。

这意味着,您在 GPTBots 内创建的 Bot,可以通过 GPTBots Tools,在经过简单的配置后,就能连接 Zapier 内成千上万的 Actions,让您的 Bot 的能力得到充分的释放!再通过简单的对话向 Bot 发送指令,就能轻松调用这些 Actions,完成各种任务!

Zapier 配置

image-20240221214321769

image-20240221185835648

访问 Zapier AI Actions,找到「My Actions - Manage Actions」,并创建 Action。

image-20240221222728513

选择您需要的 Action,本文以「Gmail: Send Email」为例。该 Action 可以接受一个指令,Zapier AI 自动解析该指令内的参数(收件箱、邮件标题、邮件正文等),并执行发送邮件的动作。

将您的 Gmail 账号进行授权,并按需设置每一个参数。每一个参数都可以按需设定特定的值,也可以如图所示一般,交由 Zapier AI 自动解析(Have AI guess a value for this field)。

image-20240221214422066

确保您的 Action 处于开启状态。

image-20240221223328025

您可以先到「Test Actions」内,对刚配置好的 Action 进行测试,以确保其处于可用状态。

image-20240221223359569

若 Results 内的状态为「success」,则 Action 执行成功,测试通过。

image-20240221223809670

接下来,到「API Playground」内,找到/api/v1/exposed/,运行它,并获取 Action ID,后续配置 GPTBots Tool 时需要用到。

image-20240221214527178

在「Credentials」内,找到您的「API Key」,后续配置 GPTBots Tool 时需要用到。

GPTBots Tool 配置

在「企业 Tools」内,创建一个 Tool。

鉴权

image-20240221224124281

选择「开发方鉴权 - None」即可,使用 Zapier AI Actions 无需鉴权。

JSON 配置

这是接入上述的「Gmail: Send Mail」的 Zapier AI Action 的 Tool 配置,您可以基于该结构,去配置您其他的 Zapier AI Actions。

您可以仅关注有注释的部分,其他部分基本上都可以直接复制使用,无需更改。

{ "openapi": "3.0.0", "servers": [ { "url": "https://actions.zapier.com" } ], "paths": { "/api/v1/dynamic/exposed/<your_action_id>/execute/": { //将<your_action_id>替换为您的 Action ID。 "post": { "operationId": "zpGmailSendEmail", //为 Action 命名。 "description": "Call this API when user wants to send an Email.", // 关于该 Action 的描述,让 LLM 了解如何与该 Action 交互。 "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Request" } } } }, "responses": { "200": { "description": "Successfully sent the mail.", //Action 调用成功的描述。 "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Response" } } } }, "400": { "description": "Invalid Request." //返回 400 的描述。 } }, "parameters": [ { "name": "x-api-key", "in": "header", "required": true, "description": "The API Key of the Zapier AI Actions.", "schema": { "type": "string", "default": "<your_api_key>" //填写您的 Zapier AI Actions 的 API Key。 } } ] } } }, "components": { "schemas": { "Request": { "type": "object", "properties": { "instructions": { "type": "string", "description": "The instruction of the Zapier AI Action 'zpGmailSendEmail'." //告知 LLM 该指令的作用。 } }, "required": [ "instructions" ] }, "Response": { "type": "object", "properties": { "id": { "type": "string", "description": "Request Id" }, "status": { "type": "string", "description": "Request Status" } }, "required": [ "instructions" ] } } } }
          {
  "openapi": "3.0.0",
  "servers": [
    {
      "url": "https://actions.zapier.com"
    }
  ],
  "paths": {
    "/api/v1/dynamic/exposed/<your_action_id>/execute/": {	//将<your_action_id>替换为您的 Action ID。
      "post": {
        "operationId": "zpGmailSendEmail",	//为 Action 命名。
        "description": "Call this API when user wants to send an Email.",	// 关于该 Action 的描述,让 LLM 了解如何与该 Action 交互。
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully sent the mail.",	//Action 调用成功的描述。
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Response"
                }
              }
            }
          },
          "400": {
            "description": "Invalid Request."	//返回 400 的描述。
          }
        },
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": true,
            "description": "The API Key of the Zapier AI Actions.",
            "schema": {
              "type": "string",
              "default": "<your_api_key>"	//填写您的 Zapier AI Actions 的 API Key。
            }
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Request": {
        "type": "object",
        "properties": {
          "instructions": {
            "type": "string",
            "description": "The instruction of the Zapier AI Action 'zpGmailSendEmail'."	//告知 LLM 该指令的作用。
          }
        },
        "required": [
          "instructions"
        ]
      },
      "Response": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Request Id"
          },
          "status": {
            "type": "string",
            "description": "Request Status"
          }
        },
        "required": [
          "instructions"
        ]
      }
    }
  }
}

        
此代码块在浮窗中显示

在 Bot 内使用 Tool

image-20240221232739323

在 Bot 内,直接通过自然语言描述你想做的事情,Bot 会自行判断是否调用。在调用时,Zapier AI 也会自动解析为合理的 Action 入参。

image-20240221232529843

该封邮件被成功地发送至了指定的地址,并且由 Zapier AI 自动地根据用户输入的要求,创作了邮件标题和正文。