Build a Mem0 sales timeline from HubSpot deal stage changes

Every time a HubSpot deal moves stages, log the move to Mem0 on that contact so any AI agent looking up the customer sees the full sales journey.

Deterministic Code
HubSpotMem0SalesData Sync
PromptCreate

Build a deterministic, code style workflow that captures every HubSpot deal stage change as a structured timeline entry in Mem0 on the associated contact. No LLM step, no reasoning, just deterministic capture so the timeline accumulates cleanly across every deal that contact touches.

Trigger: a HubSpot webhook subscribed to deal property change events for the dealstage property. The payload provides the deal id, the previous stage value, and the new stage value.

Step 1. Parse the webhook payload to extract the deal id, the previous stage value, and the new stage value.

Step 2. Call HubSpot Get Deal with that deal id, requesting the properties dealname, amount, and hubspot_owner_id, plus associations to contacts. Pull the deal name, amount, owner id, and the primary associated contact id (first item in the contacts association list).

Step 3. Call HubSpot Get Owner with the hubspot_owner_id from step 2 to resolve the owner's first and last name into a single display name.

Step 4. Call HubSpot Get Contact with the associated contact id from step 2, requesting the email property. If there is no associated contact, or the contact has no email, skip the rest of the workflow and end cleanly.

Step 5. Format a single line memory string of the form: On {YYYY-MM-DD}, deal '{deal name}' ({amount}) moved from {old stage} to {new stage}, owner {owner name}. Use today's date in the workflow's timezone. If amount is missing, omit the parenthetical. Format amount with a currency symbol and thousands separators.

Step 6. Call Mem0 Add Memories with the line from step 5 as a single user message. Scope it to user_id equal to the contact's email. Include metadata with deal_id, stage_from (old stage), stage_to (new stage), and a category of sales_timeline.

The workflow should be fully deterministic. The only branching is the early exit in step 4 when the contact has no email. Keep the integrations limited to HubSpot and Mem0 only.

What does this prompt do?

  • Listens for deal stage changes in HubSpot in real time.
  • Pulls the deal name, amount, owner, and the linked contact's email.
  • Writes a one line, dated stage transition entry to Mem0 scoped to that contact.
  • Tags each entry with the deal id, old stage, new stage, and a sales timeline category so agents can filter by it later.

What do I need to use this?

  • A HubSpot account with permission to read deals, contacts, and owners.
  • A Mem0 account and an API key from app.mem0.ai.
  • Deals in HubSpot that have at least one associated contact with an email.

How can I customize it?

  • Filter by deal stage so only certain transitions (for example, Negotiation onward) get logged.
  • Change the entry format or include extra deal fields like close date or pipeline.
  • Scope memories to the company instead of the contact, or use a different Mem0 category tag.

FAQs

Does this use an LLM to write the timeline entries?
No. The workflow reads the change and writes a fixed line, so it is fast, predictable, and cheap to run on every stage move.
What does a timeline entry actually look like?
Each entry is one dated line, like: On 2026 03 14, deal Acme Renewal ($24,000) moved from Discovery to Negotiation, owner Sam Lee.
Will this back fill historical deal stage changes?
No. It starts logging from the moment you turn it on, so the timeline builds forward over time.
What if the deal has no associated contact, or the contact has no email?
The workflow skips writing to Mem0 for that change, since Mem0 needs a stable contact identifier to attach the entry to.
Can the memory be tied to the company instead of the contact?
Yes. Swap the contact email for the company name or domain when you customize the prompt, and every deal on that company will land on one shared timeline.

Related templates

Turn Mailjet email clicks into ranked HubSpot follow-ups

Twice a day we spot the people clicking your pricing and demo pages, create a follow-up task for their owner, and post a ranked recap to Slack.

Mailjet
HubSpot
Slack Bot
Agentic Task
iMessage campaign console with pre-flight checks and delivery board

Build every text campaign in one screen: check who is actually reachable, see a realistic send plan, then watch delivery land row by row.

LoopMessage
Google Sheets
HubSpot
App
A searchable RFP answer library your bid team drafts from

Every proposal you have ever submitted in one searchable archive, with the closest past answers lined up against each question in a new RFP.

General Input Storage
General Input Database
Mistral AI
+2
App
See which target accounts just started advertising on LinkedIn

Open one board each Monday to see which of your target accounts are running LinkedIn ads right now, and which only switched them on this week.

LinkedIn Ad Library
HubSpot
General Input Database
App
Account health board that puts product usage next to your CRM

Your customer success team opens one board where every account's logins, seats and usage trend sit beside its owner, plan and renewal date.

Looker
HubSpot
Slack Bot
App
Look up a customer's full chat history mid conversation

Your agent types an email and sees every past conversation, rating and tag next to the CRM record, then files notes without ever leaving the chat.

LiveChat
HubSpot
App

Give your AI agents the full sales story, automatically.

Connect HubSpot and Mem0 once, and every deal stage change becomes a clean timeline entry on the contact.