Integration
TypeScript
Cron Schedule

External Data Sync

Pull data from an external API and upsert into HubSpot custom properties.

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)

data-sync.ts
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

1

Connect your HubSpot Portal

Add your HubSpot Private App token once. Workflood securely encrypts it via libsodium XChaCha20 and injects pre-authenticated SDK clients.

2

Create Action from Template

Select this recipe in Workflood. Edit variables, customize logic in Monaco editor, or execute dry runs with sample JSON payloads.

3

Trigger via Webhook or Cron

Trigger from standard HubSpot workflows via Webhook action, or schedule recurring batch syncs with cron expressions and timezone handling.

Ready to run

Deploy in Workflood

Single Portal is $79/mo flat with unlimited team seats, 50,000 runs/mo, and no per-seat costs.

Node 20 & Python 3.11 runtimes
gVisor micro-container sandbox
60s execution timeout (vs HubSpot 20s)
Two-way GitHub repository sync
Instant rollback & version history