Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Volunteer Matching Agent

An intelligent agent that matches Bluesky posts expressing volunteering intent with NYC volunteering opportunities using AI-powered intent detection and local vector embeddings for semantic search.

๐Ÿ“‹ Overview

๐ŸŒŸ OpenAI-Powered Version (Recommended)

The latest version uses OpenAI's GPT-4 for intelligent intent detection:

  • ๐Ÿง  Smart Intent Detection: Uses GPT-4o-mini to analyze batches of posts
  • ๐ŸŽฏ Semantic Query Extraction: AI extracts the perfect search query from each post
  • ๐Ÿ“ฆ Batch Processing: Analyzes 30 seconds of posts at a time for efficiency
  • ๐Ÿ” Local Vector Matching: Uses local embeddings for fast, offline matching
  • ๐Ÿ’ฐ Cost Effective: Batching reduces API calls (~$0.001 per 100 posts)
  • ๐ŸŽจ Higher Precision: Better intent detection than keyword matching

๐Ÿ’ป Local-Only Version

Fully offline version with keyword-based detection:

  • ๐Ÿ“š Vectorizes opportunities using local AI model (no API needed!)
  • ๐ŸŽฏ Keyword-based intent detection
  • โšก Runs completely offline once embeddings are generated

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ installed
  • OpenAI API key (for OpenAI version)
  • ~2GB free disk space (for embedding model on first run)

Installation

  1. Install dependencies:
npm install
  1. Configure API key (for OpenAI version):
cp .env.example .env

Edit .env and add your OpenAI API key:

OPENAI_API_KEY=your_openai_api_key_here

Running the Agent

OpenAI-powered version (recommended):

node volunteer-matcher-openai.js

Local-only version:

node volunteer-matcher-local.js

First run: The agent will download the embedding model (~90MB) and vectorize all opportunities (~30 seconds)

Subsequent runs: Loads vectors from disk instantly (<1 second)

The agent will:

  1. Load or create local vector database with all 15 opportunities
  2. Connect to Bluesky Jetstream
  3. Collect posts in 30-second batches (OpenAI version) or process in real-time (local version)
  4. Detect volunteering intent (AI or keywords)
  5. Match posts with relevant opportunities using vector search
  6. Save matches to matches.json

๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ volunteer-matcher-openai.js # OpenAI + local vectors (RECOMMENDED)
โ”œโ”€โ”€ volunteer-matcher-local.js  # Fully local with keywords
โ”œโ”€โ”€ volunteer-matcher.js        # Alternative: Senso API version
โ”œโ”€โ”€ vector-db.js               # Local vector database implementation
โ”œโ”€โ”€ jetstream.js               # Standalone Jetstream viewer
โ”œโ”€โ”€ volunteering.json          # 15 NYC volunteering opportunities
โ”œโ”€โ”€ vector-db.json             # Generated: vectorized opportunities
โ”œโ”€โ”€ matches.json               # Generated: matched posts
โ”œโ”€โ”€ package.json               # Node.js dependencies
โ”œโ”€โ”€ .env                       # API keys (create from .env.example)
โ””โ”€โ”€ README.md                  # This file

๐Ÿ“Š How It Works

OpenAI-Powered Version

1. Local Vector Embeddings

Uses Xenova/all-MiniLM-L6-v2 (a lightweight 80MB embedding model) to convert each opportunity into a 384-dimensional vector:

"City Harvest - Food Rescue & Distribution" โ†’ [0.023, -0.145, 0.891, ...]

The vectors capture semantic meaning, allowing similarity matching even when exact keywords don't match.

2. Batch Post Collection

  • Collects all posts from Jetstream for 30 seconds
  • Typical batch size: 50-150 posts per batch
  • Batches sent to OpenAI for analysis

3. AI Intent Detection

OpenAI analyzes the entire batch and for each post:

  • Detects volunteering intent with confidence score
  • Extracts semantic search query optimized for vector matching
  • Returns structured JSON with results for all posts

Example OpenAI output:

{
  "results": [
    {
      "post_index": 0,
      "has_volunteering_intent": true,
      "search_query": "animal shelter dog walking weekend Manhattan",
      "confidence": 0.92
    }
  ]
}

4. Vector Matching

For posts with detected intent:

  1. Use the AI-generated search query (not the original post text)
  2. Generate embedding for the optimized query
  3. Calculate cosine similarity with all 15 opportunity vectors
  4. Return top 3 matches sorted by relevance score

Example:

  • Post: "I want to help dogs in NYC"
  • Top match: "Animal Haven - Dog Walking" (85% similarity)

4. Match Output

Matches are saved with complete metadata:

{
  "timestamp": "2025-10-04T19:30:00.000Z",
  "post": {
    "text": "Looking to volunteer with kids in Brooklyn...",
    "author_did": "did:plc:abc123...",
    "post_uri": "at://did:plc:abc123.../app.bsky.feed.post/xyz",
    "post_url": "https://bsky.app/profile/did:plc:abc123.../post/xyz"
  },
  "matches": [
    {
      "title": "826 NYC - Writing & Tutoring",
      "organization": "826 NYC",
      "category": "Education & Youth",
      "borough": "Brooklyn",
      "relevance_score": 0.72,
      "contact": {...}
    }
  ],
  "ai_summary": "Based on your interest, here are relevant volunteering opportunities..."
}

