Automate Search Console Queries with AI & n8n Integration

Struggling to analyze Google Search Console data quickly? This n8n workflow uses AI and PostgreSQL to chat with your Search Console data, enabling instant custom insights without manual API calls.
agent
lmChatOpenAi
memoryPostgresChat
+7
Workflow Identifier: 2251
NODES in Use: webhook, set, memoryPostgresChat, lmChatOpenAi, agent, respondToWebhook, executeWorkflowTrigger, switch, httpRequest, aggregate
Automate Search Console with n8n and AI

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

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow helps users ask questions about Google Search Console data using simple chat messages. It solves the problem of spending hours manually pulling reports and filtering data. The result is fast answers in table format through a chat interface, saving time and effort.

The user sends a chat message with their question and a session ID to a secure webhook. The workflow keeps track of the conversation using a Postgres database. It then uses AI (OpenAI GPT-4) to understand the user’s question and makes Search Console API calls. The data is returned as easy-to-read markdown tables in the chat reply.


Tools and Services Used

  • Google Search Console API: Provides website search data and performance metrics.
  • OpenAI GPT-4o model: Understands natural language queries and generates responses.
  • PostgreSQL Database: Stores chat history for remembering context across messages.
  • n8n Automation Platform: Runs the workflow nodes handling webhook, API calls, and AI processing.
  • Basic Authentication: Secures the webhook receiving chat messages.

How This Workflow Works

Inputs

  • User sends a POST request to the Webhook node with two fields: chatInput (the question) and sessionId (unique conversation ID).
  • The webhook requires Basic Authentication for security.

Processing Steps

  • Set node extracts the chatInput and sessionId fields and adds the current date as date_message.
  • Postgres Chat Memory node loads and saves conversation history in the PostgreSQL table insights_chat_histories. This keeps the chat context for the AI.
  • OpenAI Chat Model node runs the GPT-4o model to understand and generate replies from the user’s words and memory.
  • AI Agent node uses a system prompt that guides the AI to dynamically build API calls to Google Search Console based on questions. The prompt also instructs the AI to reply with markdown tables for readability.
  • The AI agent can call tools (like getting the website list or insights) through a separate Execute Workflow Trigger node. This node parses the AI’s request details.
  • A Switch node routes API calls based on the request type: either listing Search Console properties or querying analytics data.
  • HTTP Request nodes call the Google Search Console API endpoints authorized with OAuth 2.0 credentials.
  • Set nodes format the JSON API responses into arrays called searchConsoleData.
  • Aggregate nodes combine the result arrays into a single field named response, which is sent back to the chat interface with Respond to Webhook node.

Outputs

  • The user receives a JSON reply containing markdown tables summarizing the Search Console data.
  • The chat memory is updated to keep conversation context for future questions.

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

Importing the Workflow

  1. Download the workflow file using the Download button on this page.
  2. In n8n editor, click on “Import from File” and select the downloaded workflow.

Configuring Credentials

  1. Add Google Search Console OAuth2 credentials with required scopes.
  2. Add your OpenAI API Key with access to the GPT-4o model.
  3. Connect the PostgreSQL database credentials for the Postgres Chat Memory node.

Updating Settings

  1. In the Set node that maps chat inputs, confirm the incoming JSON fields match your client structure.
  2. Verify the PostgreSQL table named insights_chat_histories exists and has proper read/write permissions.
  3. If the workflow has any placeholders like property URLs or session ID formats, update them accordingly.
  4. Check Basic Auth credentials on the Webhook node for security settings and update your client calls to include them.

Testing and Activation

  1. Run the workflow manually by sending a POST request with sample chatInput and sessionId to the webhook URL.
  2. Confirm the workflow returns data as markdown tables in the response.
  3. Activate the workflow by switching it ON in n8n for production use.
  4. Consider using self-host n8n for full control and better security in your production environment.

Customization Ideas

  • Switch the OpenAI Chat Model node to a smaller GPT-4o-mini model to save cost, trading small quality loss.
  • Adjust how many past messages the PostgreSQL chat memory stores to make conversations longer or shorter.
  • Add more Search Console dimensions like “device”, “country”, or “searchAppearance” in the API call Set node for richer insights.
  • Change webhook authentication method from Basic Auth to OAuth or API key based on your security needs.
  • Enhance the AI’s reply formatting by adding charts or different markdown styles using the Respond to Webhook node options.

Troubleshooting

Invalid OAuth token or frequent re-authentication

This usually happens when the Google OAuth client lacks the correct scopes, especially the Search Console scope https://www.googleapis.com/auth/webmasters.readonly.

Review your Google Cloud OAuth settings and update scope. Renew tokens if needed.

No data received or empty Search Console responses

Often caused by wrong date formats, wrong property URLs, or wrong dimension arrays in the API body.

Make sure dates use YYYY-MM-DD format, dimensions are correct arrays, and property URLs exactly match those from the list API.

AI agent giving unclear or wrong answers

Check that the AI Agent’s system prompt includes clear instructions for interpreting queries and calling tools.

Ensure the Postgres Chat Memory node is connected properly so that conversation context is remembered.


Summary & Results

✓ Save hours weekly by automating Search Console data queries via chat.
✓ Reduce manual errors by automating input parsing and API calls.
✓ Get easy-to-understand data output as markdown tables.
→ The workflow handles user questions, remembers context, and returns dynamic data.
→ This makes SEO data accessible for non-technical users without coding or complex queries.


Automate Search Console with n8n and AI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Google OAuth2 credentials with scope https://www.googleapis.com/auth/webmasters.readonly are required for API access.
The workflow stores chat history in a PostgreSQL database table called insights_chat_histories to maintain conversation context.
Yes, the OpenAI Chat Model node can be switched to a smaller GPT-4o-mini or GPT-3 model to save cost with some quality trade-off.
The AI agent uses system prompts and tool calling to dynamically build API requests that fetch property lists or analytics data through Google Search Console API.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.