AutomationFlowsAI & RAG › Sweeppea V0.2.0 — Smart Registration (chat)

Sweeppea V0.2.0 — Smart Registration (chat)

Sweeppea v0.2.0 — Smart Registration (chat). Uses chatTrigger, n8n-nodes-sweeppea, agent, lmChatOpenAi. Chat trigger; 13 nodes.

Chat trigger trigger★★★★☆ complexityAI-powered13 nodesChat TriggerN8N Nodes SweeppeaAgentOpenAI ChatMemory Buffer WindowChat
AI & RAG Trigger: Chat trigger Nodes: 13 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": "Sweeppea v0.2.0 \u2014 Smart Registration (chat)",
  "nodes": [
    {
      "parameters": {
        "content": "## Smart Registration v2\n\nEvolves v1's dynamic-form pattern with v0.2.0 ops.\n\n**Flow**: Chat \u2192 Count \u2192 Get Form Fields \u2192 Build prompt (with form fields + current count) \u2192 AI Agent collects data \u2192 Switch \u2192 Transform \u2192 Create \u2192 Reply.\n\n**New in v2**: shows participant their position (\"you'll be #N+1\") thanks to `Participant: Count`.\n\nReplace `sweepstakesToken` in the two Sweeppea nodes with yours, and bind the OpenAI credential on the chat model.",
        "height": 280,
        "width": 460,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -400,
        0
      ],
      "id": "10000000-0000-0000-0000-000000000001",
      "name": "Sticky: README"
    },
    {
      "parameters": {
        "public": true,
        "options": {
          "responseMode": "responseNodes"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.3,
      "position": [
        -400,
        400
      ],
      "id": "10000000-0000-0000-0000-000000000010",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "resource": "participant",
        "operation": "count",
        "sweepstakesToken": "512e77fa-3d11-4ebe-95ee-031d7ddfa593",
        "countFilterType": "all"
      },
      "type": "n8n-nodes-sweeppea.sweeppea",
      "typeVersion": 1,
      "position": [
        -180,
        400
      ],
      "id": "10000000-0000-0000-0000-000000000020",
      "name": "Count Participants",
      "credentials": {
        "sweeppeaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "participant",
        "operation": "getFormFields",
        "sweepstakesToken": "512e77fa-3d11-4ebe-95ee-031d7ddfa593"
      },
      "type": "n8n-nodes-sweeppea.sweeppea",
      "typeVersion": 1,
      "position": [
        40,
        400
      ],
      "id": "10000000-0000-0000-0000-000000000030",
      "name": "Get Form Fields",
      "credentials": {
        "sweeppeaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "/* Build Dynamic System Prompt From Form Fields + Current Count */\n\nconst schemaResp = $input.first().json;\nconst data       = schemaResp.Data;\nconst countResp  = $('Count Participants').first().json;\nconst current    = countResp?.Data?.Counts?.Total ?? 0;\nconst chatInput  = $('When chat message received').first().json.chatInput;\nconst sessionId  = $('When chat message received').first().json.sessionId;\n\nif (!data || !data.FormFields) {\n\tthrow new Error('Form fields not available \u2014 check the sweepstakesToken');\n}\n\n/* Slug Helper: 'First Name' \u2192 'First_Name' */\nconst toSlug = (n) => n.trim().replace(/\\s+/g, '_');\n\n/* Build Required/Optional Lists */\nconst required = data.FormFields.filter(f => f.Required);\nconst optional = data.FormFields.filter(f => !f.Required);\nconst describe = (f) => {\n\tconst ex   = f.Placeholder ? ` \u2014 example: ${f.Placeholder}` : '';\n\tconst opts = (f.Options && f.Options.length) ? ` \u2014 pick one: ${f.Options.map(o => `${o.Id}=${o.Name}`).join(', ')}` : '';\n\treturn `- ${f.Name}${ex}${opts}`;\n};\n\n/* Build JSON Example Skeleton */\nconst skeleton = {};\ndata.FormFields.forEach(f => {\n\tconst slug = toSlug(f.Name);\n\tif (f.Type === 'email')             skeleton[slug] = 'user@example.com';\n\telse if (f.Type === 'usphonenumber') skeleton[slug] = '5551234567';\n\telse if (f.Type === 'birthdate')     skeleton[slug] = 'MM/DD/YYYY';\n\telse if (f.Type === 'number')        skeleton[slug] = '0';\n\telse if (f.Type === 'list' && f.Options?.length) skeleton[slug] = String(f.Options[0].Id);\n\telse                                  skeleton[slug] = '<value>';\n});\n\n/* Identify Key Fields For Mapping */\nconst emailField = data.FormFields.find(f => f.Type === 'email');\nconst phoneField = data.FormFields.find(f => f.Type === 'usphonenumber');\n\n/* Compose System Message */\nconst systemPrompt = `You are a friendly sweepstake registration assistant.\n\nThe sweepstake currently has ${current} participants. Tell the user they'll be #${current + 1} once registered.\n\nCollect this data ONE field at a time:\n\nRequired:\n${required.map(describe).join('\\n')}\n${optional.length ? `\\nOptional:\\n${optional.map(describe).join('\\n')}` : ''}\n\nWhen you have all required fields, respond with EXACTLY this JSON (no markdown, no extra text):\n\n${JSON.stringify({ action: 'create_participant', ...skeleton }, null, 2)}\n\nRules:\n- Use the field names exactly as shown (underscores).\n- For list fields, pass the option ID number.\n- Validate emails and phones (10 digits) before sending the final JSON.\n- Be warm, brief, and friendly.`;\n\nreturn {\n\tjson: {\n\t\tsystemPrompt,\n\t\tchatInput,\n\t\tsessionId,\n\t\temailFieldSlug: emailField ? toSlug(emailField.Name) : 'Email',\n\t\tphoneFieldSlug: phoneField ? toSlug(phoneField.Name) : 'Mobile_Number',\n\t\tcurrentParticipantCount: current\n\t}\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        400
      ],
      "id": "10000000-0000-0000-0000-000000000040",
      "name": "Build Dynamic Prompt"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "={{ $json.systemPrompt }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        480,
        400
      ],
      "id": "10000000-0000-0000-0000-000000000050",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        420,
        620
      ],
      "id": "10000000-0000-0000-0000-000000000060",
      "name": "OpenAI Chat Model"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('When chat message received').first().json.sessionId }}",
        "contextWindowLength": 12
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        620,
        620
      ],
      "id": "10000000-0000-0000-0000-000000000070",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "create_participant",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "id": "switch-cond-1"
                  }
                ],
                "combinator": "and"
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        780,
        400
      ],
      "id": "10000000-0000-0000-0000-000000000080",
      "name": "Switch: ready to register?"
    },
    {
      "parameters": {
        "jsCode": "/* Transform AI Output JSON Into participant:create Input Shape */\n\nconst aiOutput   = $input.first().json.output;\nconst promptData = $('Build Dynamic Prompt').first().json;\n\n/* LLMs Sometimes Add Narrative Around The JSON; Strip Markdown Fences */\n/* And Extract The Outermost {...} Block From Whatever The Model Wrote  */\nlet raw = String(aiOutput).replace(/```json/g, '').replace(/```/g, '');\nconst firstBrace = raw.indexOf('{');\nconst lastBrace  = raw.lastIndexOf('}');\n\nif (firstBrace === -1 || lastBrace === -1 || lastBrace < firstBrace) {\n\tthrow new Error('AI output did not contain a JSON object: ' + raw.slice(0, 200));\n}\n\nconst clean  = raw.slice(firstBrace, lastBrace + 1).trim();\nconst parsed = JSON.parse(clean);\n\nif (parsed.action !== 'create_participant') {\n\treturn { json: {} };\n}\n\nconst { action, ...fields } = parsed;\n\nreturn {\n\tjson: {\n\t\tKeyEmail       : fields[promptData.emailFieldSlug] || '',\n\t\tKeyPhoneNumber : fields[promptData.phoneFieldSlug] || '',\n\t\tBonusEntries   : 0,\n\t\tFields         : fields\n\t}\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        980,
        304
      ],
      "id": "10000000-0000-0000-0000-000000000090",
      "name": "Transform AI \u2192 API"
    },
    {
      "parameters": {
        "resource": "participant",
        "operation": "create",
        "sweepstakesToken": "512e77fa-3d11-4ebe-95ee-031d7ddfa593"
      },
      "type": "n8n-nodes-sweeppea.sweeppea",
      "typeVersion": 1,
      "position": [
        1180,
        304
      ],
      "id": "10000000-0000-0000-0000-0000000000A0",
      "name": "Register Participant",
      "credentials": {
        "sweeppeaApi": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "message": "={{\n  $json.Response === false\n    ? ($json.Message && $json.Message.toLowerCase().includes('duplicated')\n        ? 'You have already entered this sweepstake \u2014 only one entry per person. \ud83c\udf89'\n        : 'Sorry, registration failed: ' + ($json.Message || 'unknown error'))\n    : 'You are in! \ud83c\udf8a You are participant #' + ($('Build Dynamic Prompt').first().json.currentParticipantCount + 1) + '. Good luck!'\n}}",
        "waitUserReply": false,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chat",
      "typeVersion": 1,
      "position": [
        1400,
        304
      ],
      "id": "10000000-0000-0000-0000-0000000000B0",
      "name": "Reply: registered"
    },
    {
      "parameters": {
        "message": "={{ $('AI Agent').first().json.output }}",
        "waitUserReply": false,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chat",
      "typeVersion": 1,
      "position": [
        980,
        496
      ],
      "id": "10000000-0000-0000-0000-0000000000C0",
      "name": "Reply: continue dialog"
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Count Participants",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Count Participants": {
      "main": [
        [
          {
            "node": "Get Form Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Form Fields": {
      "main": [
        [
          {
            "node": "Build Dynamic Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Dynamic Prompt": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Switch: ready to register?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch: ready to register?": {
      "main": [
        [
          {
            "node": "Transform AI \u2192 API",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reply: continue dialog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform AI \u2192 API": {
      "main": [
        [
          {
            "node": "Register Participant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Register Participant": {
      "main": [
        [
          {
            "node": "Reply: registered",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "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

Sweeppea v0.2.0 — Smart Registration (chat). Uses chatTrigger, n8n-nodes-sweeppea, agent, lmChatOpenAi. Chat trigger; 13 nodes.

Source: https://github.com/Sweeppea-Development-Lab/sweeppea-n8n-nodes/blob/c4dbe5a70c9de86b27b1a226d1e2ab71f1ed64ee/examples/sweeppea-smart-registration-v2.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

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

This Chatbot automates the process of discovering job openings and generating tailored job application emails.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

Job Application PredictLeads & ScrapeGraph AI. Uses chatTrigger, lmChatOpenAi, mcpClientTool, memoryBufferWindow. Chat trigger; 32 nodes.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

Job Application PredictLeads & ScrapeGraph AI. Uses chatTrigger, lmChatOpenAi, mcpClientTool, memoryBufferWindow. Chat trigger; 32 nodes.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

This workflow implements an advanced AI-powered system for generating, and executing Claude Skills stored on GitHub.

Chat Trigger, Memory Buffer Window, Mcp Client Tool +9