Nightly sync of HubSpot list to Meta Ads Custom Audience

By General Input

Every night at 2am, rebuild a Meta Ads Custom Audience from a HubSpot list so retargeting always matches your current CRM segment.

Integrations

  • HubSpot
  • Meta Ads
  • Slack Bot

Type

Deterministic Code

Categories

  • Marketing

Build a code workflow that runs every night at 2am and keeps a Meta Ads Custom Audience in sync with a HubSpot contact list, so retargeting always reflects the current CRM segment. This is a deterministic pipeline, not a decision agent.

Trigger: cron, daily at 02:00 in the workspace's default timezone.

Inputs (so this same workflow can be reused for multiple segments like churn risk, high LTV, product A buyers):

1) HubSpot list identifier (the named list or filter to pull from).

2) Meta Ads Custom Audience id (a pre-created customer list audience).

3) Slack channel id for the summary message.

Steps:

1. Use HubSpot Search Contacts to pull every contact that matches the given list or filter. Paginate all the way through until the full membership is loaded. Request email, phone, first name, last name, city, state, country, and zip so Meta has plenty of match fields.

2. Format each contact into the user record shape Meta's Custom Audience upload expects. Normalize email (trim and lowercase) and phone (digits only, keep country code) so the platform's hashing produces stable matches. Skip contacts with no email and no phone.

3. Call the Meta Ads Replace Users in Custom Audience operation against the given audience id. This swaps the entire membership in a single session, so adds and removals both take effect atomically. Handle Meta rate limit responses with retry-and-backoff, and fail loudly on non-retryable errors.

4. Send a Slack Bot Send a Message to the configured channel with a short summary: HubSpot list name, Meta audience id, records pulled from HubSpot, records sent to Meta, session id, records Meta accepted for matching, and any error codes returned. Keep it terse enough to be readable in a channel.

Error handling: strict. If HubSpot pagination fails, abort before touching Meta so we never send a partial list. If Meta rejects the session, post the failure to Slack with the error payload so someone can act on it in the morning.

Related prompts

Explore more prompts
A brand asset library your marketing team actually searchesTurn Mailjet email clicks into ranked HubSpot follow-upsClean out the Looker dashboards and Looks nobody opensLiveKit live operations console for room moderationWake up dormant Keap leads with a researched reasoniMessage campaign console with pre-flight checks and delivery boardLiveChat coverage board for planning next week's shiftsPhone routing control panel for LiveKit voice agentsA searchable RFP answer library your bid team drafts fromLinkedIn Ads budget pacing dashboard for every client account