See llms.txt for all machine-readable content.

Back to Templates

Add internal links to Japanese WordPress posts with Gemini and Slack approval

Quick overview

This workflow adds internal links to published Japanese WordPress posts by using Google Gemini to find related pages, then sending link suggestions to Slack for editor approval before updating the post and logging the links in n8n Data Tables.

How it works

  1. Receives a WordPress post ID either via an authenticated webhook call or a manual n8n form submission.
  2. Fetches the post from the WordPress REST API using Basic Auth, then extracts numbered paragraphs and existing links from the raw HTML.
  3. Uses Google Gemini to generate Japanese noun-phrase search keywords, searches the WordPress REST API for related posts, and also pulls matching “priority pages” from an n8n Data Table based on keyword hits in the post body.
  4. Excludes the current post, already-linked targets, and previously logged link pairs, then ranks candidates using priority status, search frequency, and how often each target has been linked before.
  5. Uses Google Gemini to propose up to the configured number of internal links (paragraph + anchor + target), then validates that each anchor appears exactly in the paragraph and is not inside existing links or cut across Japanese word boundaries.
  6. Posts the vetted suggestions to Slack as a message with a checkbox form so an editor can choose which links to add (up to a 1-day wait).
  7. If the editor selects links, reloads the WordPress post to ensure it hasn’t changed, inserts the chosen anchors into the raw HTML, updates the post via the WordPress REST API, logs added links to an n8n Data Table, and confirms the result in Slack.

Setup

  1. Add WordPress Basic Auth (application password) credentials and set the correct site URL and post type in the workflow configuration values.
  2. Add a Google Gemini API credential for the Gemini chat model nodes.
  3. Add Slack credentials, invite the app to your target channel, and set the channel ID in the Slack nodes that send the approval form and status messages.
  4. Create two n8n Data Tables named internal_links (source_url, target_url, anchor, added_at) and link_priority_pages (url, title, keywords) and populate any priority pages and comma-separated keywords.
  5. If using the webhook trigger, copy the webhook URL and configure your publishing system to POST { "post_id": <id> } with the required header authentication token.

Requirements

  • WordPress with the REST API and an application password for a user who can edit posts
  • Google Gemini API key
  • Slack app with chat:write
  • n8n Data Tables

Customization

  • Add the pages you most want to grow to the link_priority_pages Data Table (url, title, keywords). When a post contains one of those keywords, that page is offered first.
  • Change max_links and max_candidates in Config to set how many links are proposed per post and how many related posts are checked.
  • Add your own words to reject as anchors to the GENERIC list in the Check Suggestions Code node, next to こちら and 詳しくは.

Additional info

Tested end to end on a local WordPress site with Japanese posts:

  • Only the ticked links were inserted, and nothing changed when no box was ticked.
  • Anchors that cut a word in half, start or end with a particle, or are generic words such as こちら were dropped, and Slack showed why.
  • Pages in link_priority_pages appeared first in the list.
  • Links already added from the same post were not proposed again.
  • When the post was edited while the approval was open, nothing was written and Slack said why.