AutomationFlowsAI & RAG › AI Chatbot with OpenAI Agent

AI Chatbot with OpenAI Agent

Original n8n title: N8n2api(no Memory)

n8n2API(No memory). Uses chatTrigger, httpRequest, lmChatOpenAi, agent. Chat trigger; 19 nodes.

Chat trigger trigger★★★★☆ complexityAI-powered19 nodesChat TriggerHTTP RequestOpenAI ChatAgentMemory Buffer Window
AI & RAG Trigger: Chat trigger Nodes: 19 Complexity: ★★★★☆ AI nodes: yes Added:

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
{
  "name": "n8n2API(No memory)",
  "nodes": [
    {
      "parameters": {
        "public": true,
        "options": {
          "allowFileUploads": true
        }
      },
      "id": "9768a023-d488-4cdf-8407-5a0b187c4073",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1100,
        300
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "path": "v1/models",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "f0f3f61a-c056-48d6-bc3c-027bb717687f",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        1880,
        300
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "url": "https://api.72live.com/v1/models",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>"
            }
          ]
        },
        "options": {}
      },
      "id": "aee1cb92-7fd5-4f3a-923a-a953fec33d6f",
      "name": "OpenAI Models",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2100,
        300
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "v1/chat/completions",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "8c8cda9e-3009-43df-86af-6f10dad15c23",
      "name": "POST ChatCompletions",
      "type": "n8n-nodes-base.webhook",
      "position": [
        1100,
        940
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// === Code \u8282\u70b9\u4ee3\u7801: \u7248\u672c B ===\n// \u6cbf\u7528\u4f60\u539f\u6765\u7684\u51fd\u6570\u5b9a\u4e49\nfunction tranformContent(content) {\n // \u5b89\u5168\u5904\u7406: \u5982\u679c content \u662f null \u6216 undefined\uff0c\u8fd4\u56de\u7a7a\u6570\u7ec4\n  if (content == null) return [];\n  \n  // \u517c\u5bb9 content \u662f string \u548c content \u662f [{type:\"text\", text:\"\"}, {type:\"image_url\",...}] \u7684\u60c5\u51b5\n  const contentArray = [].concat(content);\n\n  return contentArray.map(item => {\n     // \u5982\u679c\u4f20\u5165\u7684 content \u662f \"string\" \u6216\u6570\u7ec4\u5143\u7d20\u662f \"string\"\n    if (typeof item === 'string') {\n      return { type: \"input_text\", text: item };\n    }\n     // \u5982\u679c content \u5df2\u7ecf\u662f\u5bf9\u8c61 {type:..., text:...} \u6216 {type: 'image_url', image_url: {url:..}}\n     if(typeof item === 'object' && item !== null && item.type){\n        // \u5904\u7406\u6587\u672c\n        if(item.type === 'text'){\n            return { type: \"input_text\", text: item.text || \"\" };\n        }\n        // \u5904\u7406\u56fe\u7247 (\u6ce8\u610f\uff1a\u4f60\u7684\u539f\u59cb\u903b\u8f91\u91cc item.type === 'image_url' \u65f6\u7684 key \u62fc\u88c5, \u786e\u4fdd\u76ee\u6807API\u63a5\u53d7\uff01)\n        // \u539f\u59cb\u903b\u8f91\uff1a { type: getInputType(item.type), [item.type]: item[item.type].url }\n        // \u5982\u679c item = { type: 'image_url', image_url: { url: 'http..' } }\n        // \u7ed3\u679c\u662f\uff1a { type: 'input_image', 'image_url': 'http..' } <-- \u786e\u8ba4\u8fd9\u662f\u76ee\u6807API\u8981\u7684\u683c\u5f0f\n         if(item.type === 'image_url' && item.image_url?.url){\n             return { type: getInputType(item.type), [item.type]: item[item.type].url  } // \u4fdd\u6301\u4f60\u7684\u903b\u8f91\n         }\n        // \u589e\u52a0\u5176\u4ed6\u7c7b\u578b\u7684\u5904\u7406\u6216\u8fd4\u56de\u7a7a/\u9ed8\u8ba4\n         return { type: \"input_text\", text: `[Unsupported content type: ${item.type}]`}; //\u6216\u8fc7\u6ee4\u6389 filter\n\n     }\n    return null; // \u65e0\u6548\u9879\n  }).filter(Boolean); // \u8fc7\u6ee4\u6389 null \u9879\n\n};\n\n// \u6cbf\u7528\nfunction getInputType(type) {\n  if (type === 'image_url') return 'input_image';\n  if (type === 'file_url') return 'input_file';\n   // OpenAI standard client uses \"text\", map it to your target \"input_text\"\n  if (type === 'text') return 'input_text'; \n  return 'input_text';\n}\n\n\n// --- \u6838\u5fc3\u4fee\u6539\u4ece\u8fd9\u91cc\u5f00\u59cb ---\n\n// \u5047\u8bbe\u8f93\u5165\u6570\u636e\u6765\u81ea\u4e0a\u4e00\u4e2a\u8282\u70b9 (Webhook \u8282\u70b9)\n// \u8bf7\u4ece\u5de6\u4fa7 Input \u9762\u677f\u62d6\u62fd\u786e\u8ba4 $input.item.json.body \u7684\u8def\u5f84\u6b63\u786e\nconst requestBody = $input.item.json.body; \n\n // \u589e\u52a0\u5b89\u5168\u6027\u68c0\u67e5\nif (!requestBody) {\n  return { model: null, messages: [], stream: false, error: \"Request body missing\" };\n}\nconst originalMessages = requestBody.messages || [];\n\n// \u4f7f\u7528\u4f60\u7684 map \u903b\u8f91\uff0c\u4f46\u53d8\u91cf\u540d\u6539\u4e3a finalMessages\nconst finalMessages = originalMessages.map(message => ({\n  role: message.role,\n  content: tranformContent(message.content) // \u4f7f\u7528\u4f60\u539f\u6765\u7684\u8f6c\u6362\u51fd\u6570\n}));\n\n// !!! \u5173\u952e\u4fee\u6539\uff1a \u8fd4\u56de HTTP Request \u8282\u70b9\u6240\u9700\u7684\u5b8c\u6574\u7ed3\u6784 !!!\n// \u800c\u4e0d\u662f return { input };\nreturn { \n   model: requestBody.model,\n   messages: finalMessages, // \u952e\u540d\u662f messages, \u4e0d\u662f input\n   stream: requestBody.stream === true, // \u786e\u4fdd\u662f boolean\n};\n"
      },
      "id": "6cfff2ab-ea1e-46a1-b6ac-c44c66efb261",
      "name": "Remap to Response API Schema",
      "type": "n8n-nodes-base.code",
      "position": [
        1320,
        940
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.72live.com/v1/chat/completions",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "<redacted-credential>"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"{{ $json.model }}\", \n  \"messages\": {{ JSON.stringify($json.messages) }},\n  \"stream\": {{ $json.stream }}\n}",
        "options": {}
      },
      "id": "ee717a86-4c1a-483f-a153-4dcef944bd7c",
      "name": "OpenAI Responses API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1540,
        940
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gemini-2.0-flash",
          "mode": "list",
          "cachedResultName": "gemini-2.0-flash"
        },
        "options": {}
      },
      "id": "4f70558e-fc48-486e-8d0f-285e8574e58a",
      "name": "n8n Webhook",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1280,
        500
      ],
      "typeVersion": 1.2,
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## 1. \u521b\u5efa\u65b0\u7684\u81ea\u5b9a\u4e49OpenAI\u51ed\u8bc1\n\u8981\u5728\u73b0\u6709n8n\u8282\u70b9\u4e2d\u4f7f\u7528\u5927\u6a21\u578b\uff0c\u4e00\u79cd\u65b9\u6cd5\u662f\u6a21\u62df\u901a\u8fc7OpenAI\u6a21\u578b\u5b50\u8282\u70b9\u8fde\u63a5\u7684\u517c\u5bb9API\u3002\u542c\u8d77\u6765\u590d\u6742\u4f46\u522b\u62c5\u5fc3\uff0c\u672c\u6a21\u677f\u5c06\u5c55\u793a\u5177\u4f53\u64cd\u4f5c\uff01\u7b2c\u4e00\u6b65\u662f\u8bbe\u7f6e\u65b0\u7684OpenAI\u51ed\u8bc1\uff0c\u4ee5\u4fbf\u6211\u4eec\u80fd\u4fee\u6539\u57fa\u7840URL\u3002",
        "height": 580,
        "width": 700,
        "color": 7
      },
      "id": "c3a2bed1-4d14-4168-9876-ed2ca1b772f9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1020,
        60
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## 2. \u5217\u51fa\u6240\u6709\u53ef\u7528\u6a21\u578b  \n[\u8be6\u7ec6\u4e86\u89e3Webhook\u89e6\u53d1\u5668\u8282\u70b9](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.webhook/)  \n\n\u6211\u4eec\u7684\u7b2c\u4e00\u4e2a\u7aef\u70b9\u7528\u4e8e\u5217\u51fa\u6240\u6709\u6a21\u578b\uff0c\u8fd9\u91cc\u5b9e\u73b0\u662f\u901a\u8fc7\u8c03\u7528\u7b2c\u4e09\u65b9\u5927\u6a21\u578bAPI\u5c55\u793a\u4e86\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u5b9e\u9645\u5e94\u7528\u53ef\u4ee5\u628a\u6a21\u578b\u7c7b\u578b\u4f5c\u4e3a\u5b50\u6d41\u7a0b\u7684\u5207\u6362\u53c2\u6570",
        "height": 580,
        "width": 800,
        "color": 7
      },
      "id": "d255bec2-66a2-4ead-b8e0-9099f08c3d78",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        60
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// \u6b64\u65f6 $json \u76f4\u63a5\u5c31\u662f\u90a3\u4e2a\u5bf9\u8c61: { \"id\": \"...\", choices: [...], usage: {...} }\n// \u6211\u4eec\u76f4\u63a5\u628a $json \u8d4b\u503c\u7ed9 data, \u5e76\u505a\u7b80\u5355\u5224\u7a7a\nconst data = $json; \n\n// \u5982\u679c\u8f93\u5165\u9879\u672c\u8eab\u5c31\u662f null \u6216 undefined\nif (!data) {\n  // \u53ef\u4ee5\u8fd4\u56de\u9519\u8bef\uff0c\u6216\u8005\u8fd4\u56de\u4e00\u4e2a\u7a7a\u7ed3\u6784\uff0c\u89c6\u4e4e\u4f60\u9700\u8981\u5e73\u53f0\u5982\u4f55\u5904\u7406\u7a7a\u9879\n\treturn { error: \"Input item is null or undefined\" }; \n }\n \n // \u589e\u52a0\u5b89\u5168\u5224\u65ad\uff0c\u9632\u6b62 data.choices \u6216 data.usage \u4e0d\u5b58\u5728\u65f6\u62a5\u9519\n const choices = data.choices || [];\n const usage = data.usage || {};\n const message = (choices[0] || {}).message || {}; // \u66f4\u5b89\u5168\u7684\u83b7\u53d6message\n\n// \u76f4\u63a5\u57fa\u4e8e data (\u5373 $json) \u6765\u6784\u5efa\u8fd4\u56de\u7ed3\u6784\nreturn {\n  \"id\": data.id, \n  \"object\": data.object, // \u4f7f\u7528 data.object\n  \"created\": data.created, // \u5339\u914d\u8f93\u5165\u5b57\u6bb5 created\n  \"model\": data.model, \n   // \u91cd\u70b9\u4fee\u6539 choices \u6620\u5c04\u903b\u8f91\n   \"choices\": choices.map((item, idx) => ({\n       index: item.index, \n       finish_reason: item.finish_reason,\n      \"message\": {\n        \"annotations\": undefined, // \u8f93\u5165\u7ed3\u6784\u4e2d\u6ca1\u6709\n         // \u5b89\u5168\u8bbf\u95ee item.message.content\n        \"content\": item.message ? item.message.content : undefined,\n        \"refusal\": null,\n         // \u5b89\u5168\u8bbf\u95ee item.message.role\n        \"role\": item.message ? item.message.role : undefined\n      }\n    })\n  ),\n   // \u91cd\u70b9\u4fee\u6539 usage \u6620\u5c04\u903b\u8f91\uff0c\u5339\u914d\u8f93\u5165\u5b57\u6bb5\u540d\n  \"usage\": {\n    // \u4f7f\u7528 completion_tokens \u4ee3\u66ff output_tokens\n    \"completion_tokens\": usage.completion_tokens,\n    \"completion_tokens_details\": usage.completion_tokens_details,\n     // \u4f7f\u7528 prompt_tokens \u4ee3\u66ff input_tokens_details\n    \"prompt_tokens\": usage.prompt_tokens, \n    \"prompt_tokens_details\": usage.prompt_tokens_details,\n    \"total_tokens\": usage.total_tokens\n  },\n   // \u8f93\u5165\u6570\u636e\u4e2d\u6ca1\u6709 service_tier\n  \"service_tier\": data.service_tier, \n  \"system_fingerprint\": data.id\n}\n\n"
      },
      "id": "5959e1ce-d975-4e67-9cfb-4e4afbf51ac3",
      "name": "Format Completion Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1960,
        1040
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "content": "## 3. \u6620\u5c04OpenAI\u54cd\u5e94API\uff0c\u5e76\u533a\u5206Stream\u6d41\u5f0f\u548c\u975e\u6d41\u5f0f\u54cd\u5e94\n[\u4e86\u89e3HTTP\u8bf7\u6c42\u8282\u70b9\u7684\u66f4\u591a\u4fe1\u606f](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.httprequest)\n",
        "height": 580,
        "width": 1540,
        "color": 7
      },
      "id": "98c5989c-1b99-4902-b09e-9193faedd720",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1020,
        660
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// \u5047\u8bbe HTTP Request \u8282\u70b9\u5c06\u6574\u4e2a\u4e0a\u6e38 SSE \u54cd\u5e94\u4f53\uff08\u4e00\u4e2a\u957f\u5b57\u7b26\u4e32\uff09\u8f93\u51fa\u5230\u4e86 data \u5c5e\u6027\n// \u68c0\u67e5\u4f60\u7684HTTP Node, \u5982\u679c\u662fBinary data,\u8def\u5f84\u53ef\u80fd\u4e0d\u540c, \u5982 $input.item.binary.myproperty.data\nconst rawStreamString = $input.item.json.data; \n\nif (!rawStreamString) {\n  // \u5982\u679c\u6ca1\u6709\u5185\u5bb9\uff0c\u8fd4\u56de\u7ed3\u675f\u4fe1\u53f7\n  return { data: \"data: [DONE]\\n\\n\" }; \n}\n\nlet fixedId = null; // \u7528\u4e8e\u5b58\u50a8\u6211\u4eec\u6355\u83b7\u5230\u7684\u7b2c\u4e00\u4e2aID\n// let fixedCreated = null; // \u4e5f\u53ef\u4ee5\u7edf\u4e00\u521b\u5efa\u65f6\u95f4\nconst outputChunks = [];\n// SSE\u534f\u8bae\u89c4\u5b9a\u5757\u4e0e\u5757\u4e4b\u95f4\u7528 \\n\\n \u5206\u9694\nconst chunks = rawStreamString.split('\\n\\n'); \n\n for (const chunkStr of chunks) {\n      const trimmedChunk = chunkStr.trim();\n       // \u8df3\u8fc7\u7a7a\u5757\n       if (!trimmedChunk) continue;\n\n       // 1. \u5904\u7406\u7ed3\u675f\u6807\u8bb0 [DONE]\n       // \u6ce8\u610f\uff1a\u6709\u4e9b\u4e0a\u6e38\u53ef\u80fd\u4e0d\u5e26 data: \u524d\u7f00\uff0c\u8fd9\u91cc\u4fdd\u5b88\u5904\u7406\u5e26\u524d\u7f00\u7684\n       if (trimmedChunk === 'data: [DONE]' || trimmedChunk === '[DONE]' ) {\n            outputChunks.push('data: [DONE]'); // \u7edf\u4e00\u8f93\u51fa data: [DONE]\n            continue; // \u5904\u7406\u4e0b\u4e00\u4e2a\n       }\n        \n       // 2. \u786e\u4fdd\u662f data: \u5f00\u5934\u7684\u6570\u636e\u5757\n       if (!trimmedChunk.startsWith('data: ')) {\n            // \u4e0d\u662f\u6807\u51c6 data: \u5757\u6216 [DONE]\uff0c\u5ffd\u7565\u6216\u539f\u6837\u4f20\u9012(\u5ffd\u7565\u66f4\u5b89\u5168)\n            // outputChunks.push(trimmedChunk); \n            continue; \n       }\n\n       try {\n           // \u63d0\u53d6 \"data: \" \u540e\u9762\u7684 JSON \u5b57\u7b26\u4e32\n           const jsonString = trimmedChunk.substring(6).trim(); \n           const dataObj = JSON.parse(jsonString);\n\n           // \u68c0\u67e5\u662f\u5426\u662f\u5305\u542b id \u7684\u6709\u6548\u5bf9\u8c61\n           if (dataObj && typeof dataObj.id === 'string') {\n                \n               // \u5982\u679c\u662f\u7b2c\u4e00\u6b21\u9047\u5230 ID, \u8bb0\u5f55\u4e0b\u6765\u4f5c\u4e3a\u7edf\u4e00ID\n               if (fixedId === null) {\n                   fixedId = dataObj.id; \n                  // fixedCreated = dataObj.created;\n               }\n              \n               // *** \u6838\u5fc3\u4fee\u590d: \u5f3a\u5236\u8986\u76d6\u5f53\u524d\u5757\u7684 ID \u4e3a\u7edf\u4e00ID ***\n               dataObj.id = fixedId; \n               // dataObj.created = fixedCreated; // \u53ef\u9009: \u4e5f\u7edf\u4e00\u65f6\u95f4\u6233\n\n               // \u91cd\u65b0\u5e8f\u5217\u5316\u4fee\u6539\u540e\u7684\u5bf9\u8c61\uff0c\u5e76\u52a0\u4e0a 'data: ' \u524d\u7f00\n                outputChunks.push('data: ' + JSON.stringify(dataObj));\n\n           } else {\n              // \u5982\u679c JSON \u5bf9\u8c61\u91cc\u6ca1\u6709 id, \u53ef\u4ee5\u9009\u62e9\u539f\u6837\u4f20\u9012\u6216\u5ffd\u7565\n               outputChunks.push(trimmedChunk); \n           }\n\n       } catch (e) {\n           // JSON \u89e3\u6790\u5931\u8d25\uff0c\u5ffd\u7565\u6b64\u9519\u8bef\u5757 (\u6216\u539f\u6837\u4f20\u9012\uff0c\u4f46\u53ef\u80fd\u5bfc\u81f4\u5ba2\u6237\u7aef\u51fa\u9519)\n           // console.error(\"Failed to parse chunk: \", trimmedChunk, e);\n            // outputChunks.push(trimmedChunk); // \u539f\u6837\u4f20\u9012\u6709\u98ce\u9669\n       }\n  }\n\n // \u5c06\u6240\u6709\u5904\u7406\u8fc7\u7684\u5757\u7528 \\n\\n \u91cd\u65b0\u8fde\u63a5\u8d77\u6765, \u5e76\u5728\u672b\u5c3e\u786e\u4fdd\u6709 \\n\\n\n const finalStreamString = outputChunks.join('\\n\\n') + '\\n\\n';\n\n// \u8fd4\u56de Respond \u8282\u70b9\u671f\u671b\u7684\u7ed3\u6784\nreturn { \n  data: finalStreamString \n};\n\n"
      },
      "id": "020b89f7-4f13-4c89-8666-7c0ec558c6ec",
      "name": "Format Stream Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1960,
        840
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "content": "## \u8bd5\u8bd5\u770b\uff01\n### \u672cn8n\u6a21\u677f\u5c55\u793a\u4e86\u5982\u4f55\u5c06OpenAI\u7684Responses API\u4e0e\u73b0\u6709LLM\u53caAI\u4ee3\u7406\u8282\u70b9\u7ed3\u5408\u4f7f\u7528\u3002\n\n\u867d\u7136\u6211\u5efa\u8bae\u7b49\u5f85\u5b98\u65b9\u652f\u6301\uff0c\u4f46\u5982\u679c\u4f60\u8feb\u4e0d\u53ca\u5f85\u60f3\u901a\u8fc7\u8fc2\u56de\u65b9\u5f0f\u5c06OpenAI\u7684Responses API\u96c6\u6210\u5230\u73b0\u6709AI\u5de5\u4f5c\u6d41\u4e2d\uff0c\u8fd9\u4e2a\u6a21\u677f\u7edd\u5bf9\u80fd\u6ee1\u8db3\u9700\u6c42\uff01\n\n\u8be5\u65b9\u6cd5\u5229\u7528n8n\u5185\u7f6e\u7684webhooks\u4e3aResponses API\u5b9e\u73b0\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u5c01\u88c5\u5c42\u3002\u901a\u8fc7\u81ea\u5b9a\u4e49OpenAI\u51ed\u8bc1\u5c06\u57fa\u7840URL\u6307\u5411\u8fd9\u4e9bwebhooks\u540e\uff0c\u5373\u53ef\u62e6\u622a\u8bf7\u6c42\u5e76\u91cd\u65b0\u6620\u5c04\u53c2\u6570\u4ee5\u786e\u4fdd\u517c\u5bb9\u6027\u3002\n\n### \u5de5\u4f5c\u539f\u7406\n* \u4ee3\u7406\u8282\u70b9\u8fde\u63a5\u4e86OpenAI\u5b50\u8282\u70b9\uff0c\u4f46\u4f7f\u7528\u7279\u6b8a\u81ea\u5b9a\u4e49\u51ed\u8bc1\u2014\u2014\u5176base_url\u88ab\u4fee\u6539\u4e3a\u6307\u5411\u672c\u6a21\u677f\u7684webhooks\n* \u6267\u884c\u67e5\u8be2\u65f6\uff0c\u4ee3\u7406\u8bf7\u6c42\u4f1a\u88ab\u8f6c\u53d1\u5230\u8ff7\u4f60\u804a\u5929\u8865\u5168\u5de5\u4f5c\u6d41\n* \u5728\u6b64\u6211\u4eec\u5c06\u6807\u51c6\u8bf7\u6c42\u53c2\u6570\u91cd\u65b0\u6620\u5c04\uff0c\u901a\u8fc7\u914d\u7f6e\u597d\u7684HTTP\u8282\u70b9\u5411Responses API\u53d1\u8d77\u67e5\u8be2\n* \u6536\u5230\u54cd\u5e94\u540e\u9700\u518d\u6b21\u8f6c\u6362\u8f93\u51fa\u683c\u5f0f\u4ee5\u786e\u4fddLangchain\u517c\u5bb9\u6027\uff0c\u4f7fLLM\u6216\u4ee3\u7406\u8282\u70b9\u80fd\u89e3\u6790\u5e76\u54cd\u5e94\u7528\u6237\n* \u5305\u542b\u4e24\u79cd\u54cd\u5e94\u683c\u5f0f\uff1a\u6d41\u5f0f\u548c\u975e\u6d41\u5f0f\n\n### \u4f7f\u7528\u65b9\u6cd5\n* \u5fc5\u987b\u6fc0\u6d3b\u672c\u5de5\u4f5c\u6d41\u624d\u80fd\u4f7f\u7528webhooks\u529f\u80fd\n* \u6309\u8bf4\u660e\u521b\u5efa\u81ea\u5b9a\u4e49OpenAI\u51ed\u8bc1\n* \u5728\u73b0\u6709AI\u5de5\u4f5c\u6d41\u4e2d\u7528\u8be5\u51ed\u8bc1\u66ff\u6362LLM\u8282\u70b9\uff0c\u65e0\u9700\u8fc1\u79fb\u5176\u4ed6\u5185\u5bb9\n\n### \u9700\u6c42\u6761\u4ef6\n* \u5177\u5907Responses API\u6743\u9650\u7684OpenAI\u8d26\u6237\n\n### \u81ea\u5b9a\u4e49\u8c03\u6574\n* \u6b22\u8fce\u7528\u76f8\u540c\u6280\u672f\u8bd5\u9a8c\u5176\u4ed6LLM\uff01\n* \u53ca\u65f6\u5173\u6ce8Responses API\u516c\u544a\u5e76\u6309\u9700\u8c03\u6574\n\n### \u9700\u8981\u5e2e\u52a9\uff1f\n\u52a0\u5165\u5fae\u4fe1\u7fa4\uff0c\u4e00\u8d77\u4ea4\u6d41\u5b66\u4e60\uff08\u5148\u52a0Gemini61718\u6216My61718\u9080\u8bf7\uff09\n\n\u795d\u60a8\u73a9\u5f97\u5f00\u5fc3\uff01",
        "height": 1180,
        "width": 420
      },
      "id": "cf7f683c-f7f3-4607-b78d-a4e617fdd8ba",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        60
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2300,
        300
      ],
      "id": "10b5c20e-87b3-4a18-93d9-f6e492df1b40",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "213702bf-d5c2-4a8a-b5c8-e55f804e4496",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $('POST ChatCompletions').first().json.body.stream }}",
              "rightValue": ""
            }
          ]
        },
        "options": {}
      },
      "id": "057f53d1-d1a1-4833-9df2-b897c257dea9",
      "name": "Is Stream?",
      "type": "n8n-nodes-base.if",
      "position": [
        1740,
        940
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.data }}",
        "options": {
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "text/event-stream; charset=utf-8"
              },
              {
                "name": "Connection",
                "value": "keep-alive"
              },
              {
                "name": "X-Accel-Buffering",
                "value": "no"
              },
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2180,
        840
      ],
      "id": "8c22b171-f700-47be-bcac-8a3ac6a9cc3c",
      "name": "Respond for Steam"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        2160,
        1040
      ],
      "id": "b062e772-53b9-404b-a6a3-bc5697645f0d",
      "name": "Respond Directly"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        1320,
        300
      ],
      "id": "39b843c4-c6a6-4d9b-8406-909d801f91a9",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "contextWindowLength": 20
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        1420,
        500
      ],
      "id": "cf70e6df-83da-4c3a-9106-c2a4600eda8d",
      "name": "Simple Memory"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "OpenAI Models",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Responses API": {
      "main": [
        [
          {
            "node": "Is Stream?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "POST ChatCompletions": {
      "main": [
        [
          {
            "node": "Remap to Response API Schema",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remap to Response API Schema": {
      "main": [
        [
          {
            "node": "OpenAI Responses API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Models": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Stream Response": {
      "main": [
        [
          {
            "node": "Respond for Steam",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Completion Response": {
      "main": [
        [
          {
            "node": "Respond Directly",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Stream?": {
      "main": [
        [
          {
            "node": "Format Stream Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Completion Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8n Webhook": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "78ea904f-3636-40f4-8e07-f737205e675c",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "Kk6dSjnGB3xrWAuR",
  "tags": []
}

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

n8n2API(No memory). Uses chatTrigger, httpRequest, lmChatOpenAi, agent. Chat trigger; 19 nodes.

Source: https://github.com/rv192/CommonRepo/blob/58237e8543787c0ee858f3fb863ee071651cd00c/n8n/series/n8n2API.json — 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

by Varritech Technologies

Chat Trigger, Agent, OpenAI Chat +8
AI & RAG

Who is this workflow for? This workflow is designed for SEO analysts, content creators, marketing agencies, and developers who need to index a website and then interact with its content as if it were

Agent, OpenAI Chat, Memory Buffer Window +10
AI & RAG

Airtable AI Agent. Uses lmChatOpenAi, agent, toolWorkflow, toolCode. Chat trigger; 42 nodes.

OpenAI Chat, Agent, Tool Workflow +6
AI & RAG

Ai Agent To Chat With Airtable And Analyze Data. Uses lmChatOpenAi, agent, stickyNote, memoryBufferWindow. Chat trigger; 41 nodes.

OpenAI Chat, Agent, Memory Buffer Window +6
AI & RAG

I prepared a detailed guide that shows the entire process of building an AI agent that integrates with Airtable data in n8n. This template covers everything from data preparation to advanced configura

OpenAI Chat, Agent, Memory Buffer Window +6