🎬 Auto-categorize blog posts with OpenAI GPT-4, GitHub, and Google Sheets for Astro/Next.js

⚑ 256 views · 🎬 Content Creation & Video

πŸ’‘ Pro Tip β€” If you need GitHub data beyond what the REST API gives you, ScraperNode has a repository scraper that extracts metadata at scale without token rate limits.

View All Scrapers

Description

image.png

Automatically Assign Categories and Tags to Blog Posts with AI

This workflow streamlines your content organization process by automatically analyzing new blog posts in your GitHub repository and assigning appropriate categories and tags using OpenAI. It compares new posts against existing entries in a Google Sheet, updates the metadata for each new article, and records the suggested tags and categories for review β€” all in one automated pipeline.


Who’s It For


How It Works

  1. Form Trigger – Starts the process manually with a form that initiates article analysis.
  2. Get Data from Google Sheets – Retrieves existing post records to prevent duplicate analysis.
  3. Compare GitHub and Google Sheets – Lists all .md or .mdx blog posts from the GitHub repository (piotr-sikora.com/src/content/blog/pl/) and identifies new posts not yet analyzed.
  4. Check New Repo Files – Uses a code node to filter only unprocessed files for AI tagging.
  5. Switch Node –
    • If there are no new posts, the workflow stops and shows a confirmation message.
    • If new posts exist, it continues to the next step.
  6. Get Post Content from GitHub – Downloads the content of each new article.
  7. AI Agent (LangChain + OpenAI GPT-4.1-mini) –
    • Reads each post’s frontmatter (--- section) and body.
    • Suggests new categories and tags based on the article’s topic.
    • Returns a JSON object with proposed updates (Structured Output Parser)
  8. Append to Google Sheets – Logs results, including:
    • File name
    • Existing tags and categories
    • Proposed tags and categories (AI suggestions)
  9. Completion Message – Displays a success message confirming the categorization process has finished.

Requirements


How to Set Up

  1. Connect your GitHub, Google Sheets, and OpenAI credentials in n8n.
  2. Update the GitHub repository path to match your project (e.g., src/content/blog/en/).
  3. In Google Sheets, create columns:
    • FileName, Categories, Proposed Categories, Tags, Proposed Tags.
  4. Adjust the AI model or prompt text if you want different tagging behavior.
  5. Run the workflow manually using the Form Trigger node.

How to Customize


Important Notes


Summary

This workflow automates metadata management for blogs or documentation sites by combining GitHub content, AI categorization, and Google Sheets tracking.
With it, you can easily maintain consistent tags and categories across dozens of articles β€” boosting SEO, readability, and editorial efficiency without manual tagging.

πŸ”— Nodes Used

GitHub, Google Sheets, AI Agent, OpenAI Chat Model, Simple Memory, Structured Output Parser

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup