AI agent to chat with you Search Console data, using OpenAI and Postgres
Needs changesWhat this workflow does
This AI workflow has 16 nodes and runs when an HTTP POST request hits its webhook URL (plus 1 other trigger). Along the way it connects Postgres Chat Memory and OpenAI Chat Model.
How it runs
Trigger: When an HTTP POST request hits its webhook URL (plus 1 other trigger).
- Set fields (Edit Fields (Set)): sets 3 fields: chatInput, sessionId, date_message
- Set fields - Consruct API CALL (Edit Fields (Set)): sets 7 fields: request_type, start_date, end_date…
- AI Agent: runs an AI agent, with model: OpenAI Chat Model; 1 tool (Call Search Console Tool); memory: Postgres Chat Memory
- Switch: routes items into 2 branches
- Respond to Webhook: sends the response back to the webhook caller
- Search Console - Get Custom Insights (HTTP Request): calls an HTTP API (POST)
- ## Search Console - Get List of Properties (HTTP Request): calls an HTTP API
- Set fields - Create searchConsoleDataArray (Edit Fields (Set)): sets 1 field: searchConsoleData
- Set fields - Create searchConsoleDataArray (Edit Fields (Set)): sets 1 field: searchConsoleData
- Array aggregation - response to AI Agent (Aggregate): combines items into one
…plus 1 more step. See the full node list below.
Services it uses
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in AI Agent (v1.6): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) AI Agent (v1.6) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (11)
- Postgres Chat Memory
@n8n/n8n-nodes-langchain.memoryPostgresChat - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Edit Fields (Set)
n8n-nodes-base.set - Webhook
n8n-nodes-base.webhook - Respond to Webhook
n8n-nodes-base.respondToWebhook - Call n8n Workflow Tool
@n8n/n8n-nodes-langchain.toolWorkflow - Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - Switch
n8n-nodes-base.switch - HTTP Request
n8n-nodes-base.httpRequest - Aggregate
n8n-nodes-base.aggregate - AI Agent
@n8n/n8n-nodes-langchain.agent
From the author
Edit 19/11/2024: As explained on the workflow, the AI Agent with the original system prompt was not effective when using gpt4-o-mini. To address this, I optimized the prompt to work better with this model. You can find the prompts I’ve tested on this Notion…