0

我正在关注 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,
    ...
  }
}
4

1 回答 1

1

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

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

所以,要实现:

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

有关更多信息,请参阅 GH 问题。

于 2021-07-16T18:34:48.143 回答