Code

Description

Author and run custom code

Component key: code

Actions

Custom Code

Author custom code

Action key: runCode

Inputs

KeyTypeDefaultRequiredComments
codeCODEmodule.exports = async (context, params) => {
return;
};
TrueThe code to be executed

This example takes the output from the HTTP GET example as input for a runCode step.

# Create a custom code block that takes an output named "todoItemId" from a
# previous action, and generates an output URL for the "To Do" item.
CODE_ACTION_ID=$(prism components:actions:list --filter 'key=runCode' --columns id --no-header)
CODE='module.exports = async (context, inputs) => \\n `https://jsonplaceholder.typicode.com/todos/${inputs.httpget.todoItemId}`;'
INPUTS='[
{
"name": "code",
"expression": "'"'${CODE}'"'"
}
]'
OUTPUTS='[
{
"name": "todoURL",
"expression": "*"
}
]'
prism integrations:steps:add ${CODE_ACTION_ID} \
--integration ${INTEGRATION_ID} \
--inputs ${INPUTS} \
--outputs ${OUTPUTS}
Last updated on