Quick overview
This workflow runs manually or weekly to find published WordPress posts missing excerpts, generates plain-text excerpts with OpenAI Chat Completions, and optionally saves the validated excerpts back to WordPress via the REST API.
How it works
- Runs either on a weekly schedule or when triggered manually.
- Fetches a configurable number of WordPress posts in edit context and keeps only published posts with an empty excerpt and at least 200 characters of content.
- Limits the batch size per run, strips HTML from each post, and prepares plain text for prompting.
- Calls the OpenAI Chat Completions API to generate a JSON-formatted excerpt in the post’s language with a configurable word limit.
- Parses and validates the AI response, skipping posts where the excerpt is missing or outside the allowed length range.
- If dry-run mode is enabled, outputs the generated excerpts for review; otherwise, updates each post’s excerpt in WordPress via the REST API.
Setup
- Create a WordPress Application Password for a user with permission to edit posts and add a WordPress API credential in n8n.
- Add an OpenAI API credential in n8n.
- In the workflow configuration, set your site URL, posts-to-scan and per-run limits, OpenAI model, excerpt word limit, and whether dryRun is enabled.