Execute Script


NOTE: This action is not enabled by default. We only enable this action on request basis based on the discretion of the product team. If you need to access this action, please send us a note through chat.

This action enables you to write and execute custom code as part of your workflow automation. You may want to write code to execute your custom logic, ex. proprietary internal calculation, or to extend zenphi's out of the box functionalities.

You can write your code in plain Javascript or Typescript.

You can pass in dynamic parameters which you may get or calculate as part of the workflow execution, to this action and use their values in your logic.

Specify input parameters

You can specify one or input parameters for your script. Use the bottom section of the action configuration to manage input parameters.

For each parameter, you need to specify its name and its value. The name cannot contain white spaces. The value can be a hard coded static value, or a dynamic value picked from the token picker (a trigger value, previous action output, a flow variable, or a vault item value).

Writing Code

You can use the code editor to write Javascript or TypeScript code. The editor has a good support for suggesting and auto-completing the code.

Available Libraries

The below libraries are available to be used in your script:

  • date-fns version 2.23.0

import { format, formatDistance, formatRelative, subDays } from 'date-fns';

  • node-fetch version 2.6.1

import fetch from 'node-fetch';

Return Result

You can return one or more values as part of the script execution. The values you return here will be part of the action's output.

Return a single value:

You can return a value of simple type (ex. string, int, etc.) using the export command

ex: export const unixTimestamp = createdDateInUnixTimestamp.

You can also return a complex object.


export const person = {

firstName: "John",

lastName: "Doe",

birthdayTimestap: result


How to return more values:

You can use the export command multiple times in your script. Each time you export a value, it becomes a new property of the action output.

Specifying Output Schema

You can use the Export Schema property of the action to configure its output schema. You can manually specify the schema or use a sample output json of the action to infer the schema. You can get a sample output by doing a test run and printing the output json using console.log in the script. You can then copy paste the sample schema into the action configuration and press on the Infer from sample button to automatically infer the schema.

Useful Tips

  • The editor fully supports the typescript's async await functions
  • You can use the console.log() function in the script to log information into the flow run's history.