AutomationFlowsAI & RAG › AI Chatbot with Redis Memory

AI Chatbot with Redis Memory

Original n8n title: Openai Chatbot with Redis Memory

OpenAI Chatbot with Redis Memory. Uses redis, openAi. Webhook trigger; 6 nodes.

Webhook trigger★★★★☆ complexityAI-powered6 nodesRedisOpenAI
AI & RAG Trigger: Webhook Nodes: 6 Complexity: ★★★★☆ AI nodes: yes Added:

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": "OpenAI Chatbot with Redis Memory",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "chat",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1b2c3d4-1111-4000-8000-000000000001",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "set-msg",
              "name": "message",
              "value": "={{ $json.body.message }}",
              "type": "string"
            },
            {
              "id": "set-session",
              "name": "sessionId",
              "value": "={{ $json.body.sessionId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-1111-4000-8000-000000000002",
      "name": "Extract Message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "operation": "get",
        "key": "={{ 'chat_history:' + $json.sessionId }}",
        "options": {}
      },
      "id": "a1b2c3d4-1111-4000-8000-000000000003",
      "name": "Redis Get History",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        750,
        300
      ],
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "message",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a helpful AI assistant. You have memory of past conversations with this user. Be concise, accurate, and friendly. If you don't know something, say so honestly."
            },
            {
              "role": "user",
              "content": "={{ 'Previous conversation:\\n' + ($json.data || 'No previous history') + '\\n\\nUser message: ' + $('Extract Message').item.json.message }}"
            }
          ]
        },
        "options": {
          "temperature": 0.7,
          "maxTokens": 1024
        }
      },
      "id": "a1b2c3d4-1111-4000-8000-000000000004",
      "name": "OpenAI Chat",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        1000,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "set",
        "key": "={{ 'chat_history:' + $('Extract Message').item.json.sessionId }}",
        "value": "={{ ($('Redis Get History').item.json.data || '') + '\\nUser: ' + $('Extract Message').item.json.message + '\\nAssistant: ' + $json.text }}",
        "expire": true,
        "ttl": 3600,
        "options": {}
      },
      "id": "a1b2c3d4-1111-4000-8000-000000000005",
      "name": "Redis Save Response",
      "type": "n8n-nodes-base.redis",
      "typeVersion": 1,
      "position": [
        1250,
        300
      ],
      "credentials": {
        "redis": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ response: $('OpenAI Chat').item.json.text, sessionId: $('Extract Message').item.json.sessionId }) }}"
      },
      "id": "a1b2c3d4-1111-4000-8000-000000000006",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1500,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Message": {
      "main": [
        [
          {
            "node": "Redis Get History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis Get History": {
      "main": [
        [
          {
            "node": "OpenAI Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat": {
      "main": [
        [
          {
            "node": "Redis Save Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Redis Save Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null
}

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

OpenAI Chatbot with Redis Memory. Uses redis, openAi. Webhook trigger; 6 nodes.

Source: https://github.com/mlnjsh/n8n-workflows-mega/blob/main/workflows/ai-agents/01-openai-chatbot-with-memory.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

z-Api. Uses httpRequest, openAi, redis, postgres. Webhook trigger; 61 nodes.

HTTP Request, OpenAI, Redis +4
AI & RAG

The Ultimate Scraper for n8n uses Selenium and AI to retrieve any information displayed on a webpage. You can also use session cookies to log in to the targeted webpage for more advanced scraping need

OpenAI Chat, HTTP Request, Information Extractor +1
AI & RAG

How it works: • Receives WhatsApp messages via webhook from Whapi.Cloud • Routes commands: AI chat (/ai), numeric commands (1-9), or help menu • Sends responses: text, images, documents, videos, conta

HTTP Request, OpenAI
AI & RAG

This workflow will allow you to use OpenAI Assistant API together with a chatting platform. This version is configured to work with Hubspot, however, the Hubspot modules can be replaced by other platf

HTTP Request, Airtable, OpenAI
AI & RAG

I'll be honest, I built this because I was getting lazy in meetings and missing key details. I started with a simple VEXA integration for transcripts, then added AI to pull out summaries and tasks. Bu

Redis, Baserow, HTTP Request +3