How to combine/aggregate results from many modules in one json and webhook result

Hi!
I have the below scenario:

at the beginning I have input data structure:

{
    "hubspot": {
        "deal_name": "MarioTEST3",
		"contact_firstName": "Mario",
		"contact_lastName": "Boss",
		"contact_email": "xyz@gmail.com",
		"company_name": "Philips"
    },
    "google_calendar": {
        "summary": "title",
        "start": {
            "dateTime": "",
            "timeZone": "Europe/Warsaw"
        },
        "end": {
            "dateTime": "",
            "timeZone": "Europe/Warsaw"
        }
    },
    "chatgpt": {
        "model": "gpt-3.5-turbo-16k",
        "messages": [
            {
                "role": "user",
                "content": "What is the weather today?"
            }
        ]
    }
}

then we have a router module that based on data structure decides which modules should be used

as you can see I have 8 webhook responses
each webhook returns the same data structure:

{
"chatgpt":{
"response":null,
"statusCode":-1
},
"hubspot":{
"dealId":"32490311555",
"dealLink":"https://app.hubspot.com/contacts/0000/deal/32490311555",
"statusCode":200
},
"google_calendar":{
"eventId":null,
"eventLink":null,
"statusCode":-1
}
}

I am wondering how I can improve my scenario to make it more flexible for connecting additional modules.
Maybe there is a way how to return data from many router paths into on JSON module having only one webhook response? It will simplify a lot my future development of this scenario.

Any ideas?

Best,
Mario

Hi @WiseOn, I have this kind of scenario and I use ‘set multiple variables’ modules in the end of each branch (instead of webhook response) and in the final branch I use ‘get multiple variables’ module just before the final webhook response. additional operation for ‘get’, but it’s much better for organisation.

Many thanks @kudracha for your prompt reply!
I am trying to implement your idea but without success.
Can you share your scenario screenshot or something?
My simplified scenario only for 2 use cases looks as below


What am I doing wrong?

@WiseOn, I commented your scenario. This should clear things up.

My example :

In this scenario I’m going through all branches and declaring status and some other variables for each iteration (see set multiple variables modules). In the last branch I’m getting calling back the same variables and then aggregating it into a text. In the end I want to have a result of a table (something like that) :

ID - - - action to be done - - - - mail associated
id1 stop mail1
id2 ok pass mail2

etc. and I’m sending it all to only 1 webhook. I don’t know how you use webhook responses, but for me only the first webhook actually works because the second third etc. won’t actually do anything, assuming that HTTP tunnel will close. Your post request is waiting for a response and when it gets it, the script is over (my scenario works with HTTP POST from apps script).

Don’t hesitate to mention me if you have questions, so I get a notification.

1 Like

Ha!
It works!
Thanks a million @kudracha !!