What You’ll Build
Your SQL database, your ticket exports and a folder of documents go into one cognee memory. A graph model you control tells cognee which people, teams, projects, customers and tickets to extract, so the same person in all three sources becomes one node. Then you ask questions no single source can answer, and browse the graph in a UI. Building the memory takes threecognee.remember calls, one per source, all with the same graph model, and answering a question takes one cognee.recall call.
The complete cookbook is
examples/cookbooks/company_brain/company_qa/.
Try It on Sample Data
The sample is Acorn Analytics, a fictional company: an HR and project database, two ticket exports (a support desk export and a CSV of escalations that Customer Success keeps in a spreadsheet) and three documents. The escalated ticket in the CSV says who is assigned to Brightline Retail’s open issue. Only the database says which team she is on. Only a meeting note says which fix was decided. You need only an LLM key, no data of your own.LLM_API_KEY alone is enough for OpenAI, cognee’s default for both the LLM and the embeddings. Other providers, such as Anthropic, Gemini, Azure OpenAI, AWS Bedrock or a local model through Ollama, need a few more lines in the same .env: LLM Providers and Embedding Providers list them for each provider. Set both, because embeddings you leave at the default still need an OpenAI key.
- Terminal
- Coding agent
[clear] Forgot the dataset company_qa instead. Your wording will differ from run to run.
Run It on Your Data
--database(optional): a SQLAlchemy URL such aspostgresql://...orsqlite:///path/to.db, read through dlt’ssql_database. Add--tables a,bto read only those tables or views.--tickets(optional): one or more JSON or CSV exports from your support desk.--docs(optional): a folder of meeting notes, postmortems or memos.- Pass at least one source. Without any, the cookbook runs on the sample.
- Node.js 20+ and npm, only for
--ui. Without them, cognee falls back to Docker.
--check reports what is missing without doing any work. Running it again skips content cognee already holds; an edited file is remembered as a new document, and its old version stays. Add --clear to forget the dataset first and start over from your sources as they are now. Later questions don’t need the sources again: uv run python examples/cookbooks/company_brain/company_qa/scripts/ask.py "question".
How It Works
Step 1: Start From an Empty Memory
Source:scripts/clear.py
This step forgets what an earlier run remembered, so old copies never mix with new ones. It runs only with --clear, which a sample run turns on by default; --no-clear keeps the dataset.
cognee.forget(dataset="company_qa"), which deletes the dataset and everything extracted from it. On your own data, use --clear only to start over.
Step 2: Remember Your Company’s Sources
Source:scripts/ingest.py
This step saves each source you pass, so every later question can use all of them. With --sample, the arguments point at the sample company.
--tables), every ticket file you pass, and every document in the folder. Each source gets one cognee.remember call with its own node set (database, tickets, docs), a tag that lets you later recall from one source alone. All three pass graph_model=CompanyGraph from models.py: the node types the LLM extracts. Each type declares identity_fields, so the same name gives the same node id, and that is what links the sources. Tickets and docs also pass preferred_loaders=["csv_loader"], so a CSV file is read as text and extracted with the graph model, rather than stored as plain table rows that never link to the other sources.
Step 3: Answer a Question Across Sources
Source:scripts/ask.py
This step answers your question from everything the previous step remembered. It runs when you pass --ask; the sample run asks its own question.
cognee.recall(question, datasets=["company_qa"]). recall with no query_type picks the retrieval strategy itself. For a plain question that is HYBRID_COMPLETION, which searches the text and the graph together and writes one answer. There is no node set filter, so the answer can draw on all three sources at once.
Step 4: Browse the Graph
Source:scripts/ui.py
This step opens the graph in your browser. It runs when you pass --ui.
cognee.start_ui. Open http://localhost:3000, sign in with the prefilled default user, and select the company_qa dataset. You see one node per person, linked to their team, projects, tickets and manager. Ctrl+C stops both.
Make It Yours
- Model your own company. Edit
models.py: add the entities your data talks about, drop the ones it doesn’t, and keepidentity_fieldson every type so sources still link. See Custom Graph Model. - Add the rest of your company’s data. Your company’s knowledge also lives in mail, shared drives, meeting notes and issue trackers. Add one more
remembercall toscripts/ingest.pyfor each source, with its own node set and the samegraph_model=CompanyGraph, so its people and projects merge with the nodes you already have. cognee ships connectors you pass straight toremember:google_drive_source,gmail_sourceandlinear_source. For Granola, the Follow-Up Agent cookbook has a small client that reads your meeting notes. Any other API or database loads through dlt. - Feed it readable rows. Point
--tablesat views that join your tables intoid,titleandcontentcolumns, like the*_profilesviews insetup.py. The LLM extracts sentences better than bare foreign keys. - Ask one source at a time. Recall with
query_type=SearchType.CHUNKSandnode_name=["tickets"]to see what the ticket export alone says. NodeSet Grouping shows how scoping works. - Let your coding agent ask. Keep
scripts/ui.pyrunning and connect Claude Code or Codex through the cognee MCP server with--api-url http://localhost:8000. The agent then reads the same graph as the UI. The cookbook README has the exact commands.
Clean Up
sample/ in the cookbook folder.
Custom Graph Model
Define the node types cognee extracts from your data.
Follow-Up Agent
Build another one: turn your latest call into next steps.
Personalized Email
Build another one: email replies that know what you promised.
Self-Hosted AI Companion
Build another one: a chat companion that knows your notes.