diff --git a/workflows/Create AI Newsletters with GPT-4o, Human Approval Workflow, and SendGrid-11032/create_ai_newsletters_with_gpt-4o_human_approval_workflow_and_sendgrid.json b/workflows/Create AI Newsletters with GPT-4o, Human Approval Workflow, and SendGrid-11032/create_ai_newsletters_with_gpt-4o_human_approval_workflow_and_sendgrid.json new file mode 100644 index 000000000..43b0fe51d --- /dev/null +++ b/workflows/Create AI Newsletters with GPT-4o, Human Approval Workflow, and SendGrid-11032/create_ai_newsletters_with_gpt-4o_human_approval_workflow_and_sendgrid.json @@ -0,0 +1 @@ +{"id":"TqDdMHto43GjNPRc","meta":{"instanceId":"73db18c27b0727eb1d6695ef46d95450042be277925d039ca7583d739b775d75"},"name":"AI-Powered Personalized Newsletter Generation and Approval System","tags":[],"nodes":[{"id":"e4c14d3b-7600-4e2d-b75e-6a7aee3664fa","name":"Newsletter Input Form","type":"n8n-nodes-base.formTrigger","position":[-48,0],"webhookId":"d6d8dae1-6368-42b9-9ae2-85124059b1d6","parameters":{"options":{"appendAttribution":false},"formTitle":"メルマガ生成フォーム","formFields":{"values":[{"fieldLabel":"今週のトピック","requiredField":true},{"fieldLabel":"ターゲット読者層","requiredField":true},{"fieldLabel":"送信者名","requiredField":true},{"fieldType":"email","fieldLabel":"承認用メールアドレス","requiredField":true}]},"formDescription":"トピックとターゲット読者層を入力してください。AIが自動的にメルマガを生成します。"},"typeVersion":2.3},{"id":"371c7a6b-b0e9-4716-a458-9a1d3297b7cc","name":"Workflow Configuration","type":"n8n-nodes-base.set","position":[176,0],"parameters":{"options":{},"assignments":{"assignments":[{"id":"id-1","name":"subscriber_list","type":"string","value":"<__PLACEHOLDER_VALUE__Comma-separated email addresses of newsletter subscribers__>"}]},"includeOtherFields":true},"typeVersion":3.4},{"id":"711255f2-fdc7-4954-a013-139509d7abc1","name":"Store Form Responses","type":"n8n-nodes-base.googleSheets","position":[448,0],"parameters":{"columns":{"value":{"topic":"topic","sender":"sender","target":"target","admin_email":"admin_email"},"mappingMode":"autoMapInputData"},"options":{},"operation":"appendOrUpdate","sheetName":{"__rl":true,"mode":"name","value":"<__PLACEHOLDER_VALUE__Sheet name (e.g., Form Responses)__>"},"documentId":{"__rl":true,"mode":"id","value":"<__PLACEHOLDER_VALUE__Google Sheets document ID__>"}},"typeVersion":4.7},{"id":"5d16f728-f115-41ca-8dc2-df5bae55fe95","name":"Generate Newsletter Content","type":"@n8n/n8n-nodes-langchain.agent","position":[672,0],"parameters":{"text":"=トピック: {{ $json.topic }}\nターゲット読者層: {{ $json.target }}\n送信者名: {{ $json.sender }}","options":{"systemMessage":"あなたはプロのメールマーケターです。入力されたトピックとターゲット読者層に基づいて、魅力的なメルマガを作成してください。\n\nタスク:\n1. ターゲット読者層に響く件名を作成する\n2. トピックに基づいた本文をMarkdown形式で作成する\n3. HTMLタグは使用せず、Markdownのみを使用する\n4. 本文は読みやすく、価値のある情報を提供する内容にする\n5. JSONフォーマットで出力する(subject と body_markdown のみ)\n\n注意事項:\n- 余計な会話や説明は含めない\n- JSONのみを出力する\n- Markdownは見出し、リスト、強調などを適切に使用する"},"promptType":"define","hasOutputParser":true},"typeVersion":3},{"id":"f7470b29-3426-47e0-a26f-0d0b2934dc4c","name":"OpenAI GPT-4o Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[672,224],"parameters":{"model":{"__rl":true,"mode":"id","value":"gpt-4o"},"options":{},"builtInTools":{}},"credentials":{"openAiApi":{"id":"OBlv0Qr6gnuMDu52","name":"OpenAi account"}},"typeVersion":1.3},{"id":"703029ef-3e5c-4c60-8395-2b820a359938","name":"JSON Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserStructured","position":[816,224],"parameters":{"schemaType":"manual","inputSchema":"{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"subject\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Email subject line that captures attention\"\n\t\t},\n\t\t\"body_markdown\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Newsletter body content in Markdown format\"\n\t\t}\n\t}\n}"},"typeVersion":1.3},{"id":"a9066ad6-b92d-4bdd-948d-3db69c3a715d","name":"Convert Markdown to HTML","type":"n8n-nodes-base.markdown","position":[1024,0],"parameters":{"mode":"markdownToHtml","options":{},"markdown":"={{ $json.body_markdown }}"},"typeVersion":1},{"id":"a710300f-2599-40a6-b9e3-c4ed54c98d99","name":"Send Approval Email","type":"n8n-nodes-base.gmail","position":[1248,0],"webhookId":"a96643e4-e100-4431-baa8-b3ee1c1e0609","parameters":{"sendTo":"={{ $('Workflow Configuration').first().json.admin_email }}","message":"=

メルマガ承認依頼

\n

以下の内容で承認をお願いします。

\n\n

件名プレビュー:

\n

{{ $json.subject }}

\n\n

本文プレビュー:

\n
\n{{ $json.data }}\n
\n\n

送信者情報:

\n

送信者名: {{ $('Workflow Configuration').first().json.sender }}

\n

ターゲット: {{ $('Workflow Configuration').first().json.target }}

\n\n
\n

✅ 承認して配信する

\n

※このリンクは24時間有効です。クリックすると即座に配信が開始されます。

","options":{},"subject":"=【承認依頼】メルマガ下書き: {{ $json.subject }}"},"credentials":{"gmailOAuth2":{"id":"HQeiho7GNJ1gSUeI","name":"こりんのアカウント"}},"typeVersion":2.1},{"id":"9d590f19-10f3-45fb-86b4-ca914281a4d6","name":"Wait for Approval","type":"n8n-nodes-base.wait","position":[1472,0],"webhookId":"597d4f0c-01da-4b6c-968d-edc40845162a","parameters":{"resume":"webhook","options":{},"resumeAmount":24,"limitWaitTime":true},"typeVersion":1.1},{"id":"f9051562-acb1-4bb3-bc72-26bd6e70a585","name":"Send Newsletter to Subscribers","type":"n8n-nodes-base.sendGrid","position":[1760,0],"parameters":{"subject":"={{ $('Convert Markdown to HTML').first().json.subject }}","toEmail":"={{ $('Workflow Configuration').first().json.subscriber_list }}","fromName":"={{ $('Workflow Configuration').first().json.sender }}","resource":"mail","fromEmail":"<__PLACEHOLDER_VALUE__Verified sender email address in SendGrid__>","contentType":"text/html","contentValue":"={{ $('Convert Markdown to HTML').first().json.data }}","additionalFields":{}},"typeVersion":1},{"id":"80d61370-fbad-40e4-ba8d-20e5a7f7c894","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1216,-448],"parameters":{"width":1120,"height":944,"content":"\n\n# Generate AI newsletters from form inputs and send via SendGrid\n\nStreamline your email marketing process with this AI-powered \"Human-in-the-Loop\" workflow. It allows you to generate high-quality, targeted newsletters from a simple form input, review them via email, and automatically distribute them to your subscribers upon approval.\n\n## ## Who is this for?\nDigital marketers, content creators, community managers, and small business owners who want to maintain consistent communication with their audience but need to reduce the time spent on drafting and formatting emails.\n\n## ## What does this workflow do?\n1. **Input Collection:** Starts with a user-friendly n8n Form where you input the newsletter topic, target audience, and sender details.\n2. **Data Logging:** Automatically saves the form responses to a Google Sheet for your records.\n3. **AI Generation:** Uses OpenAI (GPT-4o) to draft a catchy subject line and valuable body content formatted in Markdown based on your inputs.\n4. **Approval Process:** Sends a \"Review Request\" email to your inbox (via Gmail). This email contains a preview of the newsletter and a special link to approve it.\n5. **Execution Wait:** The workflow pauses and waits for you to click the approval link.\n6. **Distribution:** Once approved, it converts the Markdown to HTML and sends the final newsletter to your subscriber list using SendGrid.\n\n## ## Requirements\n- **OpenAI API Key:** To utilize GPT-4o for content generation.\n- **Google Cloud Account:** Required for the Google Sheets (logging) and Gmail (approval notifications) nodes.\n- **SendGrid Account:** Required for sending the final newsletter to your subscribers.\n- **n8n version:** Ensure you are using a version that supports the LangChain nodes.\n\n## ## How to set up\n1. **Configure Credentials:** Set up your credentials for OpenAI, Google (Sheets & Gmail), and SendGrid within n8n.\n2. **Subscriber List:** Open the **Workflow Configuration** node (Set node). Replace the placeholder with your comma-separated list of subscriber emails.\n3. **Google Sheets:** Create a Google Sheet with columns for `topic`, `target`, `sender`, and `admin_email`. Update the **Store Form Responses** node with your Document ID and Sheet Name.\n4. **Sender Verification:** In the **SendGrid** node, ensure the \"From Email\" matches a verified sender identity in your SendGrid account.\n5. **Test:** Click \"Test Workflow,\" fill out the Form Trigger URL, and check your email for the approval draft. Click the link in the email to finish the process.\n\n## ## How to customize\n- **Change the AI Model:** You can swap the OpenAI model node for Anthropic (Claude) or a local LLM if preferred.\n- **Adjust the Prompt:** Edit the system message in the **Generate Newsletter Content** agent node to change the tone or structure of the newsletter.\n- **Swap Email Providers:** If you don't use SendGrid or Gmail, simply replace these nodes with the email service of your choice (e.g., Mailchimp, Outlook, AWS SES)."},"typeVersion":1},{"id":"832d6730-2bbd-4306-973d-2ae9d75ee8b5","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[128,-128],"parameters":{"color":6,"width":224,"height":336,"content":"1. **Input Collection:** Starts with a user-friendly n8n Form where you input the newsletter topic, target audience, and sender details."},"typeVersion":1},{"id":"71e16864-54aa-41e5-b463-f98a2544a053","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[400,-128],"parameters":{"color":5,"width":192,"height":336,"content":"2. **Data Logging:** Automatically saves the form responses to a Google Sheet for your records."},"typeVersion":1},{"id":"d0d1b724-ff37-48f7-a1ae-74ba2094ac2c","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[640,-128],"parameters":{"color":4,"width":288,"height":496,"content":"3. **AI Generation:** Uses OpenAI (GPT-4o) to draft a catchy subject line and valuable body content formatted in Markdown based on your inputs."},"typeVersion":1},{"id":"86e15543-ed45-4e28-97f0-6bbc1d6b1dcc","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[976,-128],"parameters":{"color":3,"width":416,"height":336,"content":"4. **Approval Process:** Sends a \"Review Request\" email to your inbox (via Gmail). This email contains a preview of the newsletter and a special link to approve it."},"typeVersion":1},{"id":"0b102e74-f612-44c2-836c-cd198355689e","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[1424,-128],"parameters":{"color":2,"width":192,"height":336,"content":"5. **Execution Wait:** The workflow pauses and waits for you to click the approval link."},"typeVersion":1},{"id":"6a3b5711-44be-4a22-9e2e-d7be4fb7fd21","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[1680,-128],"parameters":{"width":246,"height":336,"content":"6. **Distribution:** Once approved, it converts the Markdown to HTML and sends the final newsletter to your subscriber list using SendGrid."},"typeVersion":1}],"active":false,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"44f58a5a-f4eb-4397-bf8b-49dfeb779d98","connections":{"Wait for Approval":{"main":[[{"node":"Send Newsletter to Subscribers","type":"main","index":0}]]},"JSON Output Parser":{"ai_outputParser":[[{"node":"Generate Newsletter Content","type":"ai_outputParser","index":0}]]},"OpenAI GPT-4o Model":{"ai_languageModel":[[{"node":"Generate Newsletter Content","type":"ai_languageModel","index":0}]]},"Send Approval Email":{"main":[[{"node":"Wait for Approval","type":"main","index":0}]]},"Store Form Responses":{"main":[[{"node":"Generate Newsletter Content","type":"main","index":0}]]},"Newsletter Input Form":{"main":[[{"node":"Workflow Configuration","type":"main","index":0}]]},"Workflow Configuration":{"main":[[{"node":"Store Form Responses","type":"main","index":0}]]},"Convert Markdown to HTML":{"main":[[{"node":"Send Approval Email","type":"main","index":0}]]},"Generate Newsletter Content":{"main":[[{"node":"Convert Markdown to HTML","type":"main","index":0}]]}}} \ No newline at end of file