Enrich ChartMogul customers when a HubSpot deal closes

When a deal is marked closed won in HubSpot, we tag the matching ChartMogul customer with the plan and source, and record the sale details.

Deterministic Code
ChartMogulHubSpotSalesFinanceData Sync
PromptCreate

Build a code workflow that mirrors the commercial context of every won sale from HubSpot onto the matching ChartMogul customer, so revenue reporting can be segmented by how the deal was actually sold. Use the HubSpot poll trigger "Deal Created, Updated, or Stage Changed" (event type deals_updated) so the workflow runs whenever a deal is created, edited, or moved between stages.

First, check the stage of the deal that fired the trigger. Only continue if the deal is in a closed won stage. The stage filter belongs inside the workflow, not in the trigger. If the deal is in any other stage, exit immediately without writing anything and without treating it as an error. If the trigger payload does not carry the full deal record, read it back with HubSpot Search Deals filtered on the deal id.

For a closed won deal, use HubSpot Search Contacts to find the primary contact associated with the deal and read their email address. That email is the join key between the two systems. If the deal has no associated contact with a usable email address, exit cleanly and say why.

Look the customer up with ChartMogul Search Customers by Email. Treat an empty result as a normal outcome rather than a failure: billing frequently starts days after a deal closes, so the customer may not exist in ChartMogul yet. In that case, log that no customer matched and finish successfully. The next time the deal is touched in HubSpot the workflow runs again, and by then the customer will usually exist.

When a customer does match, apply tags with ChartMogul Add Tags to Customers by Email. Tag the plan tier the deal was sold at, and the acquisition source (for example the deal's lead source or original channel). Tags are additive, so this must not disturb tags already on the customer.

Then write the structured fields with ChartMogul Add Custom Attributes to Customers by Email: deal owner as a String, deal amount as an Integer, close date as a Timestamp, and contract term as a String. Two details matter here. ChartMogul custom attribute types are capitalized exactly as String, Integer, Decimal, Timestamp and Boolean. And ChartMogul monetary amounts are integers in cents, so multiply the HubSpot deal amount by 100 and round to a whole number before sending it. Send the close date as an ISO 8601 timestamp.

Optionally call ChartMogul Retrieve a Customer's Tags and Attributes afterwards to confirm the write landed, and include the tags and attributes that were applied in the run output so each run is auditable. Keep the field mapping fixed and deterministic. There is no judgement to make at any step, so no model reasoning is needed.

Additional information

What does this prompt do?
  • Watches your HubSpot pipeline and picks up every deal that moves into a closed won stage.
  • Finds the matching customer in ChartMogul using the email address of the main contact on the deal.
  • Tags that customer with the plan tier they bought and where the deal came from, so revenue can be sliced by both later.
  • Records the deal owner, the deal value, the close date and the contract length on the customer record.
What do I need to use this?
  • A HubSpot account with deals and contacts, where closed won deals have a contact with an email address on them.
  • A ChartMogul account that already has your billing data flowing into it.
  • Agreement on which HubSpot fields hold the plan tier, the acquisition source and the contract term.
How can I customize it?
  • Change which pipeline stages count as a win, if your team uses custom stage names.
  • Swap in different details to tag or record, such as region, industry or the partner who referred the deal.
  • Adjust which contact on the deal is used for matching, for example the billing contact instead of the main one.

FAQs

What happens if the customer is not in ChartMogul yet?
Nothing breaks. Billing often starts days after a deal is signed, so if no customer matches the email address yet, the run simply ends without making changes. The next time that deal is edited in HubSpot it tries again, and by then the customer usually exists.
Will this work on HubSpot Free?
Yes for the basics. Deals and contacts are available on every HubSpot tier including free. Some of the fields you might want to copy across, such as a custom contract term field, may need a paid tier depending on your plan.
Does this change anything in HubSpot?
No. HubSpot is only read from. Every change this makes lands on the ChartMogul side, so your CRM records stay exactly as your reps left them.
Will it overwrite tags I already added in ChartMogul?
No. Tags are added alongside whatever is already on the customer. The recorded fields like deal value and close date are refreshed with the latest information from HubSpot, so corrections made after the deal closes still flow through.
How soon after a deal closes does the customer get updated?
Within a few minutes of the deal being saved in HubSpot. Because it also runs on edits, a later correction to the amount or the close date will update ChartMogul too.

Related templates

Filter spam from Netlify forms before it reaches your CRM

Every new form submission gets judged real or junk, sorted by intent, and only genuine sales leads land in HubSpot with an email brief waiting for your team.

Netlify
HubSpot
Gmail
Agentic Task
Log signed Documenso contracts as closed won in HubSpot

When a contract is fully signed, we read the agreed terms, move the matching HubSpot deal to closed won, and post a deal desk summary to Slack.

Documenso
HubSpot
Slack Bot
Agentic Task
Turn signed DocuSeal forms into HubSpot contacts and notes

When a DocuSeal document is fully signed, the answers people typed become real HubSpot records, with the executed PDF filed in Drive.

DocuSeal
HubSpot
Google Drive
+1
Agentic Task
Research new HubSpot leads and brief their owner in Slack

When a new contact lands in HubSpot, we read their company website and recent news, fill in the record, and send their owner a short brief.

Notte
HubSpot
Slack
Agentic Task
Unblock contracts stuck waiting on your own signature

When a customer signs but your side has not, this alerts the internal signer in Slack with the deal value and re-sends their signing email.

DocuSeal
HubSpot
Slack
Agentic Task
Weekday Mailjet deliverability alert that stays quiet on good days

Every weekday at 7am we check your bounce and spam complaint rates, and only message you in Slack when something is actually going wrong.

Mailjet
Slack
HubSpot
Agentic Task

Stop guessing which deals actually drive your MRR.

Let every closed won deal carry its sales context into ChartMogul, so your revenue reporting segments itself.