Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 3 min read

Ask my CRM: syncing Pipedrive into cognee memory

Every sales team I've seen has the same problem. The answers are in the CRM, but nobody can find them fast. "Which open deals are stuck on security review?" "What did the customer say about pricing last month?" The deal

Every sales team I've seen has the same problem. The answers are in the CRM, but nobody can find them fast. "Which open deals are stuck on security review?" "What did the customer say about pricing last month?" The deal record has some of it, the notes have the rest, and the activity log has the context. Finding it means clicking through ten tabs.

For Mergetober I built a Pipedrive connector for cognee. cognee turns your data into a knowledge graph plus a vector index, so you can ask questions in plain language. The connector gets your Pipedrive data in, and keeps it current.

What it looks like

import cognee
from cognee_community_connector_pipedrive import pipedrive_source

await cognee.remember(
    pipedrive_source(api_token="...", resource_name="pipedrive_sales"),
    dataset_name="pipedrive_crm",
    primary_key="id",
    write_disposition="merge",
)

answer = await cognee.search(
    query_text="Which open deals have notes about blockers, and who is the contact?",
    query_type=cognee.SearchType.GRAPH_COMPLETION,
    datasets=["pipedrive_crm"],
)

That's the whole setup. Run remember again tomorrow and it only processes what changed.

How I use it

Before a call. I ask "What has Acme told us about SSO?" and get the notes from the deal, the activity log, and the person record together. The graph links them because every note names the deal it belongs to.

Pipeline review. "Which deals in the Proposal stage have no activity planned?" Stages, pipelines, and owners are stored as names, not ids, so the question works the way you'd say it.

Handover. When a deal moves to a new owner, they can ask "Summarise everything about the Globex pilot" instead of reading 40 notes.

What gets synced

One document per record: deals (including archived ones, which you can turn off), persons, organizations, activities, and notes. Custom fields are turned into their real names and option labels. Notes are stored as HTML in Pipedrive, so the connector turns them into plain text.

Email addresses and phone numbers are left out on purpose. Memory that answers questions about deals doesn't need them, and keeping them out means less personal data in your AI stack.

The interesting part: forgetting

Adding data to memory is easy. Taking it out again is the hard part. If a rep deletes a note because it was wrong, the AI should stop quoting it.

Pipedrive only has a delete feed for deals, and only for 30 days. Persons, organizations, activities, and notes have none. So the connector does this:

  1. Each run lists every selected record.
  2. It renders each record to text and compares a fingerprint with the last run. If nothing changed, nothing is sent to cognee.
  3. When a full pass is done, any record it saw before but not this time gets checked once more by id.
  4. If Pipedrive says 404 (or the record is flagged deleted), the connector sends a delete marker, and cognee removes it from the graph, the vectors, and the database.

The extra check in step 3 matters. Listings can shift while you page through them, and I didn't want a record to be wiped from memory just because it moved between pages.

Why not just use update_time?

That was my first idea. But renaming a deal does not change the update_time of its notes. Every note document says which deal it's about, so the note text has to change too. Comparing rendered text catches that, and it also catches renamed stages and custom fields. Records that didn't change still cost nothing to process.

The cost is API calls. Listing 10,000 deals and 20,000 notes uses about 1,000 Pipedrive API tokens per run, which is well inside even a single seat's daily budget.

Behaving well on rate limits

cognee holds a lock while it ingests, so a sync that sleeps for hours on a rate limit blocks everything else. The connector waits out short bursts but caps total waiting at a minute per run. If the daily budget is spent, it stops cleanly, keeps its place, and the next run carries on from the same page.

Try it

The connector lives in packages/connector/pipedrive in cognee-community. A free Pipedrive developer sandbox is enough to try it: copy your API token from Settings β†’ Personal preferences β†’ API and run examples/example.py.

Built for Mergetober with cognee.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.