Category: Automations › SEO, Analytics & Reporting · Best for: Ahrefs users · Platform: n8n · Steps: 9
What it does
It pulls keyword ideas and numbers from Ahrefs into a sheet.
This ai agent is important so that you always make sure for all queries you send, only the keyword phrase will be passed over to the API request node, and if you misspell any word, it will be corrected.
Works with: Gemini, Memory Buffer Window, Agent
What you get
- The n8n workflow file (
workflow.json), ready to import - This setup guide
- The list of fields to change for your own accounts (see Install below)
- Email support if you get stuck
Before you start
-
An n8n account. Easiest: n8n Cloud (free trial). Self-host for free with Docker:
docker run -it --rm -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n, then open http://localhost:5678. -
Accounts and API keys for these services:
- Google (Sheets, Gmail, Drive, Calendar, Docs): how to connect (used by Google Gemini Chat Model, Google Gemini Chat Model1)
Install
- In n8n, click Create workflow (top right).
- Click the ⋯ menu → Import from file and choose
workflow.json. Or open the file, copy everything and paste it onto the empty canvas with Ctrl/Cmd + V. - Open each node with a red warning triangle and pick or create the matching credential from the list above.
- Point these fields at your own sheets, chats and accounts:
- Ahrefs Keyword API Request →
x-rapidapi-key: replace the placeholder with your own
- Ahrefs Keyword API Request →
- Click Save.
Test it
- Click Test workflow (or Execute workflow). When chat message received starts it. Trigger it once with real sample data.
- Click each node to check its output. A green tick means the step worked.
- Fix any red node: it's almost always a credential or a field that still points at a sheet or chat that isn't yours.
Go live
Toggle Active (top right). From now on it runs on its own. Check Executions in the left sidebar to see every run.
How it works, step by step
- When chat message received starts the workflow (Chat).
- Google Gemini Chat Model uses AI (Gemini).
- Simple Memory uses AI (Memory Buffer Window).
- Google Gemini Chat Model1 uses AI (Gemini).
- Keyword Query Extraction & Cleaning Agent uses AI (Agent).
- Keyword Data Response Formatter uses AI (Agent).
- Ahrefs Keyword API Request calls an external API (https://ahrefs-keyword-tool.p.rapidapi.com/global-volume).
- Extract Main Keyword & 10 related Keyword data reshapes the data for the next step.
- Aggregate Keyword Data uses Aggregate.
Extra setup notes
These notes are also on the canvas as yellow sticky notes:
Keyword Query Extraction
This ai agent is important so that you always make sure for all queries you send, only the keyword phrase will be passed over to the API request node, and if you misspell any word, it will be corrected.
The API Request
You can tweak this to either get "answer the public kwywords" or "keyword overviews", just visit the api docs page
Extract Keyword Data
The data from the API query will be so so big and I have written this javascript function to extract the most important bits. You can modify it if you want to also get monthly data, or just download the response as pdf and probably pass it for analysis.
Trigger Node
This is just a sample trigger node to get started. You can use a telegram, whatsapp, webhook node etc, to get the keyword queried.
Respose Formatter
The ai agent node to format responses will give you more room to decide how you want your summaries to be sent back to you. You can modify the system message to get your desired outcome. Otherwise, good luck building on top of this. I will give a detailed docs guide on the main n8n workflow page
Troubleshooting
- "Credentials not found": open the node and select your credential again.
- Google "access blocked": in Google Cloud, add your email as a test user on the OAuth consent screen.
- Webhook not firing: copy the node's Production URL (not Test URL) into the other app, and make sure the workflow is Active.
- AI node errors: check your API key has billing enabled and the model name exists on your plan.
- Nothing happens on schedule: the workflow must be Active, and self-hosted n8n must stay running.
Need help?
Reply to your Morning Method order email and we'll help you get it running.
© Morning Method