Skip to main content
Best answer

How to output a file from a Trigger


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 [file]

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

Best answer by Albert NemecBest answer by Albert Nemec

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 [{ file }]

 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

  • Author
  • Beginner
  • 2 replies
  • April 21, 2020

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.


  • Author
  • Beginner
  • 2 replies
  • Answer
  • April 22, 2020

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 [{ file }]