Skip to main content

Hello,
is it possible to output a file (csv, xlsx, json, XML) from Zapier trigger?

I'm making an integration from a service, that calls Zapier through webhooks informing there's a file to fetch. In the perform function, I make an API call to get the document and I would like to output the result of that call. 

From what I can see, it looks like Trigger output should be a JSON. Is it possible to output for example a CSV file? If so, how? 

Right now, I try to stash the file and return just the URL in following way: (feeling it's not quite it)

const file = z.dehydrateFile(() => {
const req = z.request(options)
const stash = z.stashFile(req)
return stash
})

return nfile]

In the Test section I got following message:
We could not find your function/array/object anywhere on your App definition.

Turns out, stashing files isn't possible in the UI integrations: https://platform.zapier.com/docs/vs

However, still not how the output should look like to contain a proper file.


Alright, figured it out, so I'll post it here for future reference.
First look at https://github.com/zapier/zapier-platform-example-app-files it helped a lot.

To answer the question, how to output a file. Return an array, with an object, where one of the keys (for example "file") is the output of z.dehydrateFile function. In this function you can return z.stashFile(z.request(optionsToFetchTheFile))

The stashFile function basically returns a URL, which is registered by Zapier as a file (or a to-be file).

Finally:

const file = z.dehydrateFile(() => {
const req = z.request(options)
const stash = z.stashFile(req)
return stash
})

return u{ file }]