患者へ電子メールと WhatsApp で処方せんを送信
これはMiscellaneous, Multimodal AI分野の自動化ワークフローで、8個のノードを含みます。主にCode, Filter, WhatsApp, EmailSend, GoogleSheetsなどのノードを使用。 Google Sheetsを使った処方箋の自動送信(メールとWhatsApp)
- •Google Sheets API認証情報
{
"id": "RiKOVQcW472o1Hfu",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "Send Prescription to Patients via Email & WhatsApp",
"tags": [],
"nodes": [
{
"id": "368d24da-9d79-4bf5-9c56-1f70bf74ab1e",
"name": "新規処方箋のフィルタリング",
"type": "n8n-nodes-base.filter",
"position": [
-1240,
-120
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.prescription_status }}",
"rightValue": "new"
},
{
"id": "2",
"operator": {
"type": "string",
"operation": "isNotEmpty"
},
"leftValue": "={{ $json.patient_email }}",
"rightValue": ""
},
{
"id": "3",
"operator": {
"type": "string",
"operation": "isNotEmpty"
},
"leftValue": "={{ $json.patient_phone }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "7ca917ec-330c-4f53-90ae-3fa7b7178200",
"name": "処方箋データのフォーマット",
"type": "n8n-nodes-base.code",
"position": [
-1020,
-120
],
"parameters": {
"jsCode": "// Format prescription data for email and WhatsApp\nconst items = $input.all();\n\nreturn items.map(item => {\n const data = item.json;\n \n // Format prescription text\n const prescriptionText = `\n🏥 PRESCRIPTION\n\nPatient: ${data.patient_name}\nDoctor: ${data.doctor_name}\nDate: ${data.prescription_date}\n\nPrescription Details:\n${data.prescription_details}\n\nDosage Instructions:\n${data.dosage_instructions}\n\nFollow-up Date: ${data.followup_date || 'Not specified'}\n\n⚠️ Important: Take medications as prescribed. Contact your doctor if you have any questions.\n `;\n \n // Format email HTML\n const emailHTML = `\n <div style=\"font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;\">\n <div style=\"background-color: #f8f9fa; padding: 20px; border-radius: 8px;\">\n <h2 style=\"color: #2c3e50; text-align: center;\">📋 Medical Prescription</h2>\n \n <div style=\"background-color: white; padding: 20px; border-radius: 6px; margin: 20px 0;\">\n <h3 style=\"color: #3498db; margin-top: 0;\">Patient Information</h3>\n <p><strong>Name:</strong> ${data.patient_name}</p>\n <p><strong>Doctor:</strong> ${data.doctor_name}</p>\n <p><strong>Date:</strong> ${data.prescription_date}</p>\n </div>\n \n <div style=\"background-color: white; padding: 20px; border-radius: 6px; margin: 20px 0;\">\n <h3 style=\"color: #27ae60; margin-top: 0;\">Prescription Details</h3>\n <p style=\"white-space: pre-line;\">${data.prescription_details}</p>\n </div>\n \n <div style=\"background-color: white; padding: 20px; border-radius: 6px; margin: 20px 0;\">\n <h3 style=\"color: #e74c3c; margin-top: 0;\">Dosage Instructions</h3>\n <p style=\"white-space: pre-line;\">${data.dosage_instructions}</p>\n </div>\n \n ${data.followup_date ? `\n <div style=\"background-color: white; padding: 20px; border-radius: 6px; margin: 20px 0;\">\n <h3 style=\"color: #f39c12; margin-top: 0;\">Follow-up</h3>\n <p><strong>Next Appointment:</strong> ${data.followup_date}</p>\n </div>\n ` : ''}\n \n <div style=\"background-color: #fff3cd; border: 1px solid #ffeaa7; padding: 15px; border-radius: 6px; margin: 20px 0;\">\n <p style=\"margin: 0; color: #856404;\">⚠️ <strong>Important:</strong> Take medications exactly as prescribed. Contact your doctor if you experience any side effects or have questions.</p>\n </div>\n \n <div style=\"text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd;\">\n <p style=\"color: #7f8c8d; font-size: 12px;\">This prescription was sent automatically from our medical system.</p>\n </div>\n </div>\n </div>\n `;\n \n return {\n json: {\n ...data,\n prescriptionText,\n emailHTML,\n whatsappMessage: prescriptionText.replace(/🏥|📋|⚠️/g, ''), // Remove emojis for WhatsApp compatibility\n timestamp: new Date().toISOString()\n }\n };\n});"
},
"typeVersion": 2
},
{
"id": "73c4304b-ac16-4deb-aaae-d40c94c29de9",
"name": "WhatsApp送信",
"type": "n8n-nodes-base.whatsApp",
"position": [
-800,
-20
],
"webhookId": "2ff35c14-14d6-485c-bf0f-8a460769b4dd",
"parameters": {
"textBody": "Hello [Patient Name], 👋 Your prescription from Dr. [Doctor Name] dated [Date] is ready. Please check the attached file for your medication details. 📞 For queries, contact us at [Contact Number]. [Clinic/Hospital Name]",
"operation": "send",
"phoneNumberId": "=+919988888888",
"additionalFields": {},
"recipientPhoneNumber": "=+91999999999999"
},
"credentials": {
"whatsAppApi": {
"id": "b0PxTDPdWzznWnfG",
"name": "WhatsApp-test "
}
},
"typeVersion": 1
},
{
"id": "cc159a2b-d6c2-414d-b3bc-05f4d0a16b29",
"name": "通知ログ記録",
"type": "n8n-nodes-base.googleSheets",
"position": [
-580,
-120
],
"parameters": {
"columns": {
"value": {
"timestamp": "={{ $json.timestamp }}",
"doctor_name": "={{ $json.doctor_name }}",
"email_status": "={{ $('Send email').item.json.success ? 'sent' : 'failed' }}",
"patient_name": "={{ $json.patient_name }}",
"patient_email": "={{ $json.patient_email }}",
"patient_phone": "={{ $json.patient_phone }}",
"prescription_id": "={{ $json.prescription_id }}",
"whatsapp_status": "={{ $('Send WhatsApp').item.json.success ? 'sent' : 'failed' }}",
"notification_type": "prescription_sent"
},
"schema": [
{
"id": "timestamp",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "patient_name",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "patient_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "patient_email",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "patient_email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "patient_phone",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "patient_phone",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "doctor_name",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "doctor_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "prescription_id",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "prescription_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "email_status",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "email_status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "whatsapp_status",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "whatsapp_status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "notification_type",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "notification_type",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"patient_name"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": "Notification_Log",
"documentId": {
"__rl": true,
"mode": "url",
"value": "=YOUR_GOOGLE_SHEET"
},
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "ScSS2KxGQULuPtdy",
"name": "Google Sheets- test"
}
},
"typeVersion": 4
},
{
"id": "0c9e09cb-1d80-4f09-abfd-4d3d712833ef",
"name": "処方箋ステータスの更新",
"type": "n8n-nodes-base.googleSheets",
"position": [
-360,
-120
],
"parameters": {
"columns": {
"value": {
"prescription_status": "sent"
},
"schema": [
{
"id": "prescription_id",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "prescription_id",
"defaultMatch": true,
"canBeUsedToMatch": true
},
{
"id": "prescription_status",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "prescription_status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"prescription_id"
]
},
"options": {},
"operation": "update",
"sheetName": "Prescriptions",
"documentId": {
"__rl": true,
"mode": "url",
"value": "=YOUR_GOOGLE_SHEET"
},
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "ScSS2KxGQULuPtdy",
"name": "Google Sheets- test"
}
},
"typeVersion": 4
},
{
"id": "5c2bf898-b7a2-43c9-a90d-e852fecf829e",
"name": "Google Sheetsトリガー",
"type": "n8n-nodes-base.googleSheetsTrigger",
"position": [
-1460,
-120
],
"parameters": {
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"sheetName": {
"__rl": true,
"mode": "id",
"value": "=cfrt5tgbhu8iujnjio90"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "=ojnbgt56ybb"
}
},
"credentials": {
"googleSheetsTriggerOAuth2Api": {
"id": "BoDTTv5L67GVL3Fi",
"name": "Google Sheets - test"
}
},
"typeVersion": 1
},
{
"id": "530efe83-c80e-4b1e-8121-c508907cecd1",
"name": "Eメール送信",
"type": "n8n-nodes-base.emailSend",
"position": [
-800,
-220
],
"webhookId": "4316a3ab-1861-43cb-9b7a-446b0938186e",
"parameters": {
"text": "Dear [Patient Name],\n\nPlease find attached your prescription from Dr. [Doctor Name] dated [Date].\nIf you have any questions about your medication, kindly contact our clinic.\n\nAttachment: Prescription PDF/Image\n\nBest regards,\n[Clinic/Hospital Name]\n[Contact Number] | [Email Address]",
"options": {
"appendAttribution": false,
"allowUnauthorizedCerts": false
},
"subject": "Your Prescription from [Doctor/Hospital Name]",
"toEmail": "={{ $json.patient_email }}",
"fromEmail": "noreply@yourhospital.com"
},
"credentials": {
"smtp": {
"id": "G1kyF8cSWTZ4vouN",
"name": "SMTP -test"
}
},
"typeVersion": 2
},
{
"id": "41b633a7-3641-4816-8b13-eb26a3d37686",
"name": "付箋メモ",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1580,
-480
],
"parameters": {
"color": 3,
"width": 660,
"height": 260,
"content": "## 🌟 Features Included\n\n- **Automated Trigger**: Monitors Google Sheet for new prescriptions\n- **Smart Filtering**: Only processes prescriptions with status \"new\"\n- **Rich Email Format**: Professional HTML email with prescription details\n- **WhatsApp Integration**: Sends formatted prescription text\n- **Comprehensive Logging**: Tracks all sent notifications\n- **Status Updates**: Marks prescriptions as \"sent\" after processing\n- **Error Handling**: Logs success/failure status for both channels"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "62ea4e96-2323-44a0-8a1c-9726039672be",
"connections": {
"530efe83-c80e-4b1e-8121-c508907cecd1": {
"main": [
[
{
"node": "cc159a2b-d6c2-414d-b3bc-05f4d0a16b29",
"type": "main",
"index": 0
}
]
]
},
"73c4304b-ac16-4deb-aaae-d40c94c29de9": {
"main": [
[
{
"node": "cc159a2b-d6c2-414d-b3bc-05f4d0a16b29",
"type": "main",
"index": 0
}
]
]
},
"cc159a2b-d6c2-414d-b3bc-05f4d0a16b29": {
"main": [
[
{
"node": "0c9e09cb-1d80-4f09-abfd-4d3d712833ef",
"type": "main",
"index": 0
}
]
]
},
"5c2bf898-b7a2-43c9-a90d-e852fecf829e": {
"main": [
[
{
"node": "368d24da-9d79-4bf5-9c56-1f70bf74ab1e",
"type": "main",
"index": 0
}
]
]
},
"368d24da-9d79-4bf5-9c56-1f70bf74ab1e": {
"main": [
[
{
"node": "7ca917ec-330c-4f53-90ae-3fa7b7178200",
"type": "main",
"index": 0
}
]
]
},
"7ca917ec-330c-4f53-90ae-3fa7b7178200": {
"main": [
[
{
"node": "530efe83-c80e-4b1e-8121-c508907cecd1",
"type": "main",
"index": 0
},
{
"node": "73c4304b-ac16-4deb-aaae-d40c94c29de9",
"type": "main",
"index": 0
}
]
]
}
}
}このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
中級 - その他, マルチモーダルAI
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
このワークフローを共有