Add Code Actions

New to setting up Transposit? Learn how to get started.

Code actions let you transform the output of one action for consumption by the next action.

  1. Start Creating a New Code Action. Select Code action in the Main Workflow drop-down list.

  2. Use AI to Generate a Code Action. Enter a prompt relevant to your needs.

  3. Set Code Action Logic. Finetune the generated logic, optionally in combination with "for each" loops, as shown below. In the scenario below, we'll process each commit retrieved from GitHub via a code action.

  4. Code the Action. Receive the input, transform it, and provide the output. By default, the code looks as follows.

    As an example, assume you'd like to process GitHub commit messages. Replace all of the above with the below.

def execute(inputs):
  
    input_param = inputs.get("input_param")

    if 'Merge pull request' in input_param:
  
       input_param = input_param.replace("Merge pull request", "-->") 

       return {

         "output_param": f"{input_param}" 

       }  

    return {
      
      "output_param": f"{input_param}",

    }  

The above code action processes and replaces all commits with "Merge pull request" in the title with an arrow, as shown below.

See https://www.transposit.com/docs/references/python-operations for sample code and reference materials.

Alternatively, use JavaScript instead.

See https://www.transposit.com/docs/references/js-operations for sample code and reference materials.

  1. Define the Input. In the Settings panel, set the input parameter that the code action will process. In the below, the current item within a "for each" loop is used as input.

  2. Use the Output. The code action transforms the input and produces output. A Post Message is a typical action to use after the code action to display the output, as shown below. Click the Data button next to the message input and browse to the code action's parameter, as shown below.

    Notice that you now have a dynamic parameter, as shown below, which will be filled in at runtime.

  3. View the Result. When you test or run the automation, your code action transforms the output as defined.

Next Steps