Question

Can anyone share an example of a trigger coded in Python?

  • 15 March 2021
  • 5 replies
  • 1845 views

Hi everyone,

I would like to know if it is possible to have an example of trigger coded in Python just to understand the logic. Thanks in advance


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Userlevel 7
Badge +14

Hi @FenixShadows 

Check out these help articles for some guidance:

https://zapier.com/help/create/code-webhooks/python-code-examples-in-zaps

https://zapier.com/help/create/code-webhooks/javascript-code-examples-in-zaps

 

Thanks @Troy Tessalone  for your answer, but unfortunately with this link I don't think I have a solution to my need. I would like to set up a trigger via a python code that will trigger a number of tasks when a condition is checked. In the examples in the link I think there are more examples of actions not triggers. So I would just like to have an overview of a functional trigger via code.

 

Userlevel 7
Badge +12

@FenixShadows 

The only way I could think a ‘code block’ could act as a trigger would be if it was listener for a webhook from another event. 

Can you elaborate more on the conditions you are checking and the behavior you are looking for?

Thank you for your feedback.

Here is an example of a context that illustrates what I want to do. Through an API I have the ability to access the child and parent tables. If a field in the parent table is changed, I would like to perform a set of tasks on the corresponding child fields.

How to set up a trigger by code considering that it is possible to have several simultaneous changes for the same row in the parent table?

Thanks in advance for your feedback

 

Userlevel 3
Badge +6

Hey @FenixShadows, hope you’re well!

Does the API have an endpoint that could be polled to check for an updates to the parent table? Or do they support webhooks for sending out data?

What I’m thinking here is that you could use a Webhook trigger in your zap and set it to either a GET poll or a Catch Hook trigger, depending on the API. Using this trigger zap could poll the endpoint asking for updated data or wait to receive the data at the catch hook URL we provide.

From there, you could set the next step in the zap to be a Code step using Python and perform the coding work you need on the data we received at the trigger.

For more info on Webhooks, check out this page: https://zapier.com/help/doc/how-get-started-webhooks-zapier

If you’re 100% looking to keep everything in a trigger, it would be recommended to check out our development platform and build your own private integration for that trigger: https://zapier.com/platform