AI Agent: Chat with Google Search Console Data via OpenAI & Postgres
Integrates with:
Overview
Unlock Conversational SEO Insights with this AI Agent\nThis AI Agent transforms how you interact with your Google Search Console data. Instead of navigating complex dashboards, simply chat with the agent in natural language. It leverages OpenAI's GPT models (e.g., GPT-4o) to understand your requests, intelligently constructs the necessary API calls to Google Search Console, fetches the required SEO data, and presents it clearly. Your conversation history is maintained using a PostgreSQL database, allowing for contextual follow-up questions and a continuous analytical dialogue.\n\nThis AI Agent has two main abilities:\n1. List Accessible Properties: On your first interaction, it will retrieve and display the list of Google Search Console properties you have access to.\n2. Fetch Custom Insights: Based on your natural language prompts (e.g., "Show me top pages for example.com for the last 7 days"), it will get detailed performance data, like clicks, impressions, CTR, and position, for specified dimensions (pages, queries, devices, etc.) and date ranges. Data is returned in a markdown table.\n\n### Key Features & Benefits\n* Conversational Data Access: Query your Google Search Console data using everyday language. No need to learn specific GSC query syntax or navigate the GSC interface for common requests.\n* AI-Powered Interpretation: Utilizes OpenAI (configurable, e.g., GPT-4o, GPT-4o-mini) to understand user intent and translate it into precise Search Console API requests through structured tool calls.\n* Automated SEO Data Retrieval: Fetches website lists and custom insights (performance by page, query, device, country, etc.) directly from Google Search Console.\n* Persistent Chat Memory: Remembers previous interactions via PostgreSQL (default table insights_chat_histories
), enabling more natural and context-aware conversations over time. Context window length is configurable.\n* Clear Data Presentation: Delivers fetched data in easy-to-read markdown tables directly in the chat response.\n* Guided Interaction: The agent is designed to first list available Search Console properties and then guide the user through specifying their data needs, confirming assumptions before execution.\n* Tool-Based Architecture: Employs an n8n tool (SearchConsoleRequestTool
) to dynamically call Search Console functionalities, making the agent robust and extensible.
Use Cases
- B2C E-commerce: Quickly ask "What were my top 10 performing landing pages last month for brand X?" to inform content strategy.
- B2B SaaS: Conversationally retrieve query performance for specific SaaS features, e.g., "Show me queries related to 'integration API' for example.com over the last quarter."
- Solopreneurs & Founders: Easily track website SEO performance by asking for weekly summaries or specific keyword rankings without deep GSC dives.
- Marketing Teams: Streamline SEO reporting by asking the agent for specific data points (e.g., clicks and impressions for a campaign-tracked URL) for presentations.
- CTOs & Heads of Automation: Provide a simple, AI-driven interface for teams to access SEO data, reducing reliance on specialized SEO tools or personnel for basic queries.
Prerequisites
- An n8n instance (Cloud or self-hosted).\n- OpenAI API Key with access to a suitable model (e.g., gpt-4o or gpt-4o-mini, models must support tool calling).\n- Google Search Console OAuth2 credentials. Ensure scopes
https://www.googleapis.com/auth/webmasters.readonly
andhttps://www.googleapis.com/auth/webmasters
are enabled in your Google Cloud Platform project for the OAuth consent screen and credentials.\n- PostgreSQL database credentials and a target database. The workflow will attempt to create the specified table (e.g.,insights_chat_histories
) if it doesn't exist.\n- Basic Authentication credentials configured for the n8n webhook if you want to protect the endpoint.
Setup Instructions
- Download the n8n workflow JSON file (
PoiRk5w0xd1ysq4U.json
).\n2. Import the workflow into your n8n instance.\n3. Webhook Configuration: In the 'Webhook - ChatInput' node, configure the 'Authentication' (e.g., Basic Auth) and note down the Webhook URL. This URL will be your chat endpoint.\n4. OpenAI Configuration: In the 'OpenAI Chat Model' node, select your OpenAI credential and choose your desired model (e.g.,gpt-4o
). The default isgpt-4o
;gpt-4o-mini
is a more affordable option.\n5. PostgreSQL Chat Memory: In the 'Postgres Chat Memory' node, select your PostgreSQL credentials and specify atableName
(default isinsights_chat_histories
). The workflow will store conversation history here.\n6. Google Search Console Credentials: \n * Create OAuth2 credentials in Google Cloud Platform for the Search Console API. Ensure you add the scopes:https://www.googleapis.com/auth/webmasters.readonly
andhttps://www.googleapis.com/auth/webmasters
. Refer to n8n documentation for setting up Google OAuth generic credentials.\n * In the 'Search Console - Get Custom Insights' (HTTP Request) node, select or create your Google Search Console OAuth2 credential.\n * In the '## Search Console - Get List of Properties' (HTTP Request) node, select or create the same Google Search Console OAuth2 credential.\n7. AI Agent System Prompt: Review the system prompt in the 'AI Agent' node. It defines how the agent behaves, including its initial actions and how it processes requests. Customize if needed.\n8. Tool Configuration: The 'Call Search Console Tool' node is pre-configured to call the workflow itself to execute Search Console tasks. Typically, no changes are needed here after import.\n9. Activate the workflow.\n10. To interact with the agent, send a POST request to the webhook URL. The body should be JSON, for example:{"chatInput": "your question here", "sessionId": "unique_session_id_123"}
. ThesessionId
is crucial for maintaining conversation context.
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation