Calling autotask from another autotask

Hey there, is it possible to call an autotask, from inside another autotask?
Direct or with the webhook of the other?
Thanks in advance!

Hey @karola,

Indeed the easiest way is via webhooks, however, somebody from your team can suddenly change the webhook, breaking something depending on it.

We're planning to work on UX improvements on that regard, so I'm curious, is there any reason you didn’t go immediately for using the webhook?

Best

hey, thanks for the fast answer!
I'm new to the Defender system, so i was thinking there was an "under-the-hood" connection between the autotasks.
So i can directly do a POST to the other autotask webhook?
My target is to launch an autotask each X hours (just to call a contract and check for states), if some parameters are respected, another autotask should be fired (using a relayer on another chain).

Hey, no problem, happy to help :smile:

If you want to connect Autotasks, yes, you can just POST to another Autotask's webhook. However, sounds to me like you want to monitor state changes on a contract and that’s achievable by setting up a Sentinel.

For example, you can listen to events/transactions with certain parameters on one chain, and whenever it triggers, fire an Autotask connected to a relayer on another chain.

Hope that helps!

Yeah that's so wonderful! But it's not what i need actually.
What i'm missing is a way to read from chain1 and write in chain2, from a single autotask.
So i'll try to POST from autotask1, with the data from chain1, on autotask2, i'll do state changes on chain2 with the data received.

The most efficient way to call an auto task from another autotask is through the Defender Autotask Client package and use the runAutotask method , You would only have to pass the ID of the autoTask you want to call and the parameters

Thanks for the details

Currently, we don't have a way to have more than one relayer attached to an Autotask but it's a good feedback.

through the Defender Autotask Client package and use the runAutotask method

Actually, this suggestion is way better (thanks @asmel). The defender-autotask-client is already available on the Autotask environment, so should be way easier to setup.

Consider also using the secrets to keep your API Keys safe.

Best

1 Like

Thanks guys! Indirectly it's the only way i can do that, as i need to switch from WebHook to timer :slight_smile:
Glad it supports arguments too (even if it's not written on the docs)