Enrich Knowledge Graph with External Data

User Intent

"How do I add additional information to extracted entities? Can I enrich person entities with LinkedIn data or organizations with company information?"

Operation

Concept: Entity enrichment strategies SDK Methods: queryObservables(), external API calls, data augmentation Entity: Enriching Observable properties with external data

Prerequisites

  • Knowledge graph with extracted entities

  • External data sources (APIs, databases)

  • Understanding of Observable properties


Enrichment Strategies

1. External API Enrichment

Person Enrichment with LinkedIn:

import { Graphlit } from 'graphlit-client';
import { ObservableTypes } from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Get person entity
const people = await graphlit.queryObservables({
  filter: { types: [ObservableTypes.Person] }
});

// Enrich with LinkedIn data (example)
for (const person of people.observables.results.slice(0, 5)) {
  const email = person.observable.properties?.email;
  
  if (email) {
    // Call external LinkedIn API (pseudocode)
    const linkedInData = await fetchLinkedInData(email);
    
    // Store enriched data
    const enrichedPerson = {
      ...person.observable,
      properties: {
        ...person.observable.properties,
        linkedInUrl: linkedInData.profileUrl,
        currentTitle: linkedInData.currentPosition?.title,
        currentCompany: linkedInData.currentPosition?.company,
        skills: linkedInData.skills,
        enrichedAt: new Date().toISOString()
      }
    };
    
    console.log(`Enriched ${person.observable.name}:`);
    console.log(`  Title: ${enrichedPerson.properties.currentTitle}`);
    console.log(`  Company: ${enrichedPerson.properties.currentCompany}`);
  }
}

async function fetchLinkedInData(email: string): Promise<any> {
  // External API call (example)
  // In production, use actual LinkedIn API or similar service
  return {
    profileUrl: `https://linkedin.com/in/${email.split('@')[0]}`,
    currentPosition: {
      title: "CEO",
      company: "Graphlit"
    },
    skills: ["AI", "Knowledge Graphs", "Semantic Memory"]
  };
}

Organization Enrichment with Clearbit:

2. Workflow-Based Enrichment

Enrichment Stage in Workflow (future feature):

3. Internal Data Enrichment

Aggregate from Multiple Sources:

4. Geographic Enrichment

Place Entity Geocoding:


Enrichment Patterns

Pattern 1: Batch Enrichment

Process all entities of type:

Pattern 2: On-Demand Enrichment

Enrich when entity is accessed:

Pattern 3: Periodic Refresh

Update enrichment data regularly:


Storage Considerations

Where to Store Enriched Data:

  1. Application Database: Store alongside entity IDs

  2. Cache: Redis/Memcached for fast access

  3. File System: JSON files for simple cases

  4. Custom Properties (if supported): Extend Observable properties

Example Storage:


Common External Data Sources

Person Enrichment

  • LinkedIn: Professional data

  • Clearbit: Contact information

  • FullContact: Social profiles

  • Hunter.io: Email verification

Organization Enrichment

  • Clearbit: Company data

  • Crunchbase: Funding, valuation

  • Google Places: Location, reviews

  • D&B: Business intelligence

Place Enrichment

  • Google Maps: Geocoding, details

  • OpenStreetMap: Geographic data

  • GeoNames: Place information


Developer Hints

  • Enrichment is external to Graphlit (store in your app)

  • Use entity IDs to link enrichment data

  • Cache enriched data to avoid repeated API calls

  • Respect external API rate limits

  • Track enrichment timestamps

  • Handle API failures gracefully

  • Future: Native enrichment workflows


Last updated

Was this helpful?