Use JavaScript code
JavaScript Code Steps let workflows run small pieces of JavaScript code. These steps give you the flexibility to add custom logic to your workflows.
This tutorial will show you how to use JavaScript code steps.
You can use JavaScript Code Steps as actions in your workflows to perform tasks like data manipulation, calculations, or interacting with external services.
What is a JS Code Step?
A JS Code Step is a specific type of action in a workflow where you can run custom JavaScript code. This is particularly useful when you need to:
• Perform calculations or transformations
• Handle complex logic that cannot be achieved with basic built-in actions
• Interact with external APIs and process the response data
• Manipulate or filter input data based on specific conditions.
Adding a JS Code Step to Your Workflow
1. Add a JS code action
The JS Code action step allows you to write code that will interact with data coming from the trigger, or a previous action step.
• In the workflow editor, click on the action step
• Search for and select JS Code from built in tools
2. Set up your JS code action
• In the Code field, enter your JavaScript code.

• You can also define data fields to be provided to the code as strings with the Input Data fields. Provide a key and a value for each field.
• Click Continue.
3. Test your code action
• Click Test step.
• If your code is valid, the step will show it was successful and display the data sent.
Using AI to Help You Generate JavaScript Code for Your Workflow
You can use AI to generate JavaScript code for your workflow. Simply describe what you’d like the code to do, and AI will generate it for you.
• In the action step, above the Code field, click Ask AI.

• In the dialog box, enter a clear prompt describing the desired code.
• Click Generate Code.
• Review the generated code.
• Click Test Step.
• Review the test results.
How to Write Your Prompt
• Use plain language in your prompt.
• Avoid technical jargon. There's no need for advanced language or programming terms.
• Be clear and concise, avoiding ambiguity in your request.
• You can manually edit the AI-generated code at any time.
Using Input Data in Your JS Code Step
For action steps, you can reference:
• Input data from your JS Code step.
• Data from previous steps to pass as input to your JS Code step.
Example
Here are some example prompts:
• Split the full name input into first and last.
• Get the current date and time and return it in the format: YYYY-MM-DD HH:MM:SS as an object.
• Check if the value provided is prime.
• Convert the input string into uppercase letters
• Extract the domain name from the provided URL
Testing and debugging JS Code steps
You can use the Workflow History to review detailed logs and data after running the workflow, while the Test Step lets you check the behavior of the JS Code step immediately during development for faster troubleshooting and adjustments.