Zapier CLI 触发器 - 如何在设置期间未返回结果时使用定义的示例数据

Zapier CLI Trigger - How to use defined sample data when no results returned during setup

我正在尝试使用 Zapier CLI 制作触发器原型,但在 UI 中设置触发器时 运行 'Pull In Samples' 部分出现问题。

这会尝试提取要使用的实时数据样本,但是文档指出,如果没有返回结果,它将使用为触发器配置的样本数据。

在大多数情况下,不会有实时数据,因此理想情况下实际上更喜欢在第一个实例中使用示例数据,但是我的触发器似乎从未使用过示例,而且我一直无法找到'no results' 响应的具体示例。

API 我正在使用 returns XML 所以我将结果处理成 JSON 如果有数据就可以正常工作。

如果到目前为止没有结果,我尝试返回“[]”,但它只是挂起,如果我检查 zapier http 日志,它会循环 http 请求,直到我取消样本检查。

返回“[{}]”returns 一个错误,我需要一个 'id' 字段。

我使用的定义是:

module.exports = {
key: 'getsmsinbound',
noun: 'GetSMSInbound',
display: {
    label: 'Get Inbound SMS',
    description: 'Check for inbound SMS'
},
operation: {
    inputFields: [
        { key: 'number', required: true, type: 'string', helpText: 'Enter the inbound number' },
        { key: 'keyword', required: false, type: 'string', helpText: 'Optional if you have configured a keyword and you wish to check for specific keyword messages.' },
    ],
    perform: getsmsinbound,
    sample: {
        id: 1,
        originator: '+447980123456',
        destination: '+447781484146',
        keyword: '',
        date: '2009-07-08',
        time: '10:38:55',
        body: 'hello world',
        network: 'Orange'
    }
}

};

我希望这是显而易见的事情,因为在搜索网络和 Zapier 文档时我没有任何运气!

示例数据必须由您的应用程序提供,并且示例有效负载不专门用于此投票。来自 docs:

Sample results will NOT be used for a user's Zap testing step. That step requires data to be received by an event or returned from a polling URL. If a user chooses to "Skip Test", then the sample result, if provided, will be used.

就我个人而言,我从未见过 "Skip Test" 出现。不久前,我就此询问了支持人员:

That's a great question! It's definitely one of those "chicken and egg" situations when using REST Hooks - if there isn't a sample available, then everything just stalls.

When the Zap editor tries to obtain a "sample result", there are three places where it's going to look:

  1. The Polling endpoint (in Step #3 of your trigger's setup) is invoked for the current user. If that returns "nothing", then the Zap editor will try the next step.
  2. The "most recent record/data" in the Zap's history. Since this is a brand new Zap, there won't be anything present.
  3. The Sample result (in Step #4 of your trigger's setup). The Zap editor will tell the user that there's "nothing to show", and will give the user the option to "skip test and continue", which will use the sample JSON that you've provided here.

实际上,它只会继续一遍又一遍地重试请求,永远不会为用户提供 "skip test and continue" 选项。我刚刚再次发送电子邮件询问此后是否有任何变化,但看起来现有示例数据是必需的。

也许默认情况下在您的 API 中创建一条记录并将其隐藏以防止正常使用,然后将其发回?

或者即使 Zapier 拒绝发送回虚拟数据。不确定,但我不知道人们如何在尚未创建数据时设置 zap(并且 Zapier 说他们的应用程序中没有多少有这个问题,但几乎我创建的每个触发器以及其他用例否则应用程序会提示我)。