Automate Ahrefs Keyword Research with n8n and Google Gemini AI

Discover how to streamline your SEO keyword research using n8n automation integrating Ahrefs API and Google Gemini AI. This workflow extracts, cleans, queries, and neatly formats relevant keyword data to save hours and improve SEO accuracy.
chatTrigger
lmChatGoogleGemini
httpRequest
+5
Workflow Identifier: 2239
NODES in Use: chatTrigger, lmChatGoogleGemini, httpRequest, code, aggregate, agent, memoryBufferWindow, stickyNote

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow helps get keyword data fast without mistakes from typos.
It takes words from chat messages, cleans them, fixes spelling, then asks Ahrefs API for keyword info.
It shows search numbers, competition info, and price costs in a neat summary.
This saves many hours and stops data confusion.


Who Should Use This Workflow

Anyone who wants quick and clear keyword research results.
Especially good for digital marketers who handle many SEO tasks and hate long data lists.


Tools and Services Used

  • Telegram Bot API: Receives user messages.
  • Google Gemini (PaLM) API: Fixes spelling and finds main keyword.
  • Ahrefs Keyword API via RapidAPI: Gives detailed keyword stats.
  • n8n automation tool: Runs and links all these steps together.

Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Download and Import

  1. Download the workflow file using the Download button on this page.
  2. Open n8n editor where you want to use this.
  3. Click “Import from File” and select the downloaded workflow.

Step 2: Add Your Credentials and API Keys

  1. Fill in Google Gemini (PaLM) API Key in the Google Gemini Chat Model node credentials.
  2. Put RapidAPI key and host info in the HTTP Request node headers.
  3. Update any chat webhook URLs or channel IDs for your chat system if needed.

Step 3: Test the Workflow

  1. Send a test keyword as a chat message to check if the Webhook node receives it.
  2. Watch each node’s output inside n8n UI to make sure keywords clean well and data flows.

Step 4: Activate for Production

  1. Switch the workflow ON from the main n8n canvas screen.
  2. Make sure your chat service points to the webhook URL.
  3. Monitor the workflow for any errors at startup.

If doing self hosting of n8n, visit self-host n8n to help set up.


Inputs, Processing, and Outputs Explained

Inputs

  • Chat messages with keywords or search phrases enter via the chat trigger node.
  • These messages can be from Telegram, WhatsApp, or any webhook-compatible chat app.

Processing Steps

  • The Google Gemini AI model node extracts exactly one clean keyword from the message.
  • The HTTP Request node calls the Ahrefs API with that keyword to get data.
  • The Code node parses the API response, pulling main and related keyword metrics like volume and cost.
  • The Aggregate node combines all keyword entries into one dataset.
  • The LangChain Agent node formats the data into a clearly readable summary.

Output

  • A neat text summary with main keyword stats and related keywords details.
  • Summary includes search volume, competition level, and CPC values.
  • This formatted text can be sent back to chat or used elsewhere.

Common Errors and What to Look For

  • Incorrect API keys in the HTTP Request node cause no data returns.
  • Vague AI prompts in the Google Gemini node may output extra text or no keyword.
  • Wrong JSON data paths in the Code node can give blank or wrong results.
  • Webhook not connected properly means messages never start the workflow.

Check these points when troubleshooting.


Customization Ideas

  • Change chat input by replacing Chat Trigger with another webhook or Telegram node.
  • Switch between multiple Ahrefs API endpoints in the HTTP Request node URL for more data types.
  • Add more keyword metrics in the Code node by editing JavaScript extraction.
  • Update the LangChain Agent prompt to change the summary style or data depth.
  • Add conversational memory nodes for multi-turn chat keyword help.

Summary of Benefits and Results

✓ Saves many hours per SEO session.
✓ Fixes typing errors automatically.
✓ Gets accurate, detailed keyword data instantly.
✓ Gives friendly summaries easy to read and use.
✓ Requires less manual data sifting.


Frequently Asked Questions

Check RapidAPI key and host headers in the HTTP Request node are correct. Ensure network access is working and use retry settings for temporary issues.
The Google Gemini AI node prompt might need clearer instructions to output exactly one clean SEO keyword. Test with various inputs and adjust the prompt.
The Ahrefs API response structure may have changed. Inspect the raw data and update JavaScript code to use the correct JSON paths for the needed fields.
No, this workflow is designed for single keyword queries via chat messages. Bulk processing needs custom changes to handle arrays and batch API calls.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free