Build a Mem0 sales timeline from HubSpot deal stage changes

By General Input

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.

Integrations

  • HubSpot
  • Mem0

Type

Deterministic Code

Categories

  • Sales

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.

Related prompts

Explore more prompts
Turn Mailjet email clicks into ranked HubSpot follow-upsiMessage campaign console with pre-flight checks and delivery boardA searchable RFP answer library your bid team drafts fromSee which target accounts just started advertising on LinkedInAccount health board that puts product usage next to your CRMLook up a customer's full chat history mid conversationLusha prospecting workbench with credit-safe revealsWhich companies your LinkedIn ads reach, matched to your CRMLead response desk with a running clock on every new leadApprove Lusha enrichment field by field before HubSpot saves it