An n8n competitor AI-visibility monitor answers the question a mention tracker cannot: when a buyer asks ChatGPT or Gemini for a recommendation, do you win, or does a rival get named first? Knowing you appear 40% of the time means little on its own. Knowing you rank third behind two competitors, and that one of them is named first in almost every answer, is something you can act on. This guide builds a free workflow that runs weekly, sends the same buyer questions to both assistants, scores every brand you name, and emails you a ranked leaderboard with mention counts and average position. It takes about 45 minutes to build, or a couple of minutes with the template at the end.
What it does
Each week the workflow sends a set of neutral buyer prompts, the questions people ask before choosing a product like yours, to Google Gemini and OpenAI’s ChatGPT through their official APIs. For every answer it scans for your brand and each competitor you listed, records who was mentioned, and notes the order they appeared in. Being named first in an answer counts for more than being named last, so the workflow tracks position, not just presence.
It then rolls everything into a leaderboard: one row per brand with Gemini mentions, ChatGPT mentions, total mentions, a mention rate across all answer slots, and an average position. The board is sorted so the brand the assistants recommend most sits on top, with average position breaking ties. That snapshot is appended to Google Sheets, so each brand’s standing trends over time, and the same board arrives in your inbox as a table headed by your own rank.
This is the competitive layer of AEO, answer engine optimization. If you only want to know whether your own brand shows up, the simpler brand-mention tracker is the place to start. This monitor is for when you already know you are in the race and want to see the standings. New to n8n? Begin with how to set up n8n.
Why it beats the default
The default competitive check is to open ChatGPT, ask “what is the best tool for X,” eyeball whether you or a rival shows up, and move on. It is a guess, not a measurement. You cannot tell whether a competitor beats you consistently or you just caught a bad answer, and you have no record to compare against next month.
Paid AEO platforms will build a competitor leaderboard, but they cost a monthly subscription, track a prompt list you do not fully control, and keep the history locked in their tool. This workflow ranks exactly the brands you care about, on the exact buyer questions that matter to your market, across both major assistants, for a few cents a run, and writes the history to a sheet you own. Add a competitor, change a prompt, or plug in a third assistant whenever you like. For more AI workflows you can import, see the best n8n AI agent templates and the full template library.
What you need
- An n8n instance (Cloud or self-hosted, version 1.0 or newer).
- A Google Gemini API key (free tier is fine to start). Used as an HTTP Header Auth credential with header
x-goog-api-key. - An OpenAI API key. Used as an HTTP Header Auth credential with header
Authorizationand valueBearer YOUR_KEY. - A Google account for Sheets and a Gmail account for the report.
- A blank Google Sheet with a header row matching the field names below.
Time: about 45 minutes from scratch, or under 5 minutes with the template.
Node-by-node list
Eight nodes: a schedule, a config node, two AI calls per prompt, a single scorer that builds the leaderboard, and a fork that both logs and emails.
Weekly schedule (Mon 7am)
|
Prompts & brands (Code: you + competitors + prompt list)
|
Ask Gemini ──► Ask ChatGPT
|
Build leaderboard (Code: score + rank every brand)
| |
Log leaderboard to Sheets Build email
|
Send digest email (Gmail)
- Weekly schedule (
Schedule Trigger) fires every Monday at 7am. - Prompts & brands (
Code) holds your brand, competitors, and prompts, one item per prompt. - Ask Gemini (
HTTP Request) sends each prompt to the Gemini API. - Ask ChatGPT (
HTTP Request) sends the same prompt to the OpenAI API. - Build leaderboard (
Code) reads every answer, scores all brands, and outputs one ranked row per brand. - Log leaderboard to Sheets (
Google Sheets) appends the snapshot. - Build email (
Code) formats the board and highlights your rank. - Send digest email (
Gmail) emails you the leaderboard.
Step-by-step build
1. Add the weekly schedule
Add a Schedule Trigger, interval Weeks, every 1 week, day Monday, hour 7. Weekly matches how slowly AI answers shift and keeps API usage tiny.
2. Set your brand, competitors, and prompts
Add a Code node. It emits one item per prompt and carries the full brand list on each item so the scorer can rank everyone.
const YOU = 'Acme Analytics';
const COMPETITORS = ['DataPulse', 'Insightly', 'MetricForge'];
const BRANDS = [YOU, ...COMPETITORS];
const PROMPTS = [
'What are the best analytics tools for a small ecommerce store?',
'Which tools help a SaaS startup track marketing ROI?',
'Recommend affordable business intelligence software for a small team.',
'What is a good tool for automated weekly sales reports?',
'Best alternatives to a spreadsheet for tracking KPIs?'
];
return PROMPTS.map(p => ({ json: { prompt: p, brands: BRANDS, you: YOU } }));
Tip: Pick competitors whose names are distinctive words. A brand called “Pulse” will match inside “impulse” and inflate its score; “DataPulse” will not.
3. Ask Gemini
Add an HTTP Request node, method POST. Under Authentication choose Generic Credential Type then Header Auth, and store your key under the header x-goog-api-key. Set the body to JSON:
URL: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent
JSON body:
={{ JSON.stringify({ contents: [ { parts: [ { text: $('Prompts & brands').item.json.prompt } ] } ] }) }}
Note: Reference $('Prompts & brands').item for the prompt, not $json. After the HTTP call the item becomes the API response, but n8n keeps the original items paired so the reference still resolves.
4. Ask ChatGPT
Add a second HTTP Request node, method POST. Store your OpenAI key under the header Authorization with value Bearer then your key. Body JSON:
URL: https://api.openai.com/v1/chat/completions
JSON body:
={{ JSON.stringify({ model: 'gpt-4o-mini', messages: [ { role: 'user', content: $('Prompts & brands').item.json.prompt } ] }) }}
5. Build the leaderboard
Add a Code node. It runs once for all items, reads every Gemini and ChatGPT answer, and for each brand counts mentions and averages the order it was named. It outputs one ranked row per brand.
const cfgAll = $('Prompts & brands').all().map(i => i.json);
const gem = $('Ask Gemini').all().map(i => i.json);
const oa = $('Ask ChatGPT').all().map(i => i.json);
const brands = cfgAll[0].brands;
const you = cfgAll[0].you;
const N = cfgAll.length;
const txt = v => (v == null ? '' : String(v));
const geminiText = i => txt(gem[i]?.candidates?.[0]?.content?.parts?.[0]?.text);
const openaiText = i => txt(oa[i]?.choices?.[0]?.message?.content);
const stat = {};
for (const b of brands) stat[b] = { brand: b, gemini_mentions: 0, chatgpt_mentions: 0, pos_sum: 0, pos_count: 0 };
function scoreAnswer(text, assistant) {
const lower = text.toLowerCase();
const found = brands
.map(b => ({ b, idx: lower.indexOf(b.toLowerCase()) }))
.filter(x => x.idx >= 0)
.sort((a, b) => a.idx - b.idx);
found.forEach((x, rank) => {
if (assistant === 'gemini') stat[x.b].gemini_mentions++;
else stat[x.b].chatgpt_mentions++;
stat[x.b].pos_sum += (rank + 1);
stat[x.b].pos_count++;
});
}
for (let i = 0; i < N; i++) { scoreAnswer(geminiText(i), 'gemini'); scoreAnswer(openaiText(i), 'chatgpt'); }
const reportDate = new Date().toISOString().slice(0, 10);
const totalSlots = N * 2;
const rows = brands.map(b => {
const s = stat[b];
const total = s.gemini_mentions + s.chatgpt_mentions;
return {
report_date: reportDate, brand: b, is_you: b === you ? 'yes' : 'no',
gemini_mentions: s.gemini_mentions, chatgpt_mentions: s.chatgpt_mentions,
total_mentions: total, mention_rate_pct: Math.round((total / totalSlots) * 100),
avg_position: s.pos_count ? Math.round((s.pos_sum / s.pos_count) * 10) / 10 : ''
};
});
rows.sort((a, b) => b.total_mentions - a.total_mentions || ((a.avg_position === '' ? 99 : a.avg_position) - (b.avg_position === '' ? 99 : b.avg_position)));
return rows.map(r => ({ json: r }));
A leaderboard row looks like this:
{
"report_date": "2026-08-24",
"brand": "DataPulse",
"is_you": "no",
"gemini_mentions": 4,
"chatgpt_mentions": 5,
"total_mentions": 9,
"mention_rate_pct": 90,
"avg_position": 1.3
}
6. Log to Google Sheets and email the board
Add a Google Sheets node (operation Append Row, mapping Map Automatically) with a header row of report_date, brand, is_you, gemini_mentions, chatgpt_mentions, total_mentions, mention_rate_pct, avg_position. Then add a Code node to format the board and a Gmail node (Email Type HTML) mapping the subject and message from it. The email leads with your rank: “You rank #3 of 4 with a 50% mention rate.”
Save and activate. Every Monday you get a standings table you can actually plan against.
Common mistakes
- Naming a brand in the prompt. It rigs the result. Prompts must be neutral buyer questions.
- Short or generic brand names. They match inside other words and inflate scores. Track full, distinctive names and tighten the match to whole words if needed.
- Reading
$jsonfor Gemini in the scorer. After the ChatGPT node,$jsonis the OpenAI item. Pull both answer sets with$('Ask Gemini').all()and$('Ask ChatGPT').all(). - Comparing runs with different prompt lists. Change the prompts and the trend breaks. Lock a core set and only add to it deliberately.
- Mismatched Sheet headers. Automatic mapping needs exact column names, or columns land blank.
Cost at realistic volume
Two API calls per prompt, one Sheets append per brand, one email per run.
| Service | Usage per weekly run (10 prompts, 4 brands) | Cost |
|---|---|---|
| Gemini API (gemini-2.5-flash) | 10 calls | Free tier covers it |
| OpenAI API (gpt-4o-mini) | 10 calls | ~$0.01 / run |
| Google Sheets | 4 row appends | Free |
| Gmail | 1 email | Free |
| n8n | 1 execution / week | Free self-hosted; ~4 executions/month on Cloud |
A competitive AI-visibility leaderboard for a few cents a month. The paid platforms that produce the same board start around fifty dollars a month.
Get the competitor AI-visibility monitor template
The guide above is free to follow. If you would rather skip the build, the ready-to-import template drops all eight nodes and every script onto your canvas. Import it, add your Gemini, OpenAI, Google Sheets, and Gmail credentials, list your competitors and prompts, and your first leaderboard can run today. Want it installed and tuned to your market? Our done-for-you service sets it up end to end.
Instant download · Works on n8n Cloud and self-hosted
Frequently asked questions
How is this different from just tracking whether my brand is mentioned?
A mention tracker answers yes or no for your brand alone. A competitor monitor ranks you against named rivals across the same questions, so you see who wins the recommendation, by how much, and who gets named first. It turns a single data point into a leaderboard you can move up.
What does average position measure?
Within each AI answer, brands are ranked by the order they are named. Average position is the mean of those ranks across every answer where the brand appears. A lower number means the assistant tends to name that brand earlier, which usually means it is the stronger default recommendation.
How many competitors can I track?
As many as you like. Add them to the COMPETITORS list in the config node and they are scored automatically. Five to eight is a practical range; beyond that the leaderboard gets noisy and some brand names start to collide with common words in the answers.
Does it use the real ChatGPT and Gemini?
It calls the official OpenAI and Google Gemini APIs, which run the same models behind the chat apps and are stable to parse. Scraping the chat websites is against their terms and breaks often, so the API is the correct and reliable route for automation.
What prompts give the most useful ranking?
Neutral category questions a buyer would ask before choosing: best tool for X, affordable software for Y, alternatives to a spreadsheet. Never name any brand in the prompt. The whole point is to see which brands the AI raises on its own when asked a fair, open question.
Related guides
- Track brand mentions in ChatGPT and Gemini — the simpler yes/no self-check to start with.
- Best n8n AI agent templates — more AI workflows you can import.
- How to set up n8n — the setup prerequisite if you are starting out.
- Browse all n8n templates.
- More AI agent and chatbot guides.