Using Python with Integromat
Ever wanted to write a Python script that can be used with your Integromat scenario?
It’s actually easier than I expected, using Google Cloud Functions.
Here’s a super simple way to re-implement the built in
replace(string;old;new)function using Python.
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 Python, especially if you are already fluent in it.
- 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.
- Fill in the name, select 128 MB memory, and set the runtime to Python:
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-1 to 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 “string”, “old”, and “new”. 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.