未等待 zapier performResume 步骤 / 运行

zapier performResume step not being waited for / run

我正在关注 zapier 中关于 callbackUrl https://platform.zapier.com/cli_docs/docs#zgeneratecallbackurl 的文档,但似乎无法将 performResume 步骤设置为 运行。我基于此集成创建的 zap 似乎也没有等待 callbackUrl 被命中。

const createScreenshot = (z, bundle) => {
  const callbackUrl = z.generateCallbackUrl();
  const promise = z.request({
    url: 'https://myapi.com/v1/render',
    method: 'POST',
    params: {},
    headers: {
      'Content-Type': 'application/json',
      Accept: 'application/json',
    },
    body: {
      ...bundle.inputData,
      webhook_url: callbackUrl
    },
    removeMissingValuesFrom: {},
  });
  z.console.log("Returning from perform / createScreenshot");
  return promise.then((response) => ({ ...response.data, waiting_for: "performResume" }));
const onScreenshotFinished = (z, bundle) => {
  z.console.log("In performResume / onScreenshotFinished", bundle.cleanedRequest);
  const responseBody = bundle.cleanedRequest;
  let screenshotUrl;

  if (responseBody.event === "render.succeeded") {
    z.console.log("render was processed successfully", responseBody);
    screenshotUrl = responseBody.result.renderUrl;
    return { screenshotUrl, ...responseBody };
  }

  z.console.log("render was not processed", responseBody);
  throw z.errors.Error("Screenshot was not successful");
}
module.exports = {
  operation: {
    perform: createScreenshot,
    performResume: onScreenshotFinished,
    ...
  }
}

我们在 GitHub (zapier/zapier-platform#398) 上讨论了这个问题(及其解决方案),但为 SO 读者总结:

设置可恢复的 Zap 时,编辑器使用 sample 填充回调中的数据。在设置过程中没有实际等待发生。一旦 zap 上线,它就会正常工作。

因此,要实施:

  • perform 应该 return 与“resume”webhook 发送的数据相匹配的样本数据
  • performSubscribe 可以读取该数据并正常运行

查看 GH 问题了解更多信息。