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

Launch an Ironclad contract when a HubSpot deal is won

The moment a deal hits Closed Won, the right contract starts in Ironclad, the link lands on the deal, and your sales channel hears who owns the next step.

Ironclad
HubSpot
Slack
Agentic Task
Draft an ERPNext sales order when a HubSpot deal is won

When a deal is marked closed won in HubSpot, the matching order is drafted in ERPNext with the right customer attached, ready for finance to review.

ERPNext
HubSpot
Slack Bot
Agentic Task
Turn new job postings into qualified HubSpot accounts

The moment a job posting matches your ideal customer profile, check what the company already runs, log the account in HubSpot, and alert your sales channel.

JobsPipe
HubSpot
Slack
Agentic Task
Give every HubSpot deal its own tracked collateral link

When a deal reaches proposal or demo, we pick the right collateral, create a unique tracked link for that buyer, and hand it to the rep.

HubSpot
Bitly
Slack Bot
Agentic Task
Turn new Jobber requests into HubSpot deals and Slack alerts

Every new service request in Jobber becomes a HubSpot contact and deal, plus an instant Slack alert so your team can call the customer back the same day.

Jobber
HubSpot
Slack Bot
Deterministic Code
Research every new HubSpot contact's company automatically

Every new contact triggers a read of the company's own website, so reps open the first call already knowing what they sell and who they sell to.

Hyperbrowser
HubSpot
Slack
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.