Knowledge Graph

⏱️ Time to Complete: 20 minutes 🎯 Level: Intermediate πŸ’» Language: TypeScript

What You'll Build

A knowledge graph that automatically extracts:

  • βœ… Entities (people, organizations, places, events, products)

  • βœ… Relationships between entities

  • βœ… Queryable structure from unstructured content

  • βœ… Multi-hop reasoning across sources

πŸ“ Knowledge graph example app


Why Knowledge Graphs Matter

Traditional search: "Find documents mentioning Sarah" Knowledge graph: "Find all interactions between Sarah Chen at Acme Corp and our Sales team, including meetings, emails, and Slack conversations"

The difference:

  • βœ… Entity recognition (Sarah Chen = person, Acme Corp = organization)

  • βœ… Relationship tracking (Sarah works at Acme, spoke with Sales)

  • βœ… Semantic understanding (group related mentions across sources)

  • βœ… Structured queries on unstructured data

Real-world example: Zine uses knowledge graphs to answer "Who from Acme Corp have we talked to?" across Slack, email, meetings, and CRM notes.


Prerequisites

  • Complete the Quickstart tutorial

  • Graphlit project with API credentials configured in .env

  • npm install graphlit-client dotenv

Need Python or .NET examples? Open Ask Graphlit in the Developer Portal (or visit ask.graphlit.dev) for autogenerated samples tailored to your SDK.


Step 1: Extract Entities from Content

Create a workflow, ingest content, and extract entities - all in one script:

What happens:

  • Creates extraction specification (GPT-5, temperature 0 for deterministic results)

  • Creates workflow with entity extraction

  • Ingests sample text with the workflow

  • Automatically extracts entities (people, organizations, places, etc.)

  • Lists all extracted entities

Run: npx tsx extract-entities.ts


Step 2: Explore Relationships in the Graph

Query content and visualize the entity relationships:

This renders the knowledge graph for a document. Each node represents a person, organization, or event; edges capture relationships Graphlit inferred (e.g., "Sarah Chen β†’ worksFor β†’ Acme Corp").


Step 3: Find Every Document Mentioning an Entity

Filtering by observations lets you answer questions like "Show me every asset where Sarah Chen appears" or "Find all notes referencing Salesforce".


Production Patterns

Batch Ingestion + Polling

Build Collections from Entities

Keep Graph Conversations Focused


Real-World Examples

1. Customer 360

  • Aggregate Slack, email, and meeting notes per account

  • Surface key contacts + topics before every call

  • Feed a sales agent that remembers context across teams

2. Incident Response Watchtower

  • Track mentions of outages across Sentry, Slack, and PagerDuty

  • Connect incidents to affected services and owners

  • Push summaries to on-call staff in real time

3. Market Intelligence Radar

  • Monitor competitor names across research docs and news

  • Attach relationships between mentions, products, and regions

  • Drive alerts when new entities (people or products) appear


Next Steps


Full Example: Production Agent

See the complete Next.js agent in graphlit-samples:

  • Visual knowledge-graph explorer with streaming chat

  • Entity filtering and relationship queries in the UI

  • Production-ready environment configuration and error handling


Build agents that understand your data model. Build with Graphlit.

Last updated

Was this helpful?