← All N8N workflows
AI & researchAgentAggregateExecute Workflow TriggerHTTP RequestOpenAI Chat Model

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.

Workflow preview
Data storePostgres Chat MemoryMemory Postgres ChatAI & modelsOpenAI Chat ModelOpenAI Chat ModelTransformSet fieldsEdit FieldsTriggerWebhook - ChatInputWebhookWeb / APIRespond to WebhookRespond To WebhookSubworkflowCall Search ConsoleToolTool WorkflowTriggerTool callingExecute Workflow TriggerRoutingSwitchSwitchTransformSet fields - ConsructAPI CALLEdit FieldsTransformSet fields - CreatesearchConsoleDataArrayEdit FieldsTransformSet fields - CreatesearchConsoleDataArray…Edit FieldsWeb / APISearch Console - GetCustom InsightsHTTP RequestWeb / API## Search Console - GetList of PropertiesHTTP RequestTransformArray aggregation -response to AI AgentAggregateTransformArray aggregation -response to AI Agent1AggregateAI & modelsAI AgentAgent

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.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Postgres Chat MemoryData storeMemory Postgres ChatSee node parameters
OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
Set fieldsTransformEdit FieldsSee node parameters
Webhook - ChatInputTriggerWebhookSee node parameters
Respond to WebhookWeb / APIRespond To WebhookSee node parameters
Call Search Console ToolSubworkflowTool WorkflowSee node parameters
Tool callingTriggerExecute Workflow TriggerSee node parameters
SwitchRoutingSwitchSee node parameters
Set fields - Consruct API CALLTransformEdit FieldsSee node parameters
Set fields - Create searchConsoleDataArrayTransformEdit FieldsSee node parameters
Set fields - Create searchConsoleDataArray 2TransformEdit FieldsSee node parameters
Search Console - Get Custom InsightsWeb / APIHTTP RequestPOST
## Search Console - Get List of PropertiesWeb / APIHTTP RequestSee node parameters
Array aggregation - response to AI AgentTransformAggregateSee node parameters
Array aggregation - response to AI Agent1TransformAggregateSee node parameters
AI AgentAI & modelsAgentSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. 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

  • httpBasicAuth
  • oAuth2Api
  • openAiApi
  • postgres

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 node
  • sessionId: retrieved from the previous webhook node
  • date_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_type field determines the route: website_list (to retrieve the list of websites) or custom_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.

More in AI & research