In this guide
Connect a portal, test a small action, then verify its result in a dedicated workflow.
1. Connect a portal
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 only for automation (to run the workflow action and report results) and oauth. It doesn’t request access to your CRM records. If your code needs HubSpot data, give it its own private app or service key as a Turbyn secret.
Access and refresh tokens are encrypted before storage and refreshed server-side. They’re never sent to the browser.
Note
You need a HubSpot account with access to the workflow type and downstream actions you intend to use. Turbyn does not require a Data Hub upgrade just to run its connected-app code action, but it does not unlock HubSpot workflow access.
2. Create an action
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.
Start with a handler that makes no external requests and writes no records:
exports.main = async (event) => {
const email = event.inputs.email;
if (typeof email !== "string") throw new Error("email must be a string");
return { text: email.trim() };
};
3. Test it
- In the Test payload pane, choose Synthetic input or Custom JSON.
- Supply a complete test event, for example
{ "inputs": { "email": " alex@example.com " } }. - Press Test run.
Editors and admins receive a dry run, where ctx.store writes are captured instead of applied. Members receive a preview, without secrets or store access. External requests made by your code are real in either mode, so guard production side effects with if (ctx.mode === "live"). See What a test run touches.
The expected returned value is { "text": "alex@example.com" }. Inspect the result before publishing. A successful execution with no returned value can still leave the next step without usable data. This example trims whitespace; it does not validate an email address.
4. Publish
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.
5. Add it to a workflow
In HubSpot, open a workflow and add an action. Under the Turbyn section, choose Custom Code.
- Saved action. A searchable dropdown of your published actions.
- Inputs (JSON). A JSON object. Insert data tokens as string values, e.g.
{ "email":then the Email token}. Your code readsevent.inputs.email.
The action works on any object type: contacts, companies, deals, tickets and custom objects.
The handler’s return value is HubSpot’s outputs JSON, plus typed Action outputs (Text, Number, Boolean, Options, Date, Date and time, Phone) for Edit record.
6. Turn it on and watch
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.