Using JavaScript with Integromat

John Thomson
Jan 8, 2019 · 3 min read

Integromat is awesome, but sometimes it’s easier to write a few lines of JavaScript to put into your scenario.

It’s actually quite easy to do, using Google Cloud Functions.

Here’s a super simple way to re-implement the built in replace(string;old;new) function using JavaScript.

Built In Function

This is the sensible way to do this, using the built in Integromat function:


The built in functions are actually quite powerful, but they certainly have limits. There are some things that would be much easier to implement in JavaScript, especially if you are already fluent in it. Unfortunately I’m not particularly fluent, which is why I made the Python version of this article first.


1.. Create a new Google Cloud Function by clicking here. You might have to create a Google Cloud account if you don’t already have one. The usage in this example is within the free tier.

2.. Fill in the name, select 128 MB memory, and leave the runtime as Node.js 6:

Image for post

3.. Next, add the code, which can be found at this gist, and set the function to match the function named within the code. Also, set the region to europe-west-1to be closer to the Integromat servers, resulting in a faster load time.


4.. Find the Trigger URL for this function by clicking on it and clicking “Trigger”. You’ll need to copy this for use later.


5.. Now go back to Integromat and create a new HTTP “Make a request” module. Set it up with the URL as the trigger from step 4, with the GET variables for “old_string”, “text_to_find”, and “text_to_replace”. The output should be the string, but with old replaced by new. This should work the same as the built in function.


You can now use the output of that anywhere else in the scenario!

Basic security can be added with an API Key type structure (with a hardcoded key in the function), otherwise anyone will be able to “call” the function if they know the URL. If I have time I will write more on that later.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store