{
  "id": "zQkM15rEmD23HAeW",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Email Generator with Tone Selection",
  "tags": [
    {
      "id": "sBLDO4c3ubWvhiSj",
      "name": "n8n creator",
      "createdAt": "2025-09-30T20:55:34.201Z",
      "updatedAt": "2025-09-30T20:55:34.201Z"
    }
  ],
  "nodes": [
    {
      "id": "a7d25cbb-f1f1-451c-bb89-7dcfaa5f8915",
      "name": "Email Generator Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        416,
        288
      ],
      "parameters": {
        "options": {},
        "formTitle": "AI Email Generator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Recipient Name",
              "requiredField": true
            },
            {
              "fieldLabel": "Email Subject",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Email Context",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Tone",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Professional"
                  },
                  {
                    "option": "Friendly"
                  },
                  {
                    "option": "Formal"
                  },
                  {
                    "option": "Casual"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        },
        "formDescription": "Generate professional emails with your chosen tone"
      },
      "typeVersion": 2.2
    },
    {
      "id": "336e7273-30ca-4800-a8b2-01eaadaa0e32",
      "name": "Extract Form Data",
      "type": "n8n-nodes-base.set",
      "position": [
        640,
        288
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "recipient-field",
              "name": "recipient",
              "type": "string",
              "value": "={{ $json['Recipient Name'] }}"
            },
            {
              "id": "subject-field",
              "name": "subject",
              "type": "string",
              "value": "={{ $json['Email Subject'] }}"
            },
            {
              "id": "context-field",
              "name": "context",
              "type": "string",
              "value": "={{ $json['Email Context'] }}"
            },
            {
              "id": "tone-field",
              "name": "tone",
              "type": "string",
              "value": "={{ $json['Tone'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fd094524-76b1-45cd-ac72-402aefc39ff9",
      "name": "Build AI Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        864,
        288
      ],
      "parameters": {
        "jsCode": "const recipient = $input.item.json.recipient;\nconst subject = $input.item.json.subject;\nconst context = $input.item.json.context;\nconst tone = $input.item.json.tone.toLowerCase();\n\nlet toneInstructions = '';\n\nswitch(tone) {\n  case 'professional':\n    toneInstructions = 'Use a professional, business-appropriate tone. Be clear, concise, and respectful. Maintain a balance between friendliness and formality.';\n    break;\n  case 'friendly':\n    toneInstructions = 'Use a warm, friendly tone while remaining appropriate. Be conversational and approachable, but maintain professionalism.';\n    break;\n  case 'formal':\n    toneInstructions = 'Use a highly formal, diplomatic tone. Use proper salutations and maintain strict formality throughout. Be respectful and courteous.';\n    break;\n  case 'casual':\n    toneInstructions = 'Use a casual, relaxed tone. Be conversational and natural, as if writing to a colleague or friend.';\n    break;\n  default:\n    toneInstructions = `Use a ${tone} tone.`;\n}\n\nconst prompt = `Write a complete email with the following details:\n\nRecipient: ${recipient}\nSubject: ${subject}\nContext: ${context}\n\nTone Instructions: ${toneInstructions}\n\nFormat the email properly with:\n- An appropriate greeting\n- A clear body that addresses the context\n- A professional closing\n- Do not include a signature line (the user will add their own)\n\nWrite only the email content, nothing else.`;\n\nreturn {\n  json: {\n    prompt: prompt,\n    recipient: recipient,\n    subject: subject,\n    tone: tone\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "a34dcc52-0851-406d-8197-e47458bba309",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1072,
        496
      ],
      "parameters": {
        "model": "gpt-3.5-turbo",
        "options": {
          "maxTokens": 500,
          "temperature": 0.7
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cffb3447-a441-4c94-9eb4-bdada01d4124",
      "name": "Generate Email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1104,
        288
      ],
      "parameters": {
        "text": "={{ $json.prompt }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "e35fba09-e164-4333-9caa-5928f0f028dc",
      "name": "Format Output",
      "type": "n8n-nodes-base.set",
      "position": [
        1408,
        288
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "email-body",
              "name": "email_body",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "email-subject",
              "name": "subject",
              "type": "string",
              "value": "={{ $('Extract Form Data').item.json.subject }}"
            },
            {
              "id": "email-tone",
              "name": "tone",
              "type": "string",
              "value": "={{ $('Extract Form Data').item.json.tone }}"
            },
            {
              "id": "email-recipient",
              "name": "recipient",
              "type": "string",
              "value": "={{ $('Extract Form Data').item.json.recipient }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7b0de931-82fa-46f6-aaa2-565c41bfceb5",
      "name": "Display Generated Email",
      "type": "n8n-nodes-base.form",
      "position": [
        1632,
        288
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "\u2705 Email Generated Successfully!",
        "completionMessage": "=**Subject:** {{ $json.subject }}\n\n**Tone:** {{ $json.tone }}\n\n**Recipient:** {{ $json.recipient }}\n\n---\n\n{{ $json.email_body }}\n\n---\n\n*Copy the email above and add your signature before sending.*"
      },
      "typeVersion": 1
    },
    {
      "id": "c5bc8234-00b1-4af0-a2e4-f6b9a547aaf0",
      "name": "Main Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -128
      ],
      "parameters": {
        "color": 5,
        "width": 844,
        "height": 1033,
        "content": "![5min Logo](https://assets.zyrosite.com/cdn-cgi/image/format=auto,w=175,q=95/d9573nnb9LioR05g/logo_tr-Yleq6B4J5WtDk64q.png)\n\n## AI Email Generator with Tone Selection\n**Made by [Biznova](https://www.biznova.tech/en)**\n **on [Tiktok](https://www.tiktok.com/@biznova_tech)**\n\n\n\n### \ud83d\udce7 What This Does\nThis workflow creates a professional email generator that allows users to:\n- Choose from multiple tones (Professional, Friendly, Formal, Casual)\n- Input recipient details, subject, and context\n- Generate a complete, well-formatted email using AI\n\n### \ud83d\udc65 Who's It For\n- Business professionals who need to write emails quickly\n- Customer support teams responding to inquiries\n- Sales teams crafting outreach messages\n- Anyone who wants help writing professional emails\n\n### \ud83c\udfaf How It Works\n1. User fills out a form with email details and selects a tone\n2. The workflow processes the input and creates an AI prompt\n3. OpenAI generates a complete email based on the tone\n4. The formatted email is displayed for the user to copy\n\n### \u2699\ufe0f Setup Requirements\n- OpenAI API key (get one at https://platform.openai.com)\n- n8n instance (cloud or self-hosted)\n\n### \ud83d\ude80 How to Use\n1. Set up your OpenAI credentials in the \"OpenAI Chat Model\" node\n2. Activate the workflow\n3. Share the form URL with users\n4. Users fill out the form and receive a generated email instantly"
      },
      "typeVersion": 1
    },
    {
      "id": "daec94b3-1af5-4305-baca-75a2b05bdc34",
      "name": "Setup Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        512
      ],
      "parameters": {
        "color": 4,
        "width": 396,
        "height": 457,
        "content": "### \ud83d\udd27 Setup Steps\n\n**1. OpenAI API Key**\n   - Go to https://platform.openai.com/api-keys\n   - Create a new API key\n   - Add it to the \"OpenAI Chat Model\" node credentials\n\n**2. Customize Tones (Optional)**\n   - Edit the \"Build AI Prompt\" node\n   - Modify the tone instructions to match your needs\n   - Add new tones to the form dropdown\n\n**3. Adjust AI Settings (Optional)**\n   - In \"OpenAI Chat Model\" node:\n   - Change model (gpt-4 for better quality)\n   - Adjust temperature (0.5-0.9)\n   - Modify max tokens for longer/shorter emails\n\n**4. Test the Workflow**\n   - Click \"Test workflow\" button\n   - Fill out the form\n   - Check the generated email\n\n**5. Share the Form**\n   - Activate the workflow\n   - Copy the form URL\n   - Share with your team or customers"
      },
      "typeVersion": 1
    },
    {
      "id": "fc3da369-ac70-420d-bcf4-aca4c1eb9b6d",
      "name": "Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 218,
        "height": 98,
        "content": "**Step 1:** User Input\nForm collects email details and tone preference"
      },
      "typeVersion": 1
    },
    {
      "id": "fa8e49fc-63bc-4df2-8d11-0124509d233a",
      "name": "Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 218,
        "height": 98,
        "content": "**Step 2:** Extract & Organize\nPrepare data for AI processing"
      },
      "typeVersion": 1
    },
    {
      "id": "7574b96c-cff4-42c9-a128-bf82a9b971d0",
      "name": "Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 218,
        "height": 98,
        "content": "**Step 3:** Build Prompt\nCreate AI instructions based on selected tone"
      },
      "typeVersion": 1
    },
    {
      "id": "2c9c5651-cb91-447a-9b27-5d2cf72142d0",
      "name": "Step 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 218,
        "height": 98,
        "content": "**Step 4:** AI Generation\nOpenAI creates the email content"
      },
      "typeVersion": 1
    },
    {
      "id": "1c68f2f6-f826-4798-9ffe-64653475122f",
      "name": "Step 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 258,
        "height": 98,
        "content": "**Step 5:** Format & Display\nShow the generated email to the user"
      },
      "typeVersion": 1
    },
    {
      "id": "8992c076-cc45-48f4-af4c-494622cb72cc",
      "name": "API Key Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        624
      ],
      "parameters": {
        "color": 3,
        "height": 80,
        "content": "\u2699\ufe0f **Configure Your API Key Here**\nAdd your OpenAI credentials"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a7bf2666-fe9a-4709-87d6-e6f8874f169f",
  "connections": {
    "Format Output": {
      "main": [
        [
          {
            "node": "Display Generated Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Email": {
      "main": [
        [
          {
            "node": "Format Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build AI Prompt": {
      "main": [
        [
          {
            "node": "Generate Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Form Data": {
      "main": [
        [
          {
            "node": "Build AI Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Email Generator Form": {
      "main": [
        [
          {
            "node": "Extract Form Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Display Generated Email": {
      "main": [
        []
      ]
    }
  }
}