Call a function from a Zap

With Zapier Functions, you can connect your function code to a Zap. This allows you to run custom code as a step in your Zap with access to features like Python packages, secrets, and a full development environment. You can call your function from any new or existing Zap by adding a Zapier Functions action event to it.

Beta

This product is in open beta. It’s available for use but still in active development and may change.

Requirements

To use a function with a Zap, you must have:

In your function

  • A Start a Function trigger.
  • Input fields set up in the Start a Function trigger.
  • Sample output data to use when testing the Zap step.
  • (Optional) A Return from a Function (return_action) action event in your code to return data to the calling Zap. 

In your Zap

  • A Zapier Functions Call a Function action event.

1. Create a function

A function normally starts from a function trigger related to a specific app. When you call it through a Zap, the trigger can retrieve any information that's part of that Zap, allowing you to reference, in your code, data from different steps of that Zap. 

Learn how to create a new function

Set up your function trigger

  • On the left sidebar of your function, click the Explorer icon. This will expand the sidebar.
  • Next to the Triggers section, click the plus sign +. This will create a new trigger file.
  • Within the trigger editor, start typing `functions` to find Zapier Functions and select it.
  • In the next field, select Start a Function as the trigger event.
  • Once the parameters load, add the input fields you want to use in the Zap.
    • Add one value per text field.
    • Fields you create here will appear in your Zap step Configure tab.
  • In the Sample Data field, enter sample data to be used when testing your Zap step. 
Screenshot 2025-05-29 at 5.34.08 PM.png
Note

If you're using the return_function action in your code, make sure the action parameters within the Output Data field match the structure of the sample output you add to this field.

Write your code

Your code can incorporate data coming from your Zap by referencing your trigger's output

(Optional) Return results to the Zap

If you want to return the code's results to the Zap, add a Return from a Function action (return_function). The Zap will wait for the function to finish running and return the contents of the return_function action to your Zap step as that step's output. 

To add this action, enter zapier.action.functions.return_function into your code. This will populate the parameters for that action, and you can enter any data you'd like to pass back to the Zap.

Screen Shot 2025-05-23 at 4.18.38 PM.png

The return_function action ends the function's execution, so you can only call it once in an execution path. If you do not use return_function in your code, the Zap step will halt once it calls the function. If you're not returning data to your Zap, make sure the Zapier Functions step is the last one in your Zap.

2. Set up your Zap

Add a trigger and other action steps

Your function can use data from any trigger or action step in the Zap that precedes the Zapier Functions step. After you set up your trigger and other actions, add the Zapier Functions step to your Zap.

Add a Zapier Functions action

  • In the Zap outline, click the Action step or the plus sign + to add a new action. A dialog box will open.
  • In the search box, search for and select Zapier Functions. The right sidebar will open to the Setup tab.
  • Click the Action event field to open the dropdown menu, then select Call a Function.
  • Select the Configure tab.
  • Click the Select Function and Trigger field to open the dropdown menu, then select the trigger for your function.
    • Only functions that use the trigger Start a Function appear in the dropdown menu. Click Refresh results if you make changes to your function.
  • Fill out the input fields created in your function trigger. You can map data from previous steps to them.
    • Click Refresh fields if you add more input fields to your function.
  • In the field Would you like to run this Function while testing?, decide if you want the function to run during test or not.
    • If you select True, all code in your main.py file will run when testing your Zap. You can also select a version of the function to run during testing.
    • If you select False, the code will not run and the Zap step will output the sample data you set up in your function trigger.

Tip

You can also start a new function from the link in your Zap step, with the trigger pre-selected and a return_function action in the main.py file.

(Optional) Add more steps to your Zap

If you add a return_function to your code, once your Functions by Zapier step finishes running, you can use the content of the output fields in later steps. You can then add more actions, or use paths and filters to create conditional logic.

Learn more:

Provide feedback and get help

Submit a feature request, provide feedback on existing features, or get help from the Zapier Functions team. You can also discuss Functions with other users on Zapier's Early Access Program Slack.

Was this article helpful?
0 out of 0 found this helpful