Built-in apps
Make Code
9 min
{{product name}} code is currently in open beta it is available to all customers on paid plans as a beta feature, both product functionality and pricing may change {{product name}} code is a built in app that allows you to add arbitrary javascript or python code to your {{scenario singular lowercase}} with the {{product name}} code app, you can write code within the module with the help of an ide that offers familiar features such as common syntax, auto completion, and error highlighting, or you can add code dynamically from previous modules in your scenario a fully isolated sandbox environment, as well as access to standard output and error logs, helps you safely test your code, reducing or eliminating the need for third party tools additionally, the app has built in javascript and python libraries, and with an enterprise account you can import custom libraries as well the code created in your {{product name}} code app module is included in downloaded {{scenario singular lowercase}} blueprints, making it easier to share and collaborate key benefits supports javascript and python built in ide experience with common syntax, auto completion, and error highlighting fully isolated sandbox environment to test your code and ensure safe execution access to data outputs and error logs, to help you troubleshoot code executions effectively ability to share code in a {{scenario singular lowercase}} blueprint features features core pro teams enterprise standard javascript and python libraries javascript moment, moment timezone, lodash python pendulum, toolz, requests x x x x ability to import custom libraries x sandbox environment with 1 cpu 512 mb ram 30 second maximum execution time x x x sandbox environment with 2 cpus 1024 mb ram 300 second maximum execution time x credit usage the {{product name}} code app consumes two credits for every one second of code execution time you can see the code execution time in the module output the billed code execution time does not include backend processing time, so your billed output time will be shorter than the actual time it takes to process the majority of use cases will execute in less than one second details regarding dynamic credit usage can be found in the credits docid 8wwqsq xru5k6euedboao article {{product name}} code module actions run code design and run a code snippet field description language select javascript or python input format select code editor or mapped code (useful for ai) code enter the code to be executed, or map dynamic code from previous modules or inputs input provide values from your {{scenario singular lowercase}} that can be used within the code they will be available nested under the input object additional dependencies (enteprise plans only) add dependencies dependencies are installed before executing the code they are not shared between multiple code modules our support team can't provide support in troubleshooting your javascript or python code our support team can't provide help in troubleshooting your javascript or python code examples calculate the number of days between two dates in this example, we will use javascript to calculate the number of days between two dates the example contains error handling code to ensure that the entered date is valid and that the start date is not after the end date in your {{scenario singular lowercase}} , add a make code > run code module in the language field, select javascript in the input format field, select code editor you can also select mapped code to use code generated in a previous module in your {{scenario singular lowercase}} in the code field, enter the following javascript code the code identifies the name of the variables for input, calculates the result daysdifference , and includes examples of both console error and throw error messages if an entered date is invalid or if the start date is after the end date if you include the throw error in your code ( lines 18 and 29 ), the {{scenario singular lowercase}} will fail with that error and you can use an error handler if you include the console error in your code ( lines 25 and 29 ), the error will be part of your output bundle // retrieve input variables from the scenario const { start date, end date } = input; // logging to the console console log("received a request with the following date start=" + start date + ", end=" + end date); // create date objects from the inputs to ensure they are valid dates const start = new date(start date); const end = new date(end date); if (isnan(start gettime()) || isnan(end gettime())) { // logging error console error("there was an error, one of the dates was not valid"); // note if you combine console error and "throw new error", the error message will not // be displayed, because the output bundle will not be generated by the module throw new error("invalid date format provided please use date objects or 'yyyy mm dd' strings "); } // ensure the start date is not after the end date if (start > end) { // logging error console error("there was an error, the start date is after the end date"); // note if you combine console error and "throw new error", the error message will not // be displayed, because the output bundle will not be generated by the module throw new error("the start date cannot be after the end date "); } // calculate the difference in milliseconds const timedifference = end gettime() start gettime(); // convert milliseconds to days and return the result const daysdifference = math floor(timedifference / (1000 60 60 24)); // check if the result is a valid number before returning if (isnan(daysdifference)) throw new error("calculation resulted in nan "); return daysdifference; variable 1 sets the start date for the name field, enter start date for the value field, map the now value for the current date and time variable 2 sets the end date click +add variable to add a second variable to the module for the name field, enter end date for the value field, use the parsedate function and add your end date and date format click save to save the module settings click the save icon in the toolbar to save your {{scenario singular lowercase}} click run once to test if the end date is after the start date , the output result is the number of days between the two dates, daysdifference if one of the dates is not in the correct format, the throw error will say invalid date format provided please use date objects or 'yyyy mm dd' strings if the end date is before the start date , the throw error will say the start date cannot be after the end date real time api response parser code example const res = await fetch("https //randomuser me/api/"); const data = await res json(); return data; input scheme safely code example zod needs to be installed const { z } = require("zod"); const schema = z object({ email z string() email() }); const input = { // or you can use context to input data from scenario email "email\@email com" } const parsed = schema safeparse(input); if (!parsed success) { throw new error("invalid email format"); } return { valid true }; one time password (otp) generator code example otplib needs to be installed const { authenticator } = require("otplib"); const secret = "kvkfkrcpnzquymlxovydsqkjkzdtsrld"; const token = authenticator generate(secret); return { otp token }; business hours calculator code example luxon needs to be installed const { datetime } = require("luxon"); const input = { // or you can use context to input data from scenario "timestamp" "2025 07 07t15 00 00z", "timezone" "america/new york" } const dt = datetime fromiso(input timestamp, { zone input timezone }); const hour = dt hour; const isopen = hour >= 9 && hour < 17; return { localtime dt toformat("hh\ mm"), isopen };