π¬ Sync WordPress and WooCommerce content with Pinecone using OpenAI embeddings
β‘ 1 views Β· π¬ Document Extraction & Analysis
Description
Quick overview
This workflow syncs WordPress/WooCommerce pages and blog posts into a Pinecone vector index by fetching content in small batches, generating OpenAI embeddings, and tracking indexed items in an n8n Data Table to handle updates and deletions.
How it works
- Runs on a manual trigger or on a daily cron schedule.
- Fetches up to 100 published WordPress pages and up to 100 published posts (IDs and modified timestamps) via the WooCommerce/WordPress REST API.
- Compares the live IDs/modified dates with the
indexed_wc_blog_v1n8n Data Table and selects up tostaticBatchSizepages/posts that are new or changed. - Fetches the full content for the selected batch from the WordPress pages and posts endpoints and combines the results.
- For each page/post, strips HTML, prepares metadata, deletes any existing Pinecone vectors for the same
fileId, then splits text, generates OpenAI embeddings, and inserts the chunks into Pinecone. - Upserts the page/postβs
fileIdanddateModifiedinto theindexed_wc_blog_v1Data Table to record what was indexed. - Identifies entries that exist in
indexed_wc_blog_v1but no longer exist in WordPress and deletes their vectors from Pinecone and their rows from the Data Table.
Setup
- Add WooCommerce API credentials with access to the WordPress REST API endpoints for pages and posts.
- Add an OpenAI API credential for creating embeddings.
- Add a Pinecone API credential, create or select a Pinecone index, and set the index host and namespace values.
- Create an n8n Data Table named
indexed_wc_blog_v1with text columnsproductId,indexedAt, anddateModified. - Update
wooBaseUrl,pineconeIndexName,pineconeIndexHost,pineconeNamespace, andstaticBatchSizein the βWC: Settings (static content)β node before enabling the schedule.
π Nodes Used
HTTP Request, Schedule Trigger, Embeddings OpenAI, Recursive Character Text Splitter, Pinecone Vector Store, Default Data Loader
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File