Skip to content

Use custom code actions in workflows

Last updated: May 7, 2021

Applies to:

Operations Hub  Professional

In workflows, you can use the Custom code action to write and execute JavaScript in your workflow. With custom code actions, you can extend workflow functionality within and outside of HubSpot.

Custom code actions support JavaScript using the Node 12.x runtime framework. When the action executes, the runtime compute is managed through a serverless function by HubSpot and AWS Lambda

For more technical information about building custom code actions, view HubSpot's developer documentation.

Please note: custom code actions must finish running within 20 seconds, and can only use up to 128 MB of memory. Breaking these limits will result in an error.

To add a custom code action to your workflow:

  • In your HubSpot account, navigate to Automation > Workflows.
  • Click the name of a workflow, or create a new workflow
  • Click the plus icon + to add a workflow action.
  • In the right panel, select Custom code

  • To use a secret in your custom code, click the Secrets dropdown menu, then select an existing secret, or add a new secret:
    • To add a new secret, such as an API key, click Add secret. Learn more about secrets in HubSpot's developer documentation.
    • In the dialog box, enter the Secret name and Secret value.
    • Click Save. You can now select this secret in future custom code actions.
    • To edit or delete existing secrets, click Manage secrets.

  • In the code field, enter your JavaScript. To learn more about coding your action, check out HubSpot's developer documentation.
  • To define data outputs that can be used as inputs later in the workflow:
    • Under Data outputs, click the Data type dropdown menu, and select a type of data.
    • In the Name field, enter a name for the data output.
    • To add multiple outputs, click Add output.
  • Click Save.

Supported libraries

The Custom code action supports the following JavaScript libraries and versions: