Webhook

Webhook 通知并帮助您收集在 Crowdin 企业版上发生的关键事件的信息,例如译文完成或校对。 当您针对项目配置 Webhook 后,Crowdin 企业版将开始通过 HTTP 发送带有数据的 POST 或 GET 请求。

只有行政管理和组/项目管理员才能注册 webhook。

用例

您可以通过添加 webhooks 来建立与服务或与您后端的集成。 例如:

  • 设置 webhook 来向您的系统发送通知。
  • 向第三方服务传送附加有特定请求需求的信息(例如HTTP方法、内容类型等)。
  • 创建与 Crowdin 企业版的自定义集成。

事件

您可以为以下类型的事件配置 webhooks:

Webhook 负载示例

在 Crowdin 开发者门户上阅读有关 基于文件的 Webhook 事件基于字符串的 Webhook 事件 的更多信息。

添加 Webhooks

To configure webhooks in Crowdin Enterprise, open your project and go to Integrations > Webhooks on the left panel. Click Create to start configuring your new webhook.

您需要提供以下信息才能注册 Webhook:

  • The webhook name (for example, “New translation added”).
  • 要发布到指定 URL 的事件列表。 您可以选择任意一个或一组事件。
  • 应发送回调的 URL 地址。
  • 对某资源需要执行的请求方法(GET或POST)。
  • POST 请求方法的内容类型 (multipart/form-data、application/jsonapplication/x-www-form-urlencoded)。
  • 对于 application/json 内容类型,您可以选择 批次网络钩子 将多个事件合并为单个请求。

Optionally, you can add special headers to your webhook. 作为一种授权方法,它们可以用来提供更多的安全保障。 For example, if you add headers, your webhook endpoint can check them to ensure that information is coming from Crowdin Enterprise.

添加 Webhook

When adding a webhook, you can test how your application will react to that call.

Test Webhook

Depending on your approach to webhooks management, you might need to add dedicated Crowdin Enterprise IP addresses to your firewall to allow Crowdin Enterprise to open the pre-configured webhook URLs.

Read more about IP Addresses.

自定义有效载荷

Each event type in Crowdin Enterprise has a specific payload format with the relevant event information. You can customize the webhook payload to add and organize the elements the way your system requires.

To check the event’s possible variables, hover over the Info icon in the Payload section’s right upper corner.

自定义有效载荷

将 Webhooks 发送至 Slack

With the help of Crowdin Enterprise webhooks, you can send notifications about pre-configured event types directly to a specific Slack channel.

To configure the webhooks’ sending to Slack, you’d need to create a simple Slack app. Read more about Sending messages to Slack using Incoming Webhooks.

As soon as you create and configure your Slack app, you’ll have a Webhook URL that should be used for the Webhooks configuration in your Crowdin Enterprise project.

Note: To send webhooks to Slack, ensure that your custom payload contains the "text" field, and the Batch webhooks option is cleared.

编辑或删除 Webhook

您可以访问特定项目中所有现有的 web 钩子的列表。 您能够从显示的 Web 钩子列表中编辑或删除任何 Web 钩子。

管理 Webhooks

活动

After the events are triggered, you will be able to review the activity of each webhook separately. Use the filter to review all or only unsuccessful webhook notifications.

Webhooks Activities

Alternatively, you can review the full list of sent webhooks in the Webhooks Log. Filter webhook notifications by result (Any or Unsuccessful), event types, or name.

Webhooks Log

Webhook 失败

过去 24 小时内响应代码为 4xx 或 5xx 范围内且失败次数达到 100 次及以上的 Webhook 会被自动禁用。

已禁用的 Webhook

已禁用的 Webhook 会在 Webhooks 部分列出,并显示一个清除的勾选标记,表示它们当前由于持续失败而处于非活动状态。 要发现更多有关失败的 Webhook 信息,请导航到 调用历史 > 失败 部分。 在这里,您可以探索有关每个失败的 Webhook 所遇到的问题的详细信息。

手动重新启用

一旦您识别并解决了 Webhook 失败的原因,就可以手动重新启用 Webhook 以恢复其功能。 在 Webhooks 部分,找到已禁用的 Webhook 并选择它进行重新启用。

寻求协助

在 Webhook 使用上有任何问题或需要帮助? 联系支持团队

本文是否有帮助?