AI Agent to chat with you Search Console Data, using OpenAI and Postgres
Configured with Agent, Aggregate, Execute Workflow Trigger, HTTP Request, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- Data store
- AI & models
- Transform
- Trigger
- Web / API
- Subworkflow
- Routing
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| Postgres Chat Memory | Data store | Memory Postgres Chat | See node parameters |
| OpenAI Chat Model | AI & models | OpenAI Chat Model | See node parameters |
| Set fields | Transform | Edit Fields | See node parameters |
| Webhook - ChatInput | Trigger | Webhook | See node parameters |
| Respond to Webhook | Web / API | Respond To Webhook | See node parameters |
| Call Search Console Tool | Subworkflow | Tool Workflow | See node parameters |
| Tool calling | Trigger | Execute Workflow Trigger | See node parameters |
| Switch | Routing | Switch | See node parameters |
| Set fields - Consruct API CALL | Transform | Edit Fields | See node parameters |
| Set fields - Create searchConsoleDataArray | Transform | Edit Fields | See node parameters |
| Set fields - Create searchConsoleDataArray 2 | Transform | Edit Fields | See node parameters |
| Search Console - Get Custom Insights | Web / API | HTTP Request | POST |
| ## Search Console - Get List of Properties | Web / API | HTTP Request | See node parameters |
| Array aggregation - response to AI Agent | Transform | Aggregate | See node parameters |
| Array aggregation - response to AI Agent1 | Transform | Aggregate | See node parameters |
| AI Agent | AI & models | Agent | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
httpBasicAuthoAuth2ApiopenAiApipostgres
Workflow notes
Webhook - ChatInput
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
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
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
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
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
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
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
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
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
Search Console - Get Custom Insights
This node performs the API call to retrieve data from Search Console.
Search Console - Get List of Properties
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`
Set Fields - Create searchConsoleDataArray
These nodes create an array based on the response from the Search Console API.
Array Aggregation - Response to AI Agent
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
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
AI Agent to chat with you Search Console Data, using OpenAI and Postgres
AI Agent to chat with you Search Console Data, using OpenAI and Postgres
Purpose and structure
This folder contains the AI Agent to chat with you Search Console Data, using OpenAI and Postgres workflow. Its executable nodes use agent, aggregate, executeWorkflowTrigger, httpRequest, lmChatOpenAi, memoryPostgresChat, respondToWebhook, set, switch, toolWorkflow, webhook. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
Webhook - ChatInput, Tool calling
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Webhook/1252_Webhook_Respondtowebhook_Automation_Webhook.json MIT; preserve source notices.