Code actions let you transform the output of one action for consumption by the next action.
Start Creating a New Code Action. Select Code action in the Main Workflow drop-down list.
Use AI to Generate a Code Action. Enter a prompt relevant to your needs.
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.
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.
input_param = inputs.get("input_param")
if 'Merge pull request' in input_param:
input_param = input_param.replace("Merge pull request", "-->")
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.
See https://www.transposit.com/docs/references/js-operations for sample code and reference materials.
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.
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.
View the Result. When you test or run the automation, your code action transforms the output as defined.