Skip to main content
Run Code
Olivia Garrahan avatar
Written by Olivia Garrahan
Updated today

How to set up and use Run Code action

Run custom JavaScript code to perform complex tasks. Follow these steps:

  1. Add a Run Code action: While editing a workflow, click the plus button between existing blocks. This will open a modal where you can select from Cassidy's pre-configured actions. Choose the Run Code action to add it to your workflow.

  2. Rename the action (optional): If you want to make the action more descriptive or easier to reference as a variable later, enter a new name.

  3. Enter custom "JavaScript Code": In the code editor, write your custom code. You can reference variables from previous steps or the trigger using variables. *Variables are inputs from the trigger, or outputs from previous steps.

    *Note: The code is executed in a secure, sandboxed environment. You can use built-in JavaScript functions and objects, but you cannot access external libraries or make network requests.

  4. Use AI to write custom code (optional): Click on the "Generate with AI" button above the code editor:

    Then, enter the prompt for what you want the code to do in the prompt text box. If you need to insert a variable, press "#" to reference a variable. In the below example, "emails" is an input to the workflow that contains a string list of emails:

    Then, click the "Generate" button to generate the code. From the above prompt, clicking "Generate" resulted in this code:

  5. Configure output keys (optional): The return value of your JavaScript code will be the output of the action. Specify the keys of the object returned by your code to access the values in later actions.

  6. Run the workflow: You can run the workflow (in this case you can see the input is 3 emails separated by a comma):

    Here is a sample of the output when using "Run Code" to filter out personal emails:

Did this answer your question?