May 19, 2024

How to Use Custom Code in Make.com

Make.com logo

Make.com is a powerful tool for automation, allowing users to integrate and automate workflows across various services without much coding. However, there are times when out-of-the-box modules might not suffice, and you need to insert custom code to perform specific tasks. Here's how to insert and use custom code in your Make.com scenarios.

Step 1: Identify the Requirement for Custom Code

Before diving into writing custom code, you must determine if your automation scenario cannot be fulfilled with the existing modules. Custom codes are generally required to perform complex data transformations or when there's a need to interact with an API that is not directly supported by Make.com.

Step 2: Select the Proper Module for Custom Code

Once you've identified the need for custom code, you'll need to choose the correct module to run it. Make.com offers the ‘HTTP’ module for custom API calls and the ‘Tools’ module, which includes a ‘Code’ component for executing scripts.

Step 3: Writing Your Custom Code

  • In the 'Tools' module, drag the 'Code' component onto your scenario.
  • Within this component, select the programming language you'll use. Make.com currently supports Node.js which will cover a great range of possibilities.
  • Write your code in the provided space. Remember to handle input data from previous modules and generate output data that can be passed along to subsequent modules in your automation chain.

Use Case Example: If you want to transform date formats that are not natively supported by Make.com, you could write a Node.js script that takes the original date as input and outputs the date in the required format.

Step 4: Input and Output Data

  • Your custom code will need input data to manipulate. You can add inputs by dragging items from previous modules or by hardcoding data into your code.
  • After processing the input, ensure your code returns an object. This object's properties will be the output data accessible to other modules in your scenario.

Step 5: Testing Your Code

After writing your code, make sure to test it by clicking the ‘Run once’ button on the scenario editor page. This step is crucial to confirm that your code interacts correctly with the input data and that the desired output is generated.

Step 6: Debugging

If the code doesn’t work as expected, use the output log provided by the ‘Code’ module to debug. The log will display error messages that can help you identify and fix issues in your code.

Step 7: Integrating Your Code into the Workflow

After successful testing and debugging, integrate your custom code into your Make.com scenario. Connect the input and output with other modules to ensure a smooth data flow through your entire automation pipeline.

By following these steps, you can effectively utilize custom code to extend the capabilities of Make.com, allowing you to create more personalized and powerful automation solutions. Remember to regularly review your custom code to ensure it stays up to date with any changes in your integrated services.