2

I am trying to prototype a trigger using the Zapier CLI and I am running to an issue with the 'Pull In Samples' section when setting up the trigger in the UI.

This tries to pull in a live sample of data to use, however the documentation states that if no results are returned it will use the sample data that is configured for the trigger.

In most cases there will be no live data and so ideally would actually prefer the sample data to be used in the first instance, however my trigger does not seem to ever use the sample and I have not been able to find a concrete example of a 'no results' response.

The API I am using returns XML so I am manipulating the result into JSON which works fine if there is data.

If there are no results so far I have tried returning '[]', but that just hangs and if I check the zapier http logs it's looping http requests until I cancel the sample check.

Returning '[{}]' returns an error that I need an 'id' field.

The definition I am using is:

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'
    }
}

};

I'm hoping it's something obvious as on scouring the web and Zapier documentation I've not had any luck!

Spud
  • 35
  • 5
  • Just asked Zapier support the same question. If I remember correctly, they basically expect you to have some data created already, so "no data" is not really an option, even though their documentation specifies otherwise (and encourages you not to send back dummy data). I'll post again when I get a response from support. They are usually pretty speedy. – typeoneerror Apr 19 '18 at 16:53

1 Answers1

2

Sample data must be provided from your app and the sample payload is not used for this poll specifically. From the 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.

Personally, I have never seen "Skip Test" show up. A while back I asked support about this:

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.

In reality, it will just continue to retry the request over and over and never provide the user with a "skip test and continue" option. I just emailed again asking if anything has changed since then, but it looks like existing sample data is a requirement.

Perhaps create a record in your API by default and hide it from normal use and just send back that one?

Or send back dummy data even though Zapier says not to. Not sure, but I don't know how people can set up a zap when no data has been created yet (and Zapier says not many of their apps have this issue, but nearly every trigger I've created and ever use case for other applications would hint to me otherwise).

typeoneerror
  • 55,990
  • 32
  • 132
  • 223
  • Many thanks for this :). The API I am prototyping against is mature so I can't really make any changes to it, however in my zap I've been able to make use of the 'frontend' property of bundle.meta which is set to true if the call is made from the Zap editor. With that I can pass a hard-coded sample response back. If you do get further confirmation it would be great to hear as right now the sample in the definition seems to be next to useless. – Spud Apr 20 '18 at 13:36
  • Just heard from Zapier and the ‘frontend && [].empty?’ methid you described is what they recommended. – typeoneerror Apr 21 '18 at 16:14