๐ŸŽฏ Volunteering Categories

The dataset includes opportunities across 5 categories:

  • Community & Social Services (6 opportunities)
  • Education & Youth (4 opportunities)
  • Environment & Parks (3 opportunities)
  • Animals & Wildlife (2 opportunities)
  • Health & Medical (1 opportunity)

๐Ÿ”ง Configuration

Customization

Modify volunteering keywords in volunteer-matcher-local.js:

const VOLUNTEERING_KEYWORDS = [
  'volunteer', 'volunteering', 'help out',
  // Add your own keywords here
];

Adjust match limit in vector-db.js:

async search(queryText, topK = 3) {  // Change topK for more/fewer matches

Force re-vectorization (if you update volunteering.json):

rm vector-db.json
node volunteer-matcher-local.js

๐Ÿ“ Example Output

๐Ÿค– Volunteer Matching Agent Starting...
================================================================================

๐Ÿ”ง Initializing embedding model...
โœ… Embedding model ready!

๐Ÿ“‚ Loading existing vector database...
โœ… Loaded 15 opportunities from disk
๐Ÿ“… Last updated: 2025-10-04T19:15:30.000Z

๐ŸŒŠ Connecting to Bluesky Jetstream...
๐Ÿ“Š Stats will update every 100 posts

================================================================================

๐Ÿ“ˆ Processed 100 posts | Found 0 volunteering posts
๐Ÿ“ˆ Processed 200 posts | Found 0 volunteering posts

================================================================================
๐ŸŽฏ VOLUNTEERING INTENT DETECTED!
================================================================================
๐Ÿ‘ค Author: did:plc:xyz789...
๐Ÿ“ Post: I'd love to volunteer at an animal shelter this weekend
๐Ÿ”— URI: at://did:plc:xyz789.../app.bsky.feed.post/abc
๐Ÿ”— URL: https://bsky.app/profile/did:plc:xyz789.../post/abc

๐Ÿ” Searching for: "I'd love to volunteer at an animal shelter this weekend..."
โœ… Found 3 matches

๐Ÿ’ก AI Summary:
   Based on your interest, here are relevant volunteering opportunities in
   Animals & Wildlife. The best match is "ASPCA - Animal Care Assistance"
   with ASPCA in Manhattan.

๐Ÿ“‹ Top Matches:

  1. ASPCA - Animal Care Assistance
     ๐Ÿข ASPCA
     ๐Ÿ“ Manhattan | Animals & Wildlife
     ๐ŸŽฏ Relevance: 78.2%
     โฐ 4 hours per week, 6-month commitment
     ๐Ÿ“ง volunteer@aspca.org

  2. Animal Haven - Dog Walking & Cat Socialization
     ๐Ÿข Animal Haven
     ๐Ÿ“ Manhattan | Animals & Wildlife
     ๐ŸŽฏ Relevance: 75.8%
     โฐ 2-3 hours per week
     ๐Ÿ“ง volunteer@animalhavenshelter.org

  3. GrowNYC - Community Garden Support
     ๐Ÿข GrowNYC
     ๐Ÿ“ All boroughs | Environment & Parks
     ๐ŸŽฏ Relevance: 42.1%
     โฐ 2-4 hours, flexible
     ๐Ÿ“ง volunteer@grownyc.org

================================================================================

๐Ÿ› ๏ธ Troubleshooting

"Command not found: node"

"Connection closed"

  • The agent auto-reconnects to Jetstream after 5 seconds
  • Check your internet connection

Model download is slow

  • First run downloads ~90MB model from HuggingFace
  • Subsequent runs use cached model (no download needed)

Getting too many false positives

  • Adjust the keyword list to be more specific
  • Increase minimum relevance score threshold in the code

๐Ÿ“ฆ Dependencies

  • @xenova/transformers - Local AI embeddings (runs in Node.js, no GPU needed)
  • ws - WebSocket client for Jetstream

๐Ÿ”ฌ Technical Details

Embedding Model: Xenova/all-MiniLM-L6-v2

  • 384-dimensional vectors
  • Trained on 1 billion sentence pairs
  • Optimized for semantic similarity
  • Runs entirely locally (CPU-only, no GPU needed)

Vector Database:

  • Simple JSON file storage
  • Cosine similarity search
  • O(n) search complexity (fine for 15 items)
  • For larger datasets, consider using a proper vector DB (Pinecone, Qdrant, etc.)

๐Ÿ”ฎ Future Enhancements

  • Automatic reply bot to post opportunities
  • User preference tracking
  • Geographic filtering (only match with user's borough)
  • Schedule-based filtering (match availability)
  • Multi-language support
  • Web dashboard for matches
  • Upgrade to proper vector DB for scale (Qdrant, Weaviate)
  • Fine-tune embedding model on volunteering-specific data

๐Ÿ“„ License

MIT

๐Ÿค Contributing

This is a hackathon project. Feel free to fork and improve!


Built with โค๏ธ for connecting volunteers with NYC opportunities

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages