Sync PostgreSQL with OpenAI Chat for Data Management Automation

Automate data retrieval from PostgreSQL and enrich insights using OpenAI GPT through an AI Chat interface. Ideal for data management professionals seeking streamlined operations. Requires 2 accounts: PostgreSQL and OpenAI API. Save hours of manual data handling and enhance decision-making with real-time insights.

Chat Trigger
103,851 views5 nodesFeb 2024Maya Johnson

Categories

Internal WikiAI RAG

AI Features

AI AgentOpenAI GPTAI Chat

Credentials

2 required

Quick Actions

Copy or download to import into your n8n instance

Workflow JSON
{
  "meta": {
    "instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d08a2559-17fd-4bdb-a976-795c3823a88a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        240
      ],
      "parameters": {
        "content": "## Try me out\nClick the 'chat' button at the bottom of the canvas and paste in:\n\n_Which tables are available?_"
      },
      "typeVersion": 1
    },
    {
      "id": "3019b559-6100-4ead-8e1a-a7dece2a6982",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        -60
      ],
      "parameters": {
        "color": 7,
        "width": 677,
        "height": 505,
        "content": "This workflow uses a Postgres DB, but you could swap it for a MySQL or SQLite one"
      },
      "typeVersion": 1
    },
    {
      "id": "73786411-5383-4921-82ee-06b3b582bab7",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -320,
        40
      ],
      "webhookId": "1c0d08f0-abd0-4bdc-beef-370c27aae1a0",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "e65a1558-e0c0-4c4a-a306-90dc6dcb618a",
      "name": "Postgres",
      "type": "n8n-nodes-base.postgresTool",
      "position": [
        140,
        260
      ],
      "parameters": {
        "query": "{{ $fromAI('sql_statement') }}",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "elRn5sxKOfCdlEs6",
          "name": "Postgres account"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "9df537e7-3ca2-4e72-bc85-ae0d944fbdd1",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        0,
        260
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "57b2b959-9f25-475f-b6bb-842139725411",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -100,
        40
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.8
    },
    {
      "id": "f21ac2dc-56ff-4ea6-a29e-168e7dfaf3fa",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -160,
        260
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8gccIjcuf3gvaoEr",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "pinData": {},
  "connections": {
    "Postgres": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Related Workflows

Automate Document Insights with Google Drive & Gemini AI

Harness the Google Drive API and Google Gemini to extract actionable insights from your company documents. This workflow is designed for business teams looking to streamline document analysis. Requires 4 accounts: Pinecone API, Google Palm API, Google Drive OAuth, and more. Save hours on document processing, enabling your team to focus on strategic initiatives and decision-making.

159,618 views
Internal WikiAI RAG

Automate Google Sheets Data Entry with OpenAI AI Agent

Streamline your data management by automating data entry into Google Sheets using OpenAI's powerful AI Chat and Agent. Perfect for teams looking to optimize their workflows with AI-driven insights. Requires 2 accounts: OpenAI API and Google Sheets OAuth. Save hours of manual data entry while enhancing accuracy and productivity!

148,282 views
Internal WikiAI Chatbot

Automate AI Chat Responses with Google Drive & Pinecone API

Leverage the Google Drive API to store and manage AI chat interactions, utilizing Pinecone's Vector Storage for optimized data retrieval. This workflow is ideal for AI-powered automation users looking to streamline communication processes. Requires 3 accounts: Pinecone API, Google Drive OAuth, and OpenAI API. Save up to 5 hours per week handling customer queries efficiently with AI-driven responses.

128,792 views
Internal WikiAI RAG

Sync OpenAI GPT with Google Drive Using Vector Storage

Automate data retrieval from Google Drive using the Google Drive API, enrich it with AI embeddings from OpenAI GPT, and store vectors in Pinecone's Vector Database. Ideal for AI-powered automation users looking to streamline workflows. Requires 3 accounts: Pinecone API, OpenAI API, Google Drive OAuth. Save hours on data management while enhancing decision-making with AI-driven insights.

104,829 views
Document ExtractionAI RAG

How to Use This Workflow

1Import to n8n

  1. Copy the JSON using the button above
  2. Open your n8n instance
  3. Click “Import workflow” or press Ctrl+V
  4. Paste the JSON and click “Import”

2Before Running

Configure credentials and update service-specific settings before executing the workflow. Review required credentials in the Technical Details section above.

103.9K