Duplicate/copy "Trigger webhook" with multiple parameters

Hi all,
Following the good advice from @Darren_Murphy , I’m always using custom actions. The problem is that the action/flow builder seems to be heavily under-developed. One feature that is frustratingly missing is the ability to copy/paste between custom flows.
In particular, would be great to copy action with many variables, such as set values in a large table/sheet. But, as the title suggests, I’m actually asking for help with the “Trigger webhook” action. Many of my webhook are loaded with many parameters. Setting them up every time seems like a hassle, not the mention a huge window for mistakes (by me :stuck_out_tongue: ).
I’ve been looking around for an easy way to manage these parameter-heavy actions. In this post, I found this after-the-fact comment from (again) @Darren_Murphy

using a template column to concatenate multiple parameters, and then unwind them at the other end.

Has anyone played with this option?
In addition to calling them from Glide, I’m also calling Integromat webhooks from within other scenarios in Integromat. This means I must keep the incoming parameters very organized. I noticed that Glide is sending the parameters under “params”, as below:
image

To make sure I’m always sending the correct structure for the webhook parameters, I’m sending it as a raw JSON when triggered from another scenario.

After this long (and boring?) explanation, assuming you have read the entire thing, any ideas how to tackle this?
I’d love to implement the elegant solution of a template column and sending just that template as a parameter to the webhook. I’m not sure how to unwind it inside Integromat. I assume it’s by using the replace module, but how do we split it back into multiple (many) parameters that we can later use in other modules on the same flow?
BTW - once I figure out how to send a single parameters from Glide, I’ll want to do the same for HTTP requests from other scenarios from Integromat. This means, again, the receiving scenario should be able to “unpack” this “all-in-one” parameters regardless of where they came from.
Thanks

You can use something like GET(SPLIT(template;delimiter);1) with 1 being the index of the thing you want to extract. Indexing starts from 1.

However it gets ugly if you have a lot of things in that template, to make sure the index is not off.

That comment was made quite some time ago - almost a year ago.
That’s not what I’d do now. What I would do now - and in fact what I did just recently - is use JSON. That is:

  • Construct a JSON object in Glide using templates and joined lists

  • Send that JSON object through a webhook as a single parameter

  • Use the parse JSON module, plus an iterator (if necessary) on the Integromat side to process it.

2 Likes

This is a much better way to do it!

1 Like

This indeed looks much more elegant.
Would you be able (and willing) to share some more explanations about each of these three steps? such as. how you constructed the JSON, how to parse it and what happens after the iterator?
Thanks!

Yes, but every use case is different of course. So what I did may not be directly applicable to your situation. But I can provide some general advice which you might be able to take and adapt.

The first thing to do is to define your JSON structure. The best way to do that is to open your favourite text editor and start typing :wink:

In my case, I needed to send a bunch of rows of data, so I used a very similar technique that I use for generating a HTML table, or a CSV export.

My JSON structure looked like this:

{
	"timesheets": [{jl}]
}

The {jl} part of the above is an arbitrary collection (a Joined List) of rows. The template for each row of data looked like this:

{
	"key": "{key}",
	"user-code": "{user-code}",
	"user-name": "{user-name}",
	"user-role": "{user-role}",
	"date": "{date}",
	"year": "{year}",
	"hours": "{hours}",
	"project-number": "{project-number}",
	"project-name": "{project-name}",
	"stage": "{stage}",
	"stage-name": "{stage-name}",
	"notes": "{notes}",
	"pretty-date": "{pretty-date}",
	"consultant-id": "{consultant-id}",
	"project-id": "{project-id}",
	"stage-id": "{stage-id}",
	"created-by": "{created-by}"
}

So the above went into a template column, and each of the {xxx} items was used as a replacement value. And then all the rows get combined via a joined list, with the end result being the screen shot that I shared earlier. And that’s what gets sent via the webhook.

The Parse JSON module will take just a single value, which is the JSON object that’s sent via the webhook:

You need to define a Data Structure that will instruct the module how to handle the JSON. The easiest way to do that is to use the Generator. Just copy/paste your JSON structure in, let the generator do its work, and then tweak it afterwards.

That’s really irrelevant here, as it’s specific to my use case. The important thing is that once you have successfully parsed the incoming JSON object, you can then access the data within and use it as you need to in subsequent modules.

2 Likes

Thanks Darren!
I’m too lazy, and too prone to making typos, so I’ve used this online Excel => JSON converter.


Update:
This converter is actually easier to use and understand.

End update


Here’s an example of the XLS I used.

Output is as follows:

[
 {
  "FirstName": 10,
  "LastName": 11,
  "Phone number": 12
 }
]

Hope this will help someone out there. I have not been able to figure out how to add the “params” on top, to match the output from Glide.

If you’re sending it via a webhook from Glide, you don’t need to worry about that. Glide does it for you. Here is what my incoming webhook looks like when it arrives on the Integromat side:

If you go back to my earlier screen shot, you can see that I sent a single parameter called data:

So Integromat sees that as params->data, where data has a type and a value. The value contains the JSON payload.

Thanks man, you rock :metal:

Just realized I didn’t close a full circle here.
I’m not always sending the webhook from Glide. I sometimes send in from Intergromal to Integromat. I’m not able to send the JSON string as a string inside another JSON. Here’s my setup:

JSON4WebHook is column name I use in Glide so replicating it here.

Here’s the content of 21. Text:

This string (21. Text) is built exactly the same as the one I’m sending from Glide.
When I try to run this, I get the following error:

I suspect this is due to the first character {, inside 21. Text.
Do I need to escape something? Perhaps have another step before pouring 21. Text into the HTTP request?
Thanks!

My guess would be that your problem is here:

  • Firstly, I don’t think that escapeHTML is required if it’s already valid JSON
  • Secondly, those double-quotes around 21. Text shouldn’t be necessary.

Yeah, I thought so to and tried it. If I remove both Integromat is taking it a step too far and already praseing the JSON which is nested inside the JSON

If I am to mimic Glide, I need it to come as a string inside “value”. Like this one that came from Glide:
image

I think we do this json inside a json @mubeeniftikhar and @wajeeha . We have individual rows in a table, then we make a joined list, and send a json made of jsons. We then use integromat to get this combined single value, then split it, then iterate the results to do our magical things.

Hi Mark
I’m not sure I fully understand your method. However, I think I’m not trying something very similar. What I do is add a “create JSON” module after the “Compose string” module (21. txt).

I than send the output of this module in the body of the HTTP request.

This seems to do the trick but I’d be happy if you could review.
PS - In my previous posts I forgot to add the “AppID” parameter. I now added it to fully mimic the Glide “trigger webhook” action. I’m using this AppID to filter a data store, based on another great advice from @Darren_Murphy .

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.