Researched: Sourced and summarized, not yet run end-to-end by us Client onboarding

CSM assignment and AI welcome email on HubSpot closed won (n8n)

Last checked: · Sourced and summarized; not yet run end-to-end by us. What this means

At a glance

Setup estimate
1–2 h (ESTIMATE)
Tools
Industries
SaaS
View source template on n8n.io (opens in new tab)

Problem

The handoff from sales to customer success is slow, and new customers wait for a welcome

Who it's for

A HubSpot closed won handoff for SaaS and service companies with a small customer success team. The trigger: a deal is marked won and then nobody owns the customer for days, so you want the least busy customer success manager (CSM) assigned automatically and a welcome email sent to the buyer's champion straight away.

Skip it if your deals rarely have a contact with HubSpot's Buying Role set to Champion (no one gets an email or an owner then), if you need a human to approve every welcome email, or if CSM workload should depend on account size rather than a simple deal count.

Tools and what each does

HubSpot Trigger
Fires on a deal property change of hs_is_closed_won (needs a HubSpot developer app for webhooks).
Set node ('Configure Template Variables')
Holds your company name, sender name and sender email for the prompt.
n8n Data Table ('csm_assignments') + Code
Lists CSMs (HubSpot owner ID and deal_count) and picks the one with the lowest count; another node is meant to add one to that count.
HubSpot (deals + contacts)
Gets the deal's associated contacts, reads each contact's hs_buying_role and finally sets the champion's contact owner to the chosen CSM.
AI Agent with OpenAI gpt-4o-mini + structured output parser
Writes a welcome email (subject and Markdown body) mentioning the CSM, a getting-started video and help docs.
Markdown + Gmail
Converts the body to HTML and sends it to the champion.

Browse by tool: n8n, HubSpot, OpenAI, Gmail

Steps

  1. Create the csm_assignments Data Table with csm_id and deal_count, one row per CSM.
  2. A deal changes its closed-won property; the IF checks it's now won.
  3. n8n picks the CSM with the lowest deal_count.
  4. It loads the deal's contacts and keeps those whose Buying Role is CHAMPION.
  5. For each champion, the AI writes a welcome email and Gmail sends it.
  6. The champion's contact owner is set to the CSM, and that CSM's count is updated.

Known problems in the source template

Found by reading the template's JSON, not by running it. Likely fails as shipped.

  • Problem: 'Increment CSM Deal Count' has no column values set, so the count likely never changes and the same CSM keeps being picked as 'least busy'.

    Fix: Map deal_count to current_count + 1 from 'Find Least Busy CSM', and match on the row ID.

  • Problem: The won check applies a strict boolean test to HubSpot's propertyValue, which webhooks send as text, and carries a stray 'contact.creation' value. It may reject every event or error.

    Fix: Compare the value as a string equal to 'true'.

  • Problem: The prompt still contains '[Link to Your Video]', '[Link to Your Help Doc]' and '[Your Company Name]', the sender email is [email protected] and both Data Table selections are blank.

    Fix: Put your real links and names in the prompt and variables, and select your table in both Data Table nodes.

Before you start

  • HubSpot with OAuth2 access, plus a HubSpot developer app for the trigger.
  • Buying Role filled in on deal contacts.
  • n8n with Data Tables available, an OpenAI API key and a Gmail account.
  • Your getting-started video and help-doc URLs.
  • Setup estimate: 1–2 h (ESTIMATE).

What can go wrong

Needs n8n Data Tables, a HubSpot developer app credential for the trigger plus OAuth for other steps, and an AI credential such as OpenAI. It assumes you use HubSpot's Buying Role property to mark a Champion. Contact and deal details go to the AI provider, and the welcome email sends without review unless you add an approval step. Replace the placeholder video and help-doc links in the prompt.

  • Silent failureIf no contact on the deal is a Champion, nothing happens: no email, no owner, no count change, and no alert. If there are two champions, both get emails and the count is changed twice. Add a fallback (for example the first contact) and a Slack alert.
  • ReliabilityThe AI email goes to the customer with no review. Check a few outputs before switching it on, or send it to the CSM as a Gmail draft instead.
  • ReliabilityOnly the champion contact gets an owner. The deal and company keep their sales owner, so check that this matches how your team reads ownership in HubSpot.
  • Data privacyCustomer names and emails go to OpenAI to write the email.
  • ModelThe template uses gpt-4o-mini, which OpenAI's deprecations page lists for removal from the API on Jan 14, 2027 (recommended replacement gpt-6-luna).

How to adapt it

  • Weight CSM load by deal amount or account tier instead of a flat deal count.
  • Post the assignment to a customer-success Slack channel and create a kickoff task for the CSM.
  • Send the welcome from the CSM's own mailbox so replies reach them.
  • Swap the Data Table for a Google Sheet if you're on an n8n version without Data Tables.

Sources we checked

Status
Researched: Sourced and summarized, not yet run end-to-end by us
Last checked
Details checked

Setup estimates are rough guesses for someone comfortable with the tools who already has the accounts and API keys. Real time is unknown until tested.

Practical AI workflows for small businesses, every Tuesday

A few workflows each issue for lead follow-up, CRM, proposals, onboarding and support, each labeled Researched or Tested.

We'll email you a link to confirm. Unsubscribe in one click. Privacy policy.

Why trust it: every entry links its source and caveats, and nothing is called Tested until we publish the logs. Our method.

More client onboarding workflows