Category: Automations › SEO, Analytics & Reporting · Best for: Site owners improving SEO · Platform: n8n · Steps: 16
What it does
Ask the AI questions about your Search Console data in plain words.
This webhook serves as the endpoint for receiving ChatInput data. Ensure that you include:
Works with: OpenAI, Memory Postgres Chat, Tool Workflow, 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:
- PostgreSQL database: how to connect (used by Postgres Chat Memory)
- OpenAI API key: how to connect (used by OpenAI Chat Model)
- httpBasicAuth: how to connect (used by Webhook - ChatInput)
- oAuth2Api: how to connect (used by Search Console - Get Custom Insights, ## Search Console - Get List of Properties)
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.
- Click Save.
Test it
- Click Test workflow (or Execute workflow). Webhook - ChatInput 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
- Webhook - ChatInput starts the workflow (Webhook).
- Tool calling starts the workflow (Execute Workflow).
- OpenAI Chat Model uses AI (OpenAI).
- Postgres Chat Memory uses AI (Memory Postgres Chat).
- Call Search Console Tool uses AI (Tool Workflow).
- Set fields reshapes the data for the next step.
- Set fields - Consruct API CALL reshapes the data for the next step.
- AI Agent uses AI (Agent).
- Switch checks a condition and routes items accordingly.
- Respond to Webhook uses Respond To Webhook.
- Search Console - Get Custom Insights calls an external API (=https://www.googleapis.com/webmasters/v3/sites/{{ $json.pro).
- ## Search Console - Get List of Properties calls an external API (=https://www.googleapis.com/webmasters/v3/sites).
- Set fields - Create searchConsoleDataArray reshapes the data for the next step.
- Set fields - Create searchConsoleDataArray 2 reshapes the data for the next step.
- Array aggregation - response to AI Agent uses Aggregate.
- Array aggregation - response to AI Agent1 uses Aggregate.
Extra setup notes
These notes are also on the canvas as yellow sticky notes:
Webhook - ChatInput
This webhook serves as the endpoint for receiving ChatInput data. Ensure that you include:
chatInput– the content you wish to send ()sessionId– a unique identifier for the session
If you're using an interface such as Open WebUI, the sessionId will be generated automatically.
Set fields
This node sets three fields:
chatInput: retrieved from the previous webhook nodesessionId: retrieved from the previous webhook nodedate_message: formatted within this node. This will be used later to help the AI agent determine the date range for retrieving Search Console data.
AI Agent - Tools Agent
This AI Agent is configured with a system prompt that instructs it to:
- On the first user message, retrieve available Search Console properties and offer the user the option to fetch data from these properties
- Based on the user’s natural language input, construct an API call to the selected Search Console property and retrieve the requested data
- Present the data in a markdown-formatted table
The AI Agent has a friendly tone and is designed to confirm the user’s data requirements accurately before executing any API requests.
AI Agent Sub-node - OpenAI Chat Model
This sub-node utilizes the selected OpenAI Chat Model. You can replace it with any LLM that supports tool calling.
Choose Your Model
In this template, the default model is gpt-4o, a costly option. If you'd like a more affordable alternative, select gpt4-o-mini, though note that responses may occasionally be of slightly lower quality compared to gpt-4o.
AI Agent Sub-node - Postgres Chat Memory
Connect your Postgres credentials and specify a table name to store the chat history. In this template, the default table name is insights_chat_histories, and the context window length is set to 5.
** Tip:** If you don’t have a Postgres database, you can quickly set one up with Supabase.
AI Agent Sub-node - Call Search Console Tool
This tool is used by the AI Agent to:
- Retrieve the list of accessible properties in Search Console
- Fetch Search Console data based on the user’s natural language request
Respond to Webhook
This node is used to send a response back to the user.
** Tip:** intermediateSteps are configured, allowing you to use raw data fetched from Search Console to create charts or other visualizations if desired.
Tool Call Trigger
This node is triggered when the AI Agent needs to retrieve the website_list (accessible Search Console properties) or custom_insights based on user data.
Set Fields - Construct API Call
This node configures fields based on the JSON sent by the AI agent:
- The
request_typefield determines the route:website_list(to retrieve the list of websites) orcustom_insights(to get insights from Search Console) - Additional fields are set to construct the API call, following the Search Console API Documentation
Search Console - Get Custom Insights
This node performs the API call to retrieve data from Search Console.
Search Console - Get List of Properties
This node performs the API call to retrieve the list of accessible properties from Search Console.
Set Fields - Create searchConsoleDataArray
These nodes create an array based on the response from the Search Console API.
Array Aggregation - Response to AI Agent
These nodes aggregate the array from the previous step and send it back to the AI Agent through the field named output as response.
AI Agent to Chat with Your Search Console Data
This AI Agent enables you to interact with your Search Console data through a chat interface. Each node is documented within the template, providing sufficient information for setup and usage. You will also need to configure Search Console OAuth credentials.
Follow this n8n documentation to set up the OAuth credentials.
Important Notes
Correctly Configure Scopes for Search Console API Calls
- It’s essential to configure the scopes correctly in your Google Search Console API OAuth2 credentials. Incorrect configuration can cause issues with the refresh token, requiring frequent reconnections. Below is the configuration I use to avoid constant re-authentication:

Of course, you'll need to add your client_id and client_secret from the Google Cloud Platform app you created to access your Search Console data.
Configure Authentication for the Webhook
Since the webhook will be publicly accessible, don’t forget to set up authentication. I’ve used Basic Auth, but feel free to choose the method that best meets your security requirements.
Example of awesome things you can do with this AI Agent

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