Hi all,
I’m currently building automated workflows using the HubSpot Workflows API. I’m trying to replicate the same logic I see in the HubSpot UI, where we can define parallel branches based on filters like contact job titles (e.g., CEO, CISO, COO), and assign different email sequences to each branch.
In the HubSpot UI, I can create a branching step that evaluates multiple conditions in parallel, like:
- If job title is CEO → send Email A
- If job title is CISO → send Email B
- If job title is COO → send Email C
- Else → end workflow or do fallback action
I want to create the same kind of clean, flat branching structure using the API.
Work done:
- Workflow enrolls contacts based on list membership (via segmentCriteria).
- For each contact, I’m checking their job title (e.g., CEO, CISO, VP, etc.) and sending them a tailored email sequence.
- My current implementation builds branching logic using BRANCH actions, with one condition per branch and the next condition linked via rejectActions.
This creates a deeply nested structure that works correctly, but it doesn’t reflect the UI-style layout we want: where conditions appear as parallel branches checked in order (like “If title is CEO → do this, else if title is CISO → do that, else if VP → another,” etc.).
Here is my code:
for (const company of companies) {
const companyName = company[“company name”];
const listId = company[“listId”];
const people = company[“person”];
const workflow = {
name: `[Agentic AI] ${companyName} Workflow`,
type: “DRIP_DELAY”,
enabled: false,
onlyEnrollsManually: true,
segmentCriteria: [
[
{
filterFamily: “ListMembership”,
operator: “IN_LIST”,
list: listId,
withinTimeMode: “PAST”
}
]
],
actions: []
};
let branchActionId = 1;
let actionId = 100;
let lastRejectBranch = null;
for (let i = people.length – 1; i >= 0; i–) {
const person = people[i];
const branch = {
type: “BRANCH”,
actionId: branchActionId++,
filters: [
[
{
property: “jobtitle”,
operator: “EQ”,
value: person.jobtitle,
type: “string”,
filterFamily: “PropertyValue”
}
]
],
acceptActions: [
{
type: “EMAIL”,
emailContentId: person.email_id,
actionId: actionId++,
stepId: 1,
goalListCount: 0
},
{
type: “DELAY”,
actionId: actionId++,
delayMillis: 3 * 24 * 60 * 60 * 1000 // 3 days
},
{
type: “EMAIL”,
emailContentId: person.email_follow_up_id,
actionId: actionId++,
stepId: 2,
goalListCount: 0
}
],
rejectActions: lastRejectBranch ? [lastRejectBranch] : []
};
lastRejectBranch = branch;
}
if (lastRejectBranch) {
workflow.actions.push(lastRejectBranch);
}
await tools.HubSpot_Workflow(workflow);
}
What I’m trying to achieve:
I want to create workflows via the API that result in a flat, UI-equivalent structure:
- One branching step – single BRANCH action with multiple filters and set them in order.
- Multiple conditions based on (job titles)
- One path executed per title
- A clean fallback “None met” action (like ending the workflow)
Is there a recommended way to implement “parallel” conditional branches (as seen in UI) using the API without chaining deeply nested rejectActions?