8
n8n 한국어amn8n.com

OpenAI 및 Redis 세션 관리를 사용한 채팅 지원 고객 인증

고급

이것은Support, AI분야의자동화 워크플로우로, 19개의 노드를 포함합니다.주로 Set, Form, Redis, Switch, FormTrigger 등의 노드를 사용하며인공지능 기술을 결합하여 스마트 자동화를 구현합니다. OpenAI와 Redis 세션 관리를 사용한 채팅 지원 고객 인증

사전 요구사항
  • Redis 서버 연결 정보
  • OpenAI API Key

카테고리

워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
  "meta": {
    "instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0c0090f9-c3a6-421d-8c67-92baeded6007",
      "name": "채팅 메시지 수신 시",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -580,
        -160
      ],
      "webhookId": "0fa189dc-16dc-470f-b69d-3e2809d8c071",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "adf71970-7f0c-4394-bdab-b701eaa7173f",
      "name": "LLM",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -240,
        40
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8gccIjcuf3gvaoEr",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "56318a6e-3a05-4f6b-9eb5-15ad6144144e",
      "name": "메모리",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -120,
        40
      ],
      "parameters": {
        "sessionKey": "=chat_{{ $('When chat message received').first().json.sessionId }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "6bde1175-7175-4ccd-ac0b-65ecc8c2d7b3",
      "name": "세션 가져오기",
      "type": "n8n-nodes-base.redis",
      "position": [
        -400,
        -160
      ],
      "parameters": {
        "key": "=chat_{{ $json.sessionId }}",
        "keyType": "string",
        "options": {},
        "operation": "get",
        "propertyName": "data"
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "81f53ae3-22b6-48cd-83b9-3c6c1041818c",
      "name": "다른 워크플로우에 의해 실행 시",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        340,
        -120
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "eventType"
            },
            {
              "name": "data",
              "type": "object"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "ade09ef9-b2bc-4cf0-84b5-7121623b4f7b",
      "name": "스위치",
      "type": "n8n-nodes-base.switch",
      "position": [
        540,
        -120
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Get Auth Url",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "55d3d729-baf4-47ad-8262-5d23fc2d3348",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.eventType }}",
                    "rightValue": "get_auth_url"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "7ee9de6a-bb37-4adc-87a2-ddb745d17ab7",
      "name": "인증 URL 응답 가져오기",
      "type": "n8n-nodes-base.set",
      "position": [
        740,
        -120
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cf2b4fb3-cda0-47f9-b9fa-fda3532a04f5",
              "name": "auth_url",
              "type": "string",
              "value": "=https://<your-n8n-url>/form/auth?sessionId={{ $json.data.sessionId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "880f7506-0947-47f1-ba0d-d08d6d18133b",
      "name": "인증 URL 가져오기",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        40,
        40
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $workflow.id }}"
        },
        "description": "Call this tool to generate a login URL which allows guest users to authenticate as customers.",
        "workflowInputs": {
          "value": {
            "data": "={{\n{\n  \"sessionId\": $('When chat message received').first().json.sessionId\n}\n}}",
            "eventType": "get_auth_url"
          },
          "schema": [
            {
              "id": "eventType",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "eventType",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "data",
              "type": "object",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "data",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "800be1b0-5bec-4eaf-ac13-e6808b955408",
      "name": "세션 업데이트",
      "type": "n8n-nodes-base.redis",
      "position": [
        1620,
        -120
      ],
      "parameters": {
        "key": "=chat_{{ $('Login Form').first().json.formQueryParameters.sessionId }}",
        "ttl": 3600,
        "value": "={{ $json.toJsonString() }}",
        "expire": true,
        "keyType": "string",
        "operation": "set"
      },
      "credentials": {
        "redis": {
          "id": "zU4DA70qSDrZM1El",
          "name": "Redis account (localhost)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8b3d4728-2ae2-40dd-98ee-9efb915d06fc",
      "name": "로그인 성공 확인",
      "type": "n8n-nodes-base.form",
      "position": [
        1800,
        -120
      ],
      "webhookId": "d939dc43-e333-4cb6-8bde-d6d8868ec9d3",
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Login Successful!",
        "completionMessage": "=Welcome back {{ $json.name }},\nYour chat session is now authenticated.\n\nYou may now close this window and chat as a customer."
      },
      "typeVersion": 1
    },
    {
      "id": "5cb5797a-7f6c-4855-bcaa-4475ef16ec8d",
      "name": "고객 지원 에이전트",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -200,
        -160
      ],
      "parameters": {
        "text": "={{ $('When chat message received').item.json.chatInput }}",
        "options": {
          "systemMessage": "=You are a customer support assistant interacting with both anonymous guests and existing customers.\n* Guest users can ask basic questions about publicly available information.\n* Existing Customers can access their accounts, basket and profile.\n* Guests who ask about their accounts, basket or profile must authenticate as a customer before they can access this information. Provide a login url for the user and ask them to return once authenticated. Remind the user not to close the chat window as this will end the session!\n\n### About the login URL \nThe login url will take the user to an external form which when authenticated, will link their chat session with their customer profile. The user should close the form once done and return to the chat window. Upon their next message, their customer profile will be included in the context.\n* If you haven't already, thank the user for authenticating and welcome them back!\n* If the user claims to have authenticated but is still identified as a guest, then it may be that the login attempt was not successful and the user should be advised politely to try again.\n\n---\nThe current user is {{ $json.data ? 'a customer' : 'a guest' }}.\n{{ $json.data ?? '' }}",
          "passthroughBinaryImages": true
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "1b1f96f6-6f70-4b86-9831-0ac31a65dbdc",
      "name": "스티커 노트",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -380
      ],
      "parameters": {
        "color": 7,
        "width": 840,
        "height": 560,
        "content": "## 1. Create a Conversational Agent with Session Access\n[Learn more about AI Agents](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent)\n\nOur support agent handles both guests and customers, with the latter identified by available session data coming in from Redis. For guests who wish to authenticate as customers, the agent is instructed to generate a login URL to share with the user - this is accomplished using a tool."
      },
      "typeVersion": 1
    },
    {
      "id": "b41e156c-a70f-422a-a37a-432e5657a999",
      "name": "스티커 노트1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -380
      ],
      "parameters": {
        "color": 7,
        "width": 720,
        "height": 560,
        "content": "## 2. Generate a Login URL via Tool\n[Learn more about Subworkflow Triggers](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflowtrigger)\n\nThe login URL is a simple redirect to an form which handles the authentication. For obvious reasons, we've deliberately avoided doing this through the chat as it could have exposed sensitive credentials. The login URL appends the SessionID as a query parameter because this is currently the only way to pre-fill fields in a n8n form."
      },
      "typeVersion": 1
    },
    {
      "id": "bd10ad35-7c72-480f-86fd-e15ee4011688",
      "name": "스티커 노트2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1000,
        -380
      ],
      "parameters": {
        "color": 7,
        "width": 1020,
        "height": 560,
        "content": "## 3. A Login Form to Link Session to Customer Profile\n[Learn more about the Form Trigger](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.formtrigger)\n\nThis login form is pretty standard and takes 3 fields: username, password and sessionId. the idea being that once authenticated successfully, the user's customer profile can be used to associate with the sessionID. Note that I haven't implemented the actual authentication logic - you'll need to do this yourself!"
      },
      "typeVersion": 1
    },
    {
      "id": "f13700b3-69cb-4809-b982-9204c2766948",
      "name": "고객 프로필 가져오기",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        -120
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"id\": 1,\n  \"name\": \"Jim Le\",\n  \"email\": \"jim@example.com\",\n  \"basket\": [\n    \"SanDisk Extreme Portable SSD 1TB (up to 1050 MB/s read, 1,000MB/s write, NVMe SSD, USB-C, External Solid State Drive, IP65 rated for dust and water resistance, Updated Firmware) Black - £84.99\",\n    \"eufy X10 Pro Omni Robot Vacuum Cleaner with Mop, All-in-One Station, 8,000Pa Powerful Suction, Dual Mops, AI Obstacle Avoidance, Auto Mop Washing, Auto-Hot-Air-Drying, Auto-Emptying, Auto-Refilling £799.00\"\n  ] \n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "66c28c7e-7ff1-4aac-8fbf-35e8c8105a65",
      "name": "Replace Me!",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1260,
        -120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e58f3c0f-c441-4c89-9a19-2c3459733dee",
      "name": "로그인 폼",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        1080,
        -120
      ],
      "webhookId": "cac0738d-f211-41de-bc6e-6f36103d9c1a",
      "parameters": {
        "options": {
          "path": "auth",
          "ignoreBots": true,
          "buttonLabel": "Submit"
        },
        "formTitle": "Authenticate Chat Session",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Username",
              "requiredField": true
            },
            {
              "fieldLabel": "Password",
              "requiredField": true
            },
            {
              "fieldName": "sessionId",
              "fieldType": "hiddenField"
            }
          ]
        },
        "responseMode": "lastNode",
        "formDescription": "Please login to validate your current chat session."
      },
      "typeVersion": 2.2
    },
    {
      "id": "2f965c47-76e3-4100-8c48-2be4dccece49",
      "name": "스티커 노트3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        60
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 140,
        "content": "### Replace with Authentication Logic!\nThis could be a query to a PostgreSQL database or otherwise."
      },
      "typeVersion": 1
    },
    {
      "id": "1d5077eb-4a6b-4bcb-9a85-e525a6c013ab",
      "name": "스티커 노트4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1160,
        -820
      ],
      "parameters": {
        "width": 460,
        "height": 1160,
        "content": "## Try It Out!\n### This n8n template demonstrates one approach to customer authentication via chat agents.\n\nUnlike approaches where you have to authenticate users prior to interacting with the agent, this approach allows guest users to authenticate at any time during the session or not at all.\n\n### How it works\n* A conversational agent is used for this demonstration. The key component is the Redis node just after the chat trigger which acts as the session context.\n* For guests, the session item is blank. for customers, the session item is populated with their customer profile.\n* The agent is instructed to generate a unique login URL only for guests when appropriate or upon request.\n* This login URL redirects the guest user to a simple n8n form also hosted in this template. The login URL has the current sessionID as a query parameter as the way to pass this data to the form.\n* Once login is successful, the matching session item by sessionId is populated with the customer profile. The user can now return to the chat window.\n* Back to the agent, now when the user sends their next message, the Redis node will pick up the session item and the customer profile associated with it. The system prompt is updated with this data which let's the agent know the user is now a customer.\n\n### How to use\n* You'll need to update the \"auth URL\" tool to match the URL of your n8n instance. Better yet, copy the production URL of your form from the trigger.\n* Activate the workflow to turn on production mode which is required for this workflow.\n* Implement the authentication logic in step 3. This could be sending the user and pass to a postgreSQL data for validation.\n\n### Requirements\n* OpenAI for LLM (feel free to swap to any provider)\n* Redis for Cache/Sessions (again, feel free to swap this out for postgresql or other database)\n\n### Customising this workflow\n* Consider not populating the session item with the user data as it can become stale. Instead, just add the userId and instruct the agent to query using tools.\n\n### Need Help?\nJoin the [Discord](https://discord.com/invite/XPKeKXeB7d) or ask in the [Forum](https://community.n8n.io/)!\n\nHappy Hacking!"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "adf71970-7f0c-4394-bdab-b701eaa7173f": {
      "ai_languageModel": [
        [
          {
            "node": "5cb5797a-7f6c-4855-bcaa-4475ef16ec8d",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "56318a6e-3a05-4f6b-9eb5-15ad6144144e": {
      "ai_memory": [
        [
          {
            "node": "5cb5797a-7f6c-4855-bcaa-4475ef16ec8d",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "ade09ef9-b2bc-4cf0-84b5-7121623b4f7b": {
      "main": [
        [
          {
            "node": "7ee9de6a-bb37-4adc-87a2-ddb745d17ab7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e58f3c0f-c441-4c89-9a19-2c3459733dee": {
      "main": [
        [
          {
            "node": "66c28c7e-7ff1-4aac-8fbf-35e8c8105a65",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6bde1175-7175-4ccd-ac0b-65ecc8c2d7b3": {
      "main": [
        [
          {
            "node": "5cb5797a-7f6c-4855-bcaa-4475ef16ec8d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "66c28c7e-7ff1-4aac-8fbf-35e8c8105a65": {
      "main": [
        [
          {
            "node": "f13700b3-69cb-4809-b982-9204c2766948",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "880f7506-0947-47f1-ba0d-d08d6d18133b": {
      "ai_tool": [
        [
          {
            "node": "5cb5797a-7f6c-4855-bcaa-4475ef16ec8d",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "800be1b0-5bec-4eaf-ac13-e6808b955408": {
      "main": [
        [
          {
            "node": "8b3d4728-2ae2-40dd-98ee-9efb915d06fc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f13700b3-69cb-4809-b982-9204c2766948": {
      "main": [
        [
          {
            "node": "800be1b0-5bec-4eaf-ac13-e6808b955408",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0c0090f9-c3a6-421d-8c67-92baeded6007": {
      "main": [
        [
          {
            "node": "6bde1175-7175-4ccd-ac0b-65ecc8c2d7b3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "81f53ae3-22b6-48cd-83b9-3c6c1041818c": {
      "main": [
        [
          {
            "node": "ade09ef9-b2bc-4cf0-84b5-7121623b4f7b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
자주 묻는 질문

이 워크플로우를 어떻게 사용하나요?

위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.

이 워크플로우는 어떤 시나리오에 적합한가요?

고급 - 지원, 인공지능

유료인가요?

이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.

워크플로우 정보
난이도
고급
노드 수19
카테고리2
노드 유형13
난이도 설명

고급 사용자를 위한 16+개 노드의 복잡한 워크플로우

저자
Jimleuk

Jimleuk

@jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

외부 링크
n8n.io에서 보기

이 워크플로우 공유

카테고리

카테고리: 34