Why this automation is needed
Native HubSpot workflows often struggle with complex multi-object traversals, conditional lookback attribution windows, custom phone format standardizations, and custom scoring calculations.
With Workflood, this recipe runs in a secure gVisor container sandbox with pre-authenticated HubSpot SDK injection, avoiding HubSpot Data Hub execution limits, memory bottlenecks, and per-seat fees.
Action Source Code (TypeScript)
export default async function main(input: {
[key: string]: unknown
}): Promise<{ synced: number; errors: string[] }> {
// Fetch data from external API
const response = await http.get('https://api.example.com/data', {
auth: secret('EXTERNAL_API_KEY'),
})
const records = response.data as { id: string; score: number }[]
const errors: string[] = []
let synced = 0
for (const record of records) {
try {
// Find matching HubSpot contact by external ID
const contacts = await hubspot.client.crm.contacts.basicApi.getPage(
1, 0, ['hs_object_id'], undefined, undefined,
[{ value: record.id, propertyName: 'external_id', operator: 'EQ' }]
)
if (contacts.results.length > 0) {
await hubspot.client.crm.contacts.basicApi.update(
contacts.results[0].id,
{ properties: { lead_score: record.score.toString() } }
)
synced++
}
} catch (err) {
errors.push(`Failed to sync ${record.id}: ${err}`)
}
}
return { synced, errors }
}
How to deploy in Workflood
Connect your HubSpot Portal
Add your HubSpot Private App token once. Workflood securely encrypts it via libsodium XChaCha20 and injects pre-authenticated SDK clients.
Create Action from Template
Select this recipe in Workflood. Edit variables, customize logic in Monaco editor, or execute dry runs with sample JSON payloads.
Trigger via Webhook or Cron
Trigger from standard HubSpot workflows via Webhook action, or schedule recurring batch syncs with cron expressions and timezone handling.
