Skip to content

Quickstart

From nothing to a running workflow step. Around ten minutes.

Sign in, then Portals → Connect portal. You’ll be sent to HubSpot to authorise the app and returned when it’s done.

The app asks for automation (to register the workflow action) plus read and write scopes on the CRM objects you want your code to touch. Grant only what you need. You can reconnect later with wider scopes.

Access and refresh tokens are encrypted before storage and refreshed server-side. They’re never sent to the browser.

Actions → New action, pick JavaScript or Python, and give it a name. The name is what you’ll see in HubSpot’s dropdown, so make it descriptive: enrich-company beats action-2.

You get a working handler to start from:

exports.main = async (event, ctx) => {
const email = event.inputFields.email;
ctx.log.info("processing", { email });
return {
outputFields: {
output1: (email ?? "").trim().toLowerCase(),
},
};
};

This is the part worth not skipping.

  1. In the Test payload pane, choose From a record and search your portal.
  2. Map the properties your code reads onto field1field5.
  3. Press Test run.

The event is built from that record’s actual data, and the run is a dry run by default: calls that would write to HubSpot are intercepted and reported as “would write X to Y” rather than executed. Turn off dry-run explicitly when you want a write to land.

Read the console and the returned outputFields. If outputFields comes back empty, the action will “succeed” in HubSpot and hand nothing to the next step. The single most common failure with HubSpot custom code, so it’s flagged loudly here.

Publish snapshots an immutable version and pins its dependency tree. Only published versions can be selected in HubSpot; your draft stays private until you publish it.

Editing later creates a new draft. The published version keeps running until you publish again, so you can’t break a live workflow by typing in the editor.

In HubSpot, open a workflow and add an action. Under the Turbyn section, choose Run Code.

  1. Saved action. A searchable dropdown of your published actions.
  2. Field 1–5. Map a CRM property, an earlier action’s output, or type a static value. These arrive as event.inputFields.field1 and so on.
  3. Payload (JSON). Optional structured input for anything that doesn’t fit a single property.

Outputs (output1output5, json, errorCode, errorMessage) are then available to later steps. Copy them into properties, or branch on them.

Turn on the workflow and enroll a record. In Turbyn, Runs shows the execution live: status, console output as it streams, timing, and the input and output payloads.

If it fails, the run detail has the stack trace, and HubSpot’s workflow history shows a readable message driven by the error code.