🎅

Naughty or Nice Calculator

n8n Workflow JSON

Nodes: 4
workflow.json
{
  "name": "My workflow 5",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Naughty or Nice ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Q1: What is your First Name?",
              "placeholder": "Santa",
              "requiredField": true
            },
            {
              "fieldLabel": "Q2: How old are you?",
              "fieldType": "number",
              "placeholder": "5",
              "requiredField": true
            },
            {
              "fieldLabel": "Q3: Email Address",
              "fieldType": "email",
              "placeholder": "santa@santa.com",
              "requiredField": true
            },
            {
              "fieldLabel": "Q4: You see someone drop their snack on the floor. What do you do?",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "A. Help them pick it up and ask if they’re okay 😊"
                  },
                  {
                    "option": "B. Tell an adult and keep playing"
                  },
                  {
                    "option": "C. Laugh and say, “Five-second rule!”"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Q5: It’s time to clean up toys. What’s your move?",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "A. Start cleaning right away and help others too"
                  },
                  {
                    "option": "B. Clean up a few toys after being reminded"
                  },
                  {
                    "option": "C. Hide the toys under something and call it “invisible”"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Q6: Someone wants a turn with something you’re using. What do you do?",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "A. Share and take turns happily"
                  },
                  {
                    "option": "B. Say “in a minute” and then share"
                  },
                  {
                    "option": "C. Hold it tight and say, “Mine forever!”"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Q7: You accidentally bump into someone. What happens next?",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "A. Say “I’m sorry” and check if they’re okay"
                  },
                  {
                    "option": "B. Say “oops” and keep going"
                  },
                  {
                    "option": "C. Blame the floor for being in the way"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Q8: You’re asked to help with a small chore. What do you do?",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "A. Help right away with a smile"
                  },
                  {
                    "option": "B. Help after a little grumbling"
                  },
                  {
                    "option": "C. Suddenly need a very important snack break"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Q9: You see someone sitting alone. What do you do?",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "A. Invite them to join you or say hello"
                  },
                  {
                    "option": "B. Smile or give a friendly wave"
                  },
                  {
                    "option": "C. Scoot away like a sneaky penguin"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.3,
      "position": [
        0,
        0
      ],
      "id": "73128a49-ea32-4abe-a866-be4e79ae0ad1",
      "name": "On form submission",
      "webhookId": "cb886bb5-9879-467f-b034-bc7ff6c05467"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "claude-3-haiku-20240307",
          "mode": "list",
          "cachedResultName": "claude-3-haiku-20240307"
        },
        "messages": {
          "values": [
            {
              "content": "=You are Santa's helper reviewing a child's \"Naughty or Nice\" quiz.\n\nHere are their answers:\n\nName: {{ $json['Q1: What is your First Name?'] }}\nAge: {{ $json['Q2: How old are you?'] }}\n\nQ4 - Dropped snack: {{ $json['Q4: You see someone drop their snack on the floor. What do you do?'] }}\nQ5 - Clean up toys: {{ $json['Q5: It’s time to clean up toys. What’s your move?'] }}\nQ6 - Sharing: {{ $json['Q6: Someone wants a turn with something you’re using. What do you do?'] }}\nQ7 - Bump into someone: {{ $json['Q7: You accidentally bump into someone. What happens next?'] }}\nQ8 - Chore: {{ $json['Q8: You’re asked to help with a small chore. What do you do?'] }}\nQ9 - Someone alone: {{ $json['Q9: You see someone sitting alone. What do you do?'] }}\n\nScoring rules:\n- Answers starting with \"A\" = 2 points (nicest)\n- Answers starting with \"B\" = 1 point (okay)\n- Answers starting with \"C\" = 0 points (naughty)\n\nCalculate their total score out of 12, then determine their category:\n- 10-12: \"Officially on the Nice List 🌟\"\n- 6-9: \"Nice List (with a few warnings) ✅\"\n- 3-5: \"On the Fence 🤔\"\n- 0-2: \"Coal is looking likely 😅\"\n\nDouble-check your math before responding.\n\nRespond with ONLY valid JSON in this exact format, no markdown:\n{\n  \"name\": \"their name\",\n  \"score\": number,\n  \"maxScore\": 12,\n  \"category\": \"their category with emoji\",\n  \"message\": \"A fun, encouraging 2-3 sentence personalized message for the child. Keep it warm and playful, even for low scores. Mention something specific Santa's elves noticed about their answers.\"\n}\n"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.anthropic",
      "typeVersion": 1,
      "position": [
        208,
        0
      ],
      "id": "13a7bcd5-a3f8-4c9a-9364-63d645b0330e",
      "name": "Message a model",
      "credentials": {
        "anthropicApi": {
          "id": "Yq0iNDd97jwRTOMM",
          "name": "Anthropic account 2"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return JSON.parse($input.first().json.content[0].text)\n\n\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        0
      ],
      "id": "f5a8d150-e2b1-4e8c-ae3f-ab169e17f5d4",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "operation": "completion",
        "respondWith": "showText",
        "responseText": "=<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>Your Nice List Certificate!</title>\n  <style>\n    * { margin: 0; padding: 0; box-sizing: border-box; }\n    body {\n      font-family: Arial, sans-serif;\n      background: linear-gradient(180deg, #0c1445 0%, #1a237e 100%);\n      min-height: 100vh;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      padding: 20px;\n    }\n    .certificate {\n      background: linear-gradient(135deg, #fef9f0 0%, #fff 100%);\n      border-radius: 20px;\n      padding: 40px;\n      max-width: 500px;\n      text-align: center;\n      box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 0 4px #c41e3a, 0 0 0 8px #165b33;\n    }\n    .emoji { font-size: 60px; margin-bottom: 10px; }\n    h1 { font-size: 24px; color: #165b33; margin-bottom: 10px; }\n    .name { font-size: 36px; color: #c41e3a; margin: 15px 0; }\n    .category { font-size: 22px; font-weight: bold; color: #165b33; margin: 15px 0; }\n    .score { background: #165b33; color: white; padding: 10px 25px; border-radius: 20px; display: inline-block; margin: 15px 0; font-size: 18px; }\n    .message { font-size: 16px; line-height: 1.6; color: #333; padding: 20px; background: #f8f8f8; border-radius: 12px; border-left: 4px solid #c41e3a; margin: 20px 0; text-align: left; }\n    .footer { margin-top: 20px; font-size: 14px; color: #666; }\n  </style>\n</head>\n<body>\n  <div class=\"certificate\">\n    <div class=\"emoji\">🎅</div>\n    <h1>Official Nice List Certificate</h1>\n    <p>This certifies that</p>\n    <div class=\"name\">{{ $json.name }}</div>\n    <div class=\"category\">{{ $json.category }}</div>\n    <div class=\"score\">Score: {{ $json.score }} / {{ $json.maxScore }}</div>\n    <div class=\"message\">{{ $json.message }}</div>\n    <div class=\"footer\">🎄 Verified by Santa's Workshop 🎄<br>December 2025</div>\n  </div>\n</body>\n</html>\n"
      },
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.3,
      "position": [
        768,
        0
      ],
      "id": "9371cbf7-8036-479d-bf9c-5e1e45906cc7",
      "name": "Form",
      "webhookId": "d89336b0-31b4-41c2-b4ee-e331f8b4d210"
    }
  ],
  "pinData": {},
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8d57ae5e-2d13-4f29-8220-e27bd77c9232",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "3b6b7ff8bfbc7e3c735f84c231f4e5842cb2f5801d4e5383997c236afab742df"
  },
  "id": "fKQ44jkse5g7BGxM",
  "tags": []
}
Copied to clipboard!