データとの対話:テキストをSQLクエリおよび可視化グラフに変換

上級

これはEngineering, Product, AI分野の自動化ワークフローで、36個のノードを含みます。主にIf, Set, Merge, Postgres, ConvertToFileなどのノードを使用、AI技術を活用したスマート自動化を実現。 データと対話:テキストをSQLクエリおよび可視化グラフに変換

前提条件
  • PostgreSQLデータベース接続情報
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "mLHcEKvtCu6m9nYi",
  "meta": {
    "instanceId": "1fc85153dfc4ea22a8172f0d7347fa9f591f71e2064dc331f7bdc1d7ee422e7a",
    "templateCredsSetupCompleted": true
  },
  "name": "Conversing with Data: Transforming Text into SQL Queries and Visual Curves",
  "tags": [
    {
      "id": "xSQPh84nO2kyMj3e",
      "name": "Talk to data",
      "createdAt": "2025-02-25T10:55:43.575Z",
      "updatedAt": "2025-02-25T10:55:43.575Z"
    }
  ],
  "nodes": [
    {
      "id": "5207b91b-5a29-4786-93e2-c7ba4bd1d0f1",
      "name": "ウィンドウバッファメモリ",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        340,
        360
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "8571a134-1a79-4858-aa22-82a037a3a5f8",
      "name": "ノーオペレーション(何もしない)",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1080,
        460
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "967fd040-bb82-4e97-a979-b1e91ef54b8f",
      "name": "出力にテーブル名を追加",
      "type": "n8n-nodes-base.set",
      "position": [
        -380,
        -60
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "80d47d3e-476e-43fd-a021-609cdad537c8",
      "name": "ローカルにファイルを保存",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -40,
        -60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8e715321-38a3-4ba6-abac-efe2ad54a039",
      "name": "ファイルからデータを抽出",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -360,
        460
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d0f9eb57-2226-4b4a-b7e7-b09074f5c410",
      "name": "チャットトリガー",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -860,
        460
      ],
      "webhookId": "c308dec7-655c-4b79-832e-991bd8ea891f",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "b05e11f0-f957-4067-85fc-35bded780b59",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        220,
        140
      ],
      "parameters": {},
      "typeVersion": 1.6
    },
    {
      "id": "f91029ec-27e5-4f1d-aec8-711ef5a7e0e4",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -340
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "95f41622-0ff4-4841-a83d-265864599f2f",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -320
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "b12dbb8a-48fe-4627-b209-916191aef4e6",
      "name": "「ワークフローテスト」クリック時",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -900,
        -60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3044a292-9596-40dd-96a5-caeed0204630",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        180
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "a6691f03-8688-4844-85be-b4344e9010bf",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -320
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "002bf810-5408-40a1-a05d-9bdcab64a14c",
      "name": "スキーマデータとチャット入力を結合",
      "type": "n8n-nodes-base.set",
      "position": [
        -120,
        460
      ],
      "parameters": {},
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "64b73d55-e01a-4777-a07c-6fb047d22666",
      "name": "ローカルファイルからスキーマを読み込み",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -620,
        460
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c016cffe-669b-418f-818f-cb3692c7dcdb",
      "name": "SQLクエリを抽出",
      "type": "n8n-nodes-base.set",
      "position": [
        680,
        380
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "3a9d2623-751d-4b62-9fb7-68d5d9c8facf",
      "name": "クエリの存在を確認",
      "type": "n8n-nodes-base.if",
      "position": [
        840,
        380
      ],
      "parameters": {},
      "typeVersion": 2.2
    },
    {
      "id": "552385b5-1086-419d-b0b8-f7fa2479c13f",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        -60
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "4ea865a5-7988-4563-9d5a-a7f4a4f9c31f",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        -60
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "0a25db4f-cc81-46f1-93cb-9e3d4028516d",
      "name": "付箋7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        560
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "66492a65-1553-4286-80ea-d03e631a0995",
      "name": "付箋8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1100,
        -40
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "73839265-f77a-4856-b1fb-b2be7f6ebe27",
      "name": "クエリ結果を整形",
      "type": "n8n-nodes-base.set",
      "position": [
        1180,
        180
      ],
      "parameters": {},
      "executeOnce": true,
      "typeVersion": 3.4
    },
    {
      "id": "e9220e4e-8bdc-48ed-b29b-a2fe124b8b72",
      "name": "最終出力を準備",
      "type": "n8n-nodes-base.set",
      "position": [
        2140,
        580
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "81a292e1-c5e9-40df-a181-66f767c60215",
      "name": "クエリ結果とチャット回答を結合",
      "type": "n8n-nodes-base.merge",
      "position": [
        1880,
        580
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "4a35ebb4-37cb-4a7c-b005-70315c6f684c",
      "name": "データベース内の全テーブルを一覧表示",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -740,
        -60
      ],
      "parameters": {},
      "typeVersion": 2.5
    },
    {
      "id": "22da4137-af07-4c03-9c2d-6b8178571ff4",
      "name": "データをJsonに変換",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -200,
        -60
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "0d7d1e90-224b-4159-8930-4470b140305d",
      "name": "スキーマ抽出ツール",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -560,
        -60
      ],
      "parameters": {},
      "typeVersion": 2.5
    },
    {
      "id": "ddba033b-aca0-42a0-b553-3edf4d93cd1f",
      "name": "最終SQL結果",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1000,
        180
      ],
      "parameters": {},
      "typeVersion": 2.5
    },
    {
      "id": "3c2b1a0d-4a50-44b2-ada9-00d3b23b3c61",
      "name": "フィールド編集",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        180
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "4ad38866-185e-4cd3-b0b0-b1e744d52204",
      "name": "構造化出力パーサー",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1900,
        420
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "744b6680-310b-4a89-a84c-dc59145fe73f",
      "name": "フィールド編集1",
      "type": "n8n-nodes-base.set",
      "position": [
        2120,
        180
      ],
      "parameters": {},
      "typeVersion": 3.4
    },
    {
      "id": "196473ba-78c5-412c-8940-121a0e1f28d2",
      "name": "プロットエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1700,
        180
      ],
      "parameters": {},
      "typeVersion": 1.7
    },
    {
      "id": "9e03e081-0de2-4b8e-bcaa-adc0d2240272",
      "name": "deepseek-chat",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1700,
        380
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "376d0712-00c4-4132-a429-b36234e75316",
      "name": "Deepseek-chat",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        200,
        360
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "43d27038-22c0-41ec-b2b5-507c311b23f1",
      "name": "付箋9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -60
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "c206c591-5826-4285-900a-c082587bfbaa",
      "name": "付箋10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        -40
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "57bbe158-4ddc-4f46-b871-d22735e3f720",
      "name": "付箋11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1260,
        580
      ],
      "parameters": {
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "93ee6099-65dc-47bc-ba35-15f2e22b1412",
  "connections": {
    "b05e11f0-f957-4067-85fc-35bded780b59": {
      "main": [
        [
          {
            "node": "c016cffe-669b-418f-818f-cb3692c7dcdb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "196473ba-78c5-412c-8940-121a0e1f28d2": {
      "main": [
        [
          {
            "node": "744b6680-310b-4a89-a84c-dc59145fe73f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3c2b1a0d-4a50-44b2-ada9-00d3b23b3c61": {
      "main": [
        [
          {
            "node": "196473ba-78c5-412c-8940-121a0e1f28d2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d0f9eb57-2226-4b4a-b7e7-b09074f5c410": {
      "main": [
        [
          {
            "node": "64b73d55-e01a-4777-a07c-6fb047d22666",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "744b6680-310b-4a89-a84c-dc59145fe73f": {
      "main": [
        [
          {
            "node": "81a292e1-c5e9-40df-a181-66f767c60215",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "376d0712-00c4-4132-a429-b36234e75316": {
      "ai_languageModel": [
        [
          {
            "node": "b05e11f0-f957-4067-85fc-35bded780b59",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "9e03e081-0de2-4b8e-bcaa-adc0d2240272": {
      "ai_languageModel": [
        [
          {
            "node": "196473ba-78c5-412c-8940-121a0e1f28d2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "ddba033b-aca0-42a0-b553-3edf4d93cd1f": {
      "main": [
        [
          {
            "node": "73839265-f77a-4856-b1fb-b2be7f6ebe27",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0d7d1e90-224b-4159-8930-4470b140305d": {
      "main": [
        [
          {
            "node": "967fd040-bb82-4e97-a979-b1e91ef54b8f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c016cffe-669b-418f-818f-cb3692c7dcdb": {
      "main": [
        [
          {
            "node": "3a9d2623-751d-4b62-9fb7-68d5d9c8facf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "22da4137-af07-4c03-9c2d-6b8178571ff4": {
      "main": [
        [
          {
            "node": "80d47d3e-476e-43fd-a021-609cdad537c8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "73839265-f77a-4856-b1fb-b2be7f6ebe27": {
      "main": [
        [
          {
            "node": "81a292e1-c5e9-40df-a181-66f767c60215",
            "type": "main",
            "index": 0
          },
          {
            "node": "3c2b1a0d-4a50-44b2-ada9-00d3b23b3c61",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5207b91b-5a29-4786-93e2-c7ba4bd1d0f1": {
      "ai_memory": [
        [
          {
            "node": "b05e11f0-f957-4067-85fc-35bded780b59",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "3a9d2623-751d-4b62-9fb7-68d5d9c8facf": {
      "main": [
        [
          {
            "node": "81a292e1-c5e9-40df-a181-66f767c60215",
            "type": "main",
            "index": 1
          },
          {
            "node": "ddba033b-aca0-42a0-b553-3edf4d93cd1f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "8571a134-1a79-4858-aa22-82a037a3a5f8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8e715321-38a3-4ba6-abac-efe2ad54a039": {
      "main": [
        [
          {
            "node": "002bf810-5408-40a1-a05d-9bdcab64a14c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "967fd040-bb82-4e97-a979-b1e91ef54b8f": {
      "main": [
        [
          {
            "node": "22da4137-af07-4c03-9c2d-6b8178571ff4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4ad38866-185e-4cd3-b0b0-b1e744d52204": {
      "ai_outputParser": [
        [
          {
            "node": "196473ba-78c5-412c-8940-121a0e1f28d2",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "4a35ebb4-37cb-4a7c-b005-70315c6f684c": {
      "main": [
        [
          {
            "node": "0d7d1e90-224b-4159-8930-4470b140305d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b12dbb8a-48fe-4627-b209-916191aef4e6": {
      "main": [
        [
          {
            "node": "4a35ebb4-37cb-4a7c-b005-70315c6f684c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "002bf810-5408-40a1-a05d-9bdcab64a14c": {
      "main": [
        [
          {
            "node": "b05e11f0-f957-4067-85fc-35bded780b59",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "64b73d55-e01a-4777-a07c-6fb047d22666": {
      "main": [
        [
          {
            "node": "8e715321-38a3-4ba6-abac-efe2ad54a039",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "81a292e1-c5e9-40df-a181-66f767c60215": {
      "main": [
        [
          {
            "node": "e9220e4e-8bdc-48ed-b29b-a2fe124b8b72",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - エンジニアリング, プロダクト, 人工知能

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数36
カテゴリー3
ノードタイプ15
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34