I want to create a webhook that will trigger another webhook and return it's outcome to the original call

Hello everyone,

I’m working on an interesting challenge and could use some guidance. I’m trying to create an iterative webhook call. Essentially, I want the webhook to trigger a call, and if there’s missing data in the response, I want it to fetch the missing data and then re-trigger the same webhook.

Here’s what I have so far:

Webhook Trigger: Initiates the process.
Data Check: If the response has missing data, I identify what’s missing.
Fetch Missing Data: Collect the necessary data if anything is missing.
Re-trigger Webhook: Once the missing data is obtained, I call the same webhook again with the complete information.

I’m stuck on how to loop the webhook call within the same scenario if the data is missing and I re-trigger the webhook, I just get an “accepted” response instead of the “webhook response” I was hoping to get. I’m guessing it has to do with the fact that the run is over but I want a way to reply only with the response modul.

Has anyone encountered a similar situation or have any ideas on how to structure this? Your expertise and guidance would be highly appreciated!

Thank you in advance, Adam.

I don’t think you should be using webhooks to make the initial call. Use a normal HTTP request to call a scenario that has a webhook trigger, and returns a webhook response when done.

You are seeing the “accepted” default response is because a webhook that returns a response needs to have a “webhook response” module.

2 Likes

Hi Adam and welcome!

Don’t think there’s any need to recursively call your scenario, but I am also not familiar with your entire workflow, so I guess it depends on things like how you’re checking for missing data and some other factors.

If you add a router after your webhook trigger, you could add some filters that tell your scenario which route to take next depending on how the data look.
The filters on the first route could be set up to dump the data you do have into variables.
Route 2: Filter this route to run only if key pieces of data are missing. Then, get the data, and dump into variables, overwriting some of those you may have done on the first route.
Route 3: Get all the variables and continue your scenario to end with a Webhook Response.

So long as the entire scenario completes in ~40 seconds, the Webhook Response should kick in instead of giving the standard “Accepted” response.

This is probably not the best way, but I’m curious to see how others deal with this sort of thing.

2 Likes

Ok, you can definitely do this.

webhook
HTTP request to the other module
wait step
retrieve data from data store, cloudflare KV, etc
continue

Other module receives 1st module
whatever calls you need to do
post the data to a data store, cloudflare KV, etc

Just make sure the key is something relevant so its easy to lookup.

2 Likes