探索 Tiptap V3 的最新功能

评论 Webhook

Available in Team plan

设置和管理 Webhook,以改善您的评论集成。评论 Webhook 的常见用例包括:

  • 在创建、解决、更新或删除线程时发送通知。
  • 在添加、更新或删除评论时通知用户。
  • 结合使用 提及扩展,在用户被提及时向用户发送电子邮件或通知。

启用评论事件

对于 2024 年 3 月 1 日后创建的账户,评论 Webhook 默认启用。否则,您可能仍在使用旧版本的 Webhook 系统,需要手动升级:

  1. 如果您之前实现了协作 Webhook,请在处理传入 Webhook 时检查 typetrigger 字段。(文档
  2. 访问您的 协作设置
  3. 在 Webhooks 部分,点击 升级

该升级有必要以便适应多种新事件被路由到同一 Webhook 端点的引入,新的 typetrigger 字段作为区别。

配置 Webhook

要配置评论通知的 Webhook:

  1. 访问您账户中的 协作设置
  2. 在 Webhooks 部分,添加您希望的端点 URL。

添加 URL 后,Webhook 会立即生效。您将开始接收指定事件的通知,毫无延迟。

Webhook 事件

评论 Webhook 触发与评论扩展内线程和评论相关的多种事件的通知。这些事件在其关联操作发生时立即触发。

  • comment.added
  • comment.updated
  • comment.deleted
  • thread.created
  • thread.resolved
  • thread.updated
  • thread.deleted

示例有效载荷

以下是不同类型 Webhook 事件的示例有效载荷:

线程/评论创建

{
  "trigger": "comment.added",
  "thread": {
    "id": "128ba3a9-c684-4956-8c9f-fe5dc147c7e5",
    "createdAt": "2024-03-02T22:17:51.304Z",
    "comments": [
      {
        "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
        "createdAt": "2024-03-02T22:17:51.307Z",
        "updatedAt": "2024-03-02T22:17:51.307Z",
        "data": {
          "userName": "Cyndi Lauper",
          "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
        },
        "content": "线程创建评论"
      }
    ],
    "updatedAt": "2024-03-02T22:17:51.305Z"
  },
  "comment": {
    "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
    "createdAt": "2024-03-02T22:17:51.307Z",
    "updatedAt": "2024-03-02T22:17:51.307Z",
    "data": {
      "userName": "Cyndi Lauper",
      "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
    },
    "content": "线程创建评论"
  },
  "appName": "",
  "user": "",
  "name": "documentName",
  "type": "THREAD"
}

评论更新

{
  "trigger": "comment.updated",
  "thread": [
    {
      "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
      "createdAt": "2024-03-02T22:17:51.307Z",
      "updatedAt": "2024-03-02T22:18:04.246Z",
      "data": {
        "userName": "Cyndi Lauper",
        "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
      },
      "content": "线程创建评论(已编辑)"
    }
  ],
  "comment": {
    "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
    "createdAt": "2024-03-02T22:17:51.307Z",
    "updatedAt": "2024-03-02T22:18:04.246Z",
    "data": {
      "userName": "Cyndi Lauper",
      "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
    },
    "content": "线程创建评论(已编辑)"
  },
  "appName": "",
  "user": "",
  "name": "documentName",
  "type": "THREAD"
}

评论删除

{
  "trigger": "comment.deleted",
  "thread": {
    "id": "128ba3a9-c684-4956-8c9f-fe5dc147c7e5",
    "createdAt": "2024-03-02T22:17:51.304Z",
    "comments": [
      {
        "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
        "createdAt": "2024-03-02T22:17:51.307Z",
        "updatedAt": "2024-03-02T22:18:04.246Z",
        "data": {
          "userName": "Cyndi Lauper",
          "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
        },
        "content": "线程创建评论(已编辑)"
      }
    ],
    "updatedAt": "2024-03-02T22:17:51.305Z"
  },
  "comment": {
    "id": "1841e650-2202-42b6-a868-907fee42ccf7",
    "createdAt": "2024-03-02T22:18:20.974Z",
    "updatedAt": "2024-03-02T22:18:20.975Z",
    "data": {
      "userName": "Cyndi Lauper",
      "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
    },
    "content": "第二条评论,相同线程"
  },
  "appName": "",
  "user": "",
  "name": "documentName",
  "type": "THREAD"
}

线程删除

{
  "trigger": "thread.deleted",
  "thread": {
    "id": "128ba3a9-c684-4956-8c9f-fe5dc147c7e5",
    "createdAt": "2024-03-02T22:17:51.304Z",
    "comments": [
      {
        "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
        "createdAt": "2024-03-02T22:17:51.307Z",
        "updatedAt": "2024-03-02T22:18:04.246Z",
        "data": {
          "userName": "Cyndi Lauper",
          "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
        },
        "content": "线程创建评论(已编辑)"
      }
    ],
    "updatedAt": "2024-03-02T22:18:52.050Z",
    "resolvedAt": null
  },
  "appName": "",
  "user": "",
  "name": "documentName",
  "type": "THREAD"
}

线程解决

{
  "trigger": "thread.resolved",
  "thread": {
    "id": "128ba3a9-c684-4956-8c9f-fe5dc147c7e5",
    "createdAt": "2024-03-02T22:17:51.304Z",
    "comments": [
      {
        "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
        "createdAt": "2024-03-02T22:17:51.307Z",
        "updatedAt": "2024-03-02T22:18:04.246Z",
        "data": {
          "userName": "Cyndi Lauper",
          "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
        },
        "content": "线程创建评论(已编辑)"
      }
    ],
    "updatedAt": "2024-03-02T22:18:48.531Z",
    "resolvedAt": "2024-03-02T22:18:48.531Z"
  },
  "appName": "",
  "user": "",
  "name": "documentName",
  "type": "THREAD"
}

线程更新(即未解决)

{
  "trigger": "thread.updated",
  "thread": {
    "id": "128ba3a9-c684-4956-8c9f-fe5dc147c7e5",
    "createdAt": "2024-03-02T22:17:51.304Z",
    "comments": [
      {
        "id": "0259e4cb-43ad-4eb2-a7e9-a7a7d5207a76",
        "createdAt": "2024-03-02T22:17:51.307Z",
        "updatedAt": "2024-03-02T22:18:04.246Z",
        "data": {
          "userName": "Cyndi Lauper",
          "userAvatar": "https://api.dicebear.com/7.x/lorelei/svg?seed=Cyndi Lauper"
        },
        "content": "线程创建评论(已编辑)"
      }
    ],
    "updatedAt": "2024-03-02T22:18:52.050Z",
    "resolvedAt": null
  },
  "appName": "",
  "user": "",
  "name": "documentName",
  "type": "THREAD"
}