javascriptzapierzapier-cli

How to reuse javascript functions in zapier


I have a bigger network of hundreds of zaps connected by webhooks. They are all using code steps running javascript functions to clean data, run scripts, make fetches, ect.

Needless to say, many of the functions I am using have to be reused across zaps, and managing them is increasingly becomming difficult. If I have to change one function/parameter, I have to change it manually in all zaps. Exporting the zaps is not possible, as the webhook triggers are changed once they are imported (sadly).

I am looking for a way to centralize my common functions, but haven't been able to figure out a solution that would work.

So far:

  1. I tried to convert functions into strings, save them through the store function and then use new Function() to convert them back to functions. This didn't work well, especially when trying to use complex functions.

  2. I also considered building my own Zapier App, where I easily could store common functions which seems as a good solution. The problem here is that I would end up with 150 different "create" steps, which wouldn't be very easy to use. I haven't been able to find anywhere if it is possible to have "dynamic" create-steps just as the inputFields where you can search to find the options you need.

Maybe there exist a "modifiable" code app for Zapier, where I can define my functions and add them to an code editor so it is thereby supercharged with my functions? That would be cool.

I am hoping that I am missing some obvious option here, as I am stuck at this moment. I am also pretty sure, that others have been where I am now, I just haven't been able to find the question in here.

Any suggestions?


Solution

  • David here, from the Zapier Platform team. Great question!

    The answer is definitely to pull all these functions into a custom app. We've got info about that here: https://github.com/zapier/zapier-platform/blob/master/packages/cli/README.md

    That'll give you the flexibility needed to write and organize your JS code however you'd like.

    The problem here is that I would end up with 150 different "create" steps, which wouldn't be very easy to use. I haven't been able to find anywhere if it is possible to have "dynamic" create-steps just as the inputFields where you can search to find the options you need.

    The editor has a dropdown to search for actions easily. Here's me filtering Slack for "create" actions having to do with message:

    It would be up to you to name your functions well, but it wouldn't be too hard to find them after that.

    We do a similar thing with our Formatter by Zapier app, where the "Text" category has a ton of little functions: