AutomationFlowsAI & RAG › Store AI Chat Conversations with Openai Gpt-4.1-mini and Pinecone

Store AI Chat Conversations with Openai Gpt-4.1-mini and Pinecone

ByDoc Williams @the17thhokage on n8n.io

How it works Chat input triggers the workflow when a user sends a message. The primary AI Agent processes the incoming message using OpenAI's Chat Model to generate intelligent responses. Context is retrieved from an assistant service using the "Get context from Assistant" node…

Chat trigger trigger★★★☆☆ complexityAI-powered11 nodesAgentOpenAI ChatChat Trigger@Pinecone Database/N8N Nodes Pinecone AssistantHTTP Request
AI & RAG Trigger: Chat trigger Nodes: 11 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #13091 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "0HTVSt0K7UA8O6hK",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Chat Agent with Database History Logging",
  "tags": [],
  "nodes": [
    {
      "id": "d85a5354-ce56-4ea2-8d40-9c772f7d22c1",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1248,
        816
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful assistant. Use the Pinecone Assistant Tool to retrieve data about Pinecone releases. Include the file name and file url in citations wherever referenced in output."
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e2f52b9b-d77e-4abe-baa5-66d724f1e138",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1248,
        1056
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "416735b3-c8e9-4546-be09-a6a4a352df6b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        720
      ],
      "parameters": {
        "color": 7,
        "width": 1344,
        "height": 576,
        "content": "## AI Chat Agent with Database History Logging"
      },
      "typeVersion": 1
    },
    {
      "id": "e648c838-8f21-41ee-8091-a4536e149c8f",
      "name": "Chat input",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        848,
        816
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "4ba50df2-022a-4cce-a33c-b3651489b26c",
      "name": "Get context from Assistant",
      "type": "@pinecone-database/n8n-nodes-pinecone-assistant.pineconeAssistantTool",
      "position": [
        1456,
        1024
      ],
      "parameters": {
        "assistantData": "{\"name\":\"n8n-assistant\",\"host\":\"https://prod-1-data.ke.pinecone.io\"}",
        "additionalFields": {
          "topK": 16,
          "sourceTag": "n8n:n8n_nodes_pinecone_assistant:quickstart",
          "snippetSize": 2048
        }
      },
      "credentials": {
        "pineconeAssistantApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b62f3294-cea5-41bd-965f-c7822af5aabf",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        1904
      ],
      "parameters": {
        "width": 1088,
        "height": 736,
        "content": "## Who is this for?\nThis workflow is designed for developers and businesses building AI-powered chat applications who need to track and store conversation history. It's ideal for:\n\n* Customer support teams implementing AI chatbots\n* Product teams testing AI agent interactions\n* Developers building conversational AI systems with audit trails\n* Anyone needing persistent chat history for analysis or compliance\n\n## What problem is this workflow solving?\nMany AI chat implementations lack proper conversation tracking and database storage. This workflow solves the challenge of capturing chat interactions while maintaining context through AI agents, providing a complete solution for conversational AI with persistent history storage. This is essential for:\n\n* Analyzing customer interactions and improving AI responses\n* Maintaining conversation history across sessions\n* Building searchable chat archives\n* Ensuring data compliance and audit capabilities\n* Training and improving AI models with real conversation data\n\n## What this workflow does\nThis workflow creates an end-to-end AI chat system that:\n\n1. Accepts chat input through a trigger node\n2. Processes conversations using an AI Agent powered by OpenAI Chat Model for intelligent responses\n3. Retrieves contextual information from Pinecone Assistant to enhance responses\n4. Formats and structures the conversation data\n5. Stores chat history to a database via POST endpoint for persistence and analysis\n\nThe workflow maintains conversation context while ensuring all interactions are properly logged and stored for future reference."
      },
      "typeVersion": 1
    },
    {
      "id": "d521cc58-35ea-4cbf-8aa0-e1f5b8c0dfa7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        608
      ],
      "parameters": {
        "width": 592,
        "height": 608,
        "content": "## Setup Requirements\n\n### Prerequisites\n\n* A [Pinecone account](https://app.pinecone.io/) and [API key](https://app.pinecone.io/organizations/-/projects/-/keys)\n* An [OpenAI account](https://auth.openai.com/create-account) and [API key](https://platform.openai.com/settings/organization/api-keys)\n* A database with REST API endpoint (e.g., Supabase, Airtable, or custom backend)\n\n### Setup Steps\n\n1. **Configure Chat Input**: Set up the Chat Trigger node with your preferred entry point\n\n2. **Add OpenAI Credentials**: Click the OpenAI Chat Model node and add your OpenAI API credentials\n\n3. **Configure Pinecone Assistant**: \n   - Add your Pinecone Assistant credentials\n   - Update the assistant data with your assistant name and host URL\n\n4. **Set Database Endpoint**: In the \"Posting Responses to DB\" HTTP Request node, replace `https://your-database-api.com/endpoint` with your actual database API endpoint\n\n5. **Add Database Authentication** (if required): Add authentication headers in the HTTP Request node\n\n6. **Customize Response Format**: Adjust the \"Formatting Answers\" node to match your desired output structure\n\n7. **Test the Workflow**: Use the chat interface to test the complete flow"
      },
      "typeVersion": 1
    },
    {
      "id": "abec7d7e-6ea5-4883-b288-a9acd3c133b5",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        1264
      ],
      "parameters": {
        "width": 592,
        "height": 576,
        "content": "## How to customize this workflow\n\n### Database Integration\n* Replace the POST endpoint URL with your database API (Supabase, Airtable, Firebase, etc.)\n* Modify the \"Formatting Answers\" node to match your database schema\n* Add authentication headers as needed (API keys, Bearer tokens, etc.)\n\n### AI Agent Behavior\n* Adjust system prompts in the AI Agent node to match your use case\n* Configure temperature and other model parameters for response style\n* Switch between different OpenAI models (GPT-4, GPT-3.5-turbo, etc.)\n\n### Context Retrieval\n* Customize the Pinecone Assistant settings (topK, snippetSize) for optimal context\n* Add additional context sources or knowledge bases\n* Implement conversation memory with user profiles\n\n### Extended Functionality\n* Add sentiment analysis nodes to track conversation tone\n* Implement notification triggers for specific keywords or intents\n* Add branching logic for different conversation flows\n* Include analytics nodes to track metrics like response time and satisfaction"
      },
      "typeVersion": 1
    },
    {
      "id": "ce38f4ba-4773-4064-abd6-ed99be873e74",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        464
      ],
      "parameters": {
        "width": 528,
        "height": 240,
        "content": "## Related Resources\n\n### Video Tutorial\n[Setup So Easy It Feels Like Cheating: NEW Pinecone Assistant with n8n](https://youtu.be/ZWBn_OxellE)\n\n### Example App\n[Lovable Prompt for App Reviewer](https://swiy.co/prompt-volume-app-revewer)\n\n### Helpful Links\n* [n8n AI Agents Documentation](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/)\n* [Pinecone Assistant Guide](https://docs.pinecone.io/guides/assistant/understanding-assistant)\n* [OpenAI API Documentation](https://platform.openai.com/docs/)"
      },
      "typeVersion": 1
    },
    {
      "id": "7b331760-ded2-424e-8246-eb16b220bc9d",
      "name": "Posting Responses to DB",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1632,
        816
      ],
      "parameters": {
        "url": "https://your-database-api.com/endpoint",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "conversation_data",
              "value": "={{ $json }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "dc08fda1-e711-4f81-b2f9-12f15183aa01",
      "name": "Formatting Answers",
      "type": "n8n-nodes-base.set",
      "position": [
        1888,
        816
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e87ba133-eb68-4a8b-9904-fcb420854e60",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "a2b8c4d5-f123-45e6-7890-1a2b3c4d5e6f",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "80a721d5-e93c-4162-83dc-b537fccce095",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Posting Responses to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat input": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Posting Responses to DB": {
      "main": [
        [
          {
            "node": "Formatting Answers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get context from Assistant": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

How it works Chat input triggers the workflow when a user sends a message. The primary AI Agent processes the incoming message using OpenAI's Chat Model to generate intelligent responses. Context is retrieved from an assistant service using the "Get context from Assistant" node…

Source: https://n8n.io/workflows/13091/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow transforms your n8n instance into a fully automated AI sales assistant for WooCommerce stores. It detects customer intent from chat, searches products, answers FAQs, generates Stripe pay

Chat Trigger, Memory Buffer Window, Information Extractor +13
AI & RAG

Airbnb Guest Assistant. Uses lmChatOpenAi, googleDrive, documentDefaultDataLoader, textSplitterCharacterTextSplitter. Chat trigger; 26 nodes.

OpenAI Chat, Google Drive, Document Default Data Loader +11
AI & RAG

OpenAI Personal Shopper with RAG and WooCommerce. Uses chatTrigger, memoryBufferWindow, toolCalculator, lmChatOpenAi. Chat trigger; 25 nodes.

Chat Trigger, Memory Buffer Window, Tool Calculator +11
AI & RAG

OpenAI Personal Shopper with RAG and WooCommerce. Uses chatTrigger, memoryBufferWindow, toolCalculator, lmChatOpenAi. Chat trigger; 25 nodes.

Chat Trigger, Memory Buffer Window, Tool Calculator +11
AI & RAG

This workflow combines OpenAI, Retrieval-Augmented Generation (RAG), and WooCommerce to create an intelligent personal shopping assistant. It handles two scenarios: Product Search: Extracts user inten

Chat Trigger, Memory Buffer Window, Tool Calculator +11