AutomationFlowsAI & RAG › Post-surgery Patient Triage & Follow-up System with Gemini Ai, Telegram &…

Post-surgery Patient Triage & Follow-up System with Gemini Ai, Telegram &…

Original n8n title: Post-surgery Patient Triage & Follow-up System with Gemini Ai, Telegram & Google Suite

ByPixcels Themes @pixcelsthemes on n8n.io

This template is for clinics, hospitals, care teams, and telemedicine providers who need a structured, automated system for post-surgery follow-up. It helps reduce manual workload while ensuring every patient gets timely check-ins and appropriate triage.

Cron / scheduled trigger★★★★★ complexityAI-powered43 nodesGoogle SheetsTelegramTelegram TriggerAgentGoogle Gemini ChatGoogle Sheets ToolGmail ToolHTTP Request Tool
AI & RAG Trigger: Cron / scheduled Nodes: 43 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #11649 — we link there as the canonical source.

This workflow follows the Agent → Gmail Tool 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
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "3c09d83d-a4d0-47c3-ae9f-cac823ee481f",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -640,
        -288
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9cb7991e-ce16-47ea-bc41-2a1b3b011488",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -416,
        -288
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit?usp=drivesdk",
          "cachedResultName": "patiants list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "5b20db41-6287-48f5-8051-3440b47d1ccf",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -192,
        -288
      ],
      "parameters": {
        "jsCode": "const today = new Date();\n\nreturn items.filter(item => {\n  const data = item.json;\n\n  const dischargeDate = new Date(data.start_date);\n  const followUpDays = Number(data[\"Follow_up_duration(days)\"]);\n\n  // Calculate how many days since discharge\n  const daysSinceDischarge = Math.floor((today - dischargeDate) / (1000 * 60 * 60 * 24));\n\n  // Conditions:\n  // - Patient already discharged (no future dates, no today)\n  // - Still within follow-up window\n  return daysSinceDischarge > 0 && daysSinceDischarge <= followUpDays;\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "99e71803-8a2d-44da-b2ee-c45d171bb308",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        32,
        -288
      ],
      "parameters": {
        "text": "=Hello {{ $('Code').item.json.Name }}\n\nWe hope your recovery is going smoothly and that you're feeling a little better today. \ud83d\udc9b\n\nIf you're feeling any pain, discomfort, or have *any concerns at all*, please don\u2019t hesitate to reach out.  \nWe're here to support you \u2014 just reply to this message, and we\u2019ll get back to you as soon as possible. \n\nyou are free to tell us what are you feeling!\n\nTake it easy, rest well, and remember healing takes time. You've got this. \ud83d\udcaa\n\n\u2013 Your Care Team",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c16c414f-9b70-42b8-86e4-11ab0f2be60d",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -640,
        544
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6bb49f4d-9fe7-4b5c-a00b-3e88ba9fad9d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -192,
        544
      ],
      "parameters": {
        "text": "=You are a medical assistant AI. Your task is to expand vague or short post-surgery patient messages into clear, medically useful summaries for doctors and triage systems.\n\nYou will receive:\n- Patient name: {{ $json.first_name }}\n- Patient message: \"{{ $json.message.text }}\"\n\n\u26a0\ufe0f You will not be given the patient's full medical history. Do not assume or invent it.\n\nWrite a 2\u20134 sentence summary that:\n\n1. Clearly restates what the patient said\n2. Connects their message **only** to the given surgery type\n3. Expands the patient's message with clarity and plain language\n4. Relates the symptoms, if any, to the typical post-operative expectations of that surgery\n5. Do not assume or fabricate any health history beyond the surgery provided\n6. Do not diagnose or recommend anything \u2014 just provide a clear explanation of what the patient is reporting\n7. If the message contains no health concern, note that clearly, but acknowledge the patient is responsive\n\nFinal output should help a triage system understand the message without guessing or over-interpreting it. Focus only on what is explicitly said and the given surgery.\n",
        "options": {
          "systemMessage": "check the google sheet for patients surgery type in column Surgery_Name\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "e30874bd-cb7d-4819-bafc-519151f38e93",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -184,
        768
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "32395867-bcf4-4f4f-953a-576e273eb6a8",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "2c05b155-7263-491b-8f0c-b3c07cb56f19",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "read"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "74fe8360-bb67-467b-bfc3-08bbe00da59f",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1440,
        1008
      ],
      "parameters": {
        "text": "=You are a compassionate medical assistant following up with a post-surgery patient.\n\nThe patient visited for: check google sheet\nThey just sent this message: \u201c{{ $('Edit Fields').item.json.message.text }}\u201d\npatient name: {{ $('Edit Fields').item.json.first_name }}\n\nBased on this, write a short, kind response for a low-intensity concern that:\n\nReassures the patient that their mild symptom is typical after whatever the reason\n\nEncourages them to continue recovery as advised\n\nReminds them to contact the care team if things get worse\n\nUses a warm, friendly, human tone (no medical jargon)\n\nKeep the reply brief: 2\u20134 sentences.",
        "options": {
          "systemMessage": "you have to check for patients details from google sheet "
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "7bc4675e-6bcb-43db-8f37-5b83fa036b97",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        512,
        544
      ],
      "parameters": {
        "jsCode": "// This function expects input like:\n// status: read\\nintensity: moderate\n\nconst output = $json[\"output\"]; // The raw message from AI, e.g., status: read\\nintensity: moderate\nconst lines = output.split('\\n');\n\nlet result = {};\n\nfor (const line of lines) {\n  const [key, value] = line.split(':').map(s => s.trim());\n  if (key && value) {\n    result[key] = value;\n  }\n}\n\nreturn [{ json: result }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6e8e8e3e-8a7e-490d-a79d-f05d72245f17",
      "name": "feedback msg",
      "type": "n8n-nodes-base.telegram",
      "position": [
        960,
        648
      ],
      "parameters": {
        "text": "That's wonderful to hear! \ud83d\ude0a We're glad you're feeling better. Keep resting and take things at your own pace \u2014 healing is a journey, and you're doing great!  If anything changes or you have any questions at all, just reply to this message. We're always here for you.  \u2013 Your Care Team \ud83d\udc9b",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "02fb4e0c-7a32-4f5e-a32e-90400ac2e1b2",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1440,
        1232
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1bd6c1aa-6417-4be9-bf46-22d3c2879780",
      "name": "Get row(s) in sheet in Google Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1568,
        1232
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit?usp=drivesdk",
          "cachedResultName": "patiants list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "08dc8c5a-d1c5-4676-a8a6-7bd6302de8c3",
      "name": "AI Agent2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1408,
        352
      ],
      "parameters": {
        "text": "=You are a helpful and empathetic virtual assistant working with a post-surgery care team.\n\nThe patient recently had: check google sheet\nTheir message: \"{{ $json.message.text }}\"  \nPatient name (if available): {{ $json.name }}\n\nThis message has been classified as **moderate intensity**, meaning the patient may be experiencing mild to moderate discomfort or symptoms.\n\nYour job is to:\n- Acknowledge the symptom(s) without alarming the patient.\n- Express care and support.\n- Reassure them that their message will be reviewed by the care team shortly.\n- Keep the message clear, warm, and no more than 2\u20134 sentences.\n\nDo **not** provide a medical diagnosis or instructions beyond general reassurance.\n\nOutput only the message to be sent to the patient.\n",
        "options": {
          "systemMessage": "you have to check for patients details from google sheet "
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "672314b7-c1d0-4c2a-b43b-a3d80b9bcd72",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1408,
        576
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d11bc670-b952-468f-a799-3e2471f71371",
      "name": "Get row(s) in sheet in Google Sheets1",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1536,
        576
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit?usp=drivesdk",
          "cachedResultName": "patiants list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "5e288c17-1e63-40d7-9cb6-12d6f0d46f02",
      "name": "AI Agent3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1376,
        -256
      ],
      "parameters": {
        "text": "=You are a compassionate and professional virtual assistant working with a post-surgery care team.\n\nThe patient recently had: check google sheet\nTheir message: \"{{ $('Edit Fields').item.json.message.text }}\"  \nPatient name: {{ $('Edit Fields').item.json.first_name }}\n\nThis message has been classified as **high intensity**, indicating the patient may be experiencing serious symptoms or complications.\n\nYour job is to:\n- Respond with urgency and care.\n- Reassure the patient that their message has been prioritized.\n- Let them know the medical team is being alerted right away.\n- Maintain a calm and professional tone.\n- Limit the response to 2\u20134 sentences.\n\nDo **not** provide a diagnosis. Do **not** tell the patient to wait too long if it\u2019s serious.\n\nOutput only the message to be sent to the patient.\n",
        "options": {
          "systemMessage": "you have to check for patients details from google sheet "
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "c8450ee5-91c8-4bc7-ab7c-b31c1d3ade6e",
      "name": "Google Gemini Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1376,
        -32
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d3e27cd1-ae78-4529-89b8-f869bcd5aec1",
      "name": "Get row(s) in sheet in Google Sheets2",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1504,
        -32
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit?usp=drivesdk",
          "cachedResultName": "patiants list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "5c233476-748a-485c-a4d3-1eb4847f76aa",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -416,
        544
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b81ebcd5-33dd-4dca-b637-197332db043e",
              "name": "first_name",
              "type": "string",
              "value": "={{ $json.message.chat.first_name }}"
            },
            {
              "id": "492ec819-3fd1-4e10-b4b3-e95898c6202c",
              "name": "message.text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            },
            {
              "id": "4ca233f3-7453-45fe-a2b9-50bebe548dac",
              "name": "message.chat.id",
              "type": "number",
              "value": "={{ $json.message.chat.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "29b7eff8-2a5d-4c7c-bb54-26bbdb9e99de",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        960,
        424
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "high",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6b06de34-d361-4279-a019-c4bad35695c3",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intensity }}",
                    "rightValue": "high"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "moderate",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c3eb48be-2f33-46c8-a367-a678be89a3df",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intensity }}",
                    "rightValue": "moderate"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "low",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b7c5475c-4d90-43b4-a42c-9b95b060b809",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intensity }}",
                    "rightValue": "low"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "ignoreCase": true
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "e4ed967b-7fd4-4a56-8b11-376743c3d500",
      "name": "Send a text message2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1776,
        352
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "88a98ac3-e870-4277-ab37-ac87da8367c5",
      "name": "Send a text message3",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1728,
        -256
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "40460acd-7304-4544-bacc-188ff40501a7",
      "name": "Send a text message4",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1792,
        1008
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "46a159a8-16a5-4395-9fda-aa54b558f1c5",
      "name": "Get row(s) in sheet in Google Sheets3",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -56,
        768
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit?usp=drivesdk",
          "cachedResultName": "patiants list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "e9ba961e-891a-40cb-beb7-2a63cadfbd5d",
      "name": "AI Agent4",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        160,
        544
      ],
      "parameters": {
        "text": "=You are a medical message triage assistant. You will be given detailed explanation of patient's state. Your job is to decide whether a human care team needs to read the message or not.\n\nsummary: {{ $json.output }}\n\nClassify each patient message into one of the following:\n\nStatus:\n\n\"read\" \u2013 if the patient mentions any symptoms, pain (even mild), discomfort, medication issue, temperature change (hot/cold), swelling, unusual feelings, wound concerns, or anything that may require monitoring.\n\n\"ignore\" \u2013 if the patient gives only positive, reassuring updates like feeling fine, healing well, no problems, etc.\n\nIf the status is \"read\", also include:\n\nintensity:\n\nlow \u2013 minor or occasional discomfort, mild pain, or temporary symptoms that do not sound urgent or worrying.\n\nmoderate \u2013 symptoms that are persistent, noticeable, or could affect healing (e.g., swelling, ongoing pain, medication confusion).\n\nhigh \u2013 urgent or severe symptoms that may need immediate care, such as sharp pain, high fever, heavy bleeding, signs of infection, etc.\n\nYour response format should be:\n\nstatus: read\nintensity: moderate\nOr:\n\nstatus: ignore",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "8ab879ea-f8ac-4773-8fd3-9c34f39e6e73",
      "name": "Google Gemini Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        232,
        768
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e97bf2ae-ef95-4eaa-811c-45fe5653d568",
      "name": "AI Agent5",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2064,
        -256
      ],
      "parameters": {
        "text": "=You are a medical assistant AI responsible for preparing urgent notification emails to doctors when a post-surgery patient shows signs that may need immediate medical attention.\n\nInput data:\n- Patient name: {{ $('Telegram Trigger').item.json.message.from.first_name }}\n- Patient message: \"{{ $('Telegram Trigger').item.json.message.text }}\"\n- Message intensity:  {{ $('Code1').item.json.intensity }} (values: low, moderate, high)\n\nYour task:\nGenerate a **formal, professional email** that will be sent to the patient's assigned doctor (at {{ $json.doctor_email }}).\n\nThe email must:\n1. Clearly state who the patient is\n2. Summarize the concern based on their message\n3. Link the concern to the surgery (do not go beyond surgery context)\n4. Specify the **intensity** level of the concern\n5. Politely request the doctor to review the situation and respond if needed\n6. Be concise, respectful, and medically relevant\n\nThe email must have:\n- A subject line appropriate to the urgency\n- A brief intro\n- A clear summary of the issue\n- A respectful closing\n\n\u26a0\ufe0f Do not fabricate medical details. Only use what's provided. Do not guess history. Focus only on the surgery type and message content.\n",
        "options": {
          "systemMessage": "for patients surgery type and doctors mail id check for google sheet\nalso use gmail to send mail to doctor"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "80e402f5-ea97-415d-be46-da6afc950db0",
      "name": "Google Gemini Chat Model5",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1952,
        -32
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cb93c424-d3d7-4fb6-9169-ca1b0884db85",
      "name": "Get row(s) in sheet in Google Sheets4",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        2080,
        -32
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qa6cQgdaxfA3qLW2ZRBB0uq2rrp3FoFr-RzUkMeyCsg/edit?usp=drivesdk",
          "cachedResultName": "patiants list"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "693414d4-2b23-49eb-aa94-759a00387838",
      "name": "Send a message in Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        2208,
        -32
      ],
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {},
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "93fd5155-346c-4170-8d66-e2c84e6d5a86",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        2336,
        -32
      ],
      "parameters": {
        "url": "https://api.vapi.ai/call",
        "options": {},
        "jsonBody": "{\n  \"assistantId\": \"b208b330-51f2-47a7-b3b1-3d73f3ab09b5\",\n  \"phoneNumberId\": \"694f09bf-a35a-4749-960b-a4e82e916344\",\n  \"customer\": {\n  \"number\": \"+1234567890\"\n  }\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "78c6bd9d-ff94-4770-9897-4a37b35c2cf3",
      "name": "AI Agent6",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2096,
        352
      ],
      "parameters": {
        "text": "={{ $('AI Agent').item.json.output }}\ncrete a event at calender and send message about it on telegrame\ncurrent date: {{ $now }}",
        "options": {
          "systemMessage": "you have to create a appointment to after 1-2 days and send a telegram msg informing them\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "8cf41952-5c2f-4ce7-9167-300bd0ff6bcb",
      "name": "Google Gemini Chat Model6",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2048,
        576
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2faa85fa-faf6-4f84-be2b-1c1195c79760",
      "name": "Create an event in Google Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        2176,
        576
      ],
      "parameters": {
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "user@example.com"
        },
        "additionalFields": {}
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "de96ada6-5e0d-4c74-bfd7-7816998349cd",
      "name": "Send a text message in Telegram",
      "type": "n8n-nodes-base.telegramTool",
      "position": [
        2304,
        576
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1fd5fa3b-0fba-4524-83b5-3db589ba6445",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        -416
      ],
      "parameters": {
        "width": 880,
        "height": 960,
        "content": "## AI-Powered Post-Surgery Patient Care & Communication\n\n### How it works\n1. Daily, the workflow retrieves post-surgery patient data from your Google Sheet.\n2. It automatically sends personalized well-being follow-up messages to patients within their recovery period via Telegram.\n3. When a patient replies, an AI agent analyzes their message to determine the concern's intensity (low, moderate, high).\n4. An appropriate, empathetic Telegram response is sent based on the classified intensity.\n5. For moderate concerns, a follow-up appointment is scheduled; for high concerns, the doctor is immediately notified by email and a phone call is initiated.\n\n### Setup\n- [ ] Connect your Google Sheets account and specify the patient data spreadsheet.\n- [ ] Connect your Telegram account to send and receive patient messages.\n- [ ] Add your Google Gemini API key for AI message processing.\n- [ ] Connect your Google Calendar account for scheduling follow-up events.\n- [ ] Connect your Gmail account to send urgent doctor notifications.\n- [ ] Configure your VAPI.ai API key for automated doctor calls.\n- [ ] Set the desired daily schedule for proactive patient outreach."
      },
      "typeVersion": 1
    },
    {
      "id": "a939c944-e356-43c7-9688-3e7aff3e471d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 576,
        "content": "## 1. Pull patients details to check if follow up is needed"
      },
      "typeVersion": 1
    },
    {
      "id": "c7844390-ea64-4adb-8581-06b4a9c9c806",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        384
      ],
      "parameters": {
        "color": 7,
        "width": 1360,
        "height": 560,
        "content": "## 2. review patient messages to clasify the intensity"
      },
      "typeVersion": 1
    },
    {
      "id": "607121ca-8b42-4241-9da3-0e2cfc01517a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        320
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 512,
        "content": "## 3. route response"
      },
      "typeVersion": 1
    },
    {
      "id": "c68669a4-541f-4b5a-a3cb-d7ed2d79032a",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        896
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 496,
        "content": "## 4. Low intensity reply"
      },
      "typeVersion": 1
    },
    {
      "id": "d4a1f798-3801-401d-8477-254941739860",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1296,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 1216,
        "height": 496,
        "content": "## 5.  Resasure assure patient and schedule an appointment\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4eeb5b19-7b1a-41c7-a4fa-bbf13455b934",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 1136,
        "height": 512,
        "content": "## 6. Initiate call, inform doctor and scheduledappointment for high intensity"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "feedback msg",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "AI Agent3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "AI Agent4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Send a text message4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent2": {
      "main": [
        [
          {
            "node": "Send a text message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent3": {
      "main": [
        [
          {
            "node": "Send a text message3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent4": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "ai_tool": [
        [
          {
            "node": "AI Agent5",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message2": {
      "main": [
        [
          {
            "node": "AI Agent6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message3": {
      "main": [
        [
          {
            "node": "AI Agent5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message in Gmail": {
      "ai_tool": [
        [
          {
            "node": "AI Agent5",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent4",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent5",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model6": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent6",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message in Telegram": {
      "ai_tool": [
        [
          {
            "node": "AI Agent6",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create an event in Google Calendar": {
      "ai_tool": [
        [
          {
            "node": "AI Agent6",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets2": {
      "ai_tool": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets3": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet in Google Sheets4": {
      "ai_tool": [
        [
          {
            "node": "AI Agent5",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}

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

This template is for clinics, hospitals, care teams, and telemedicine providers who need a structured, automated system for post-surgery follow-up. It helps reduce manual workload while ensuring every patient gets timely check-ins and appropriate triage.

Source: https://n8n.io/workflows/11649/ — 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

Template Name: AI Personal Assistant - Task & Email Management Price: $27 Category: Productivity & Automation Difficulty: Intermediate Use Case: Personal productivity automation for busy professionals

Telegram, HTTP Request, OpenAI +8
AI & RAG

Categories: Lead Generation, Business Automation, AI

Agent, Google Gemini Chat, Gmail Tool +3
AI & RAG

Are you drowning in daily operational chaos, desperately trying to juggle sales, projects, content, and client communication? Imagine an AI brain that handles it all, freeing you to lead your business

Telegram Trigger, Telegram, OpenAI +13
AI & RAG

This project is a template for building a complete academic virtual assistant using n8n. It connects to Telegram, answers frequently asked questions by querying MongoDB, keeps the community informed a

Telegram, MongoDB, Telegram Trigger +6
AI & RAG

Telegram Trigger receives incoming messages (text, voice, photo, document). Switch routes by message type to appropriate processors: Text → forwarded as-is. Voice → downloaded and sent to Transcribe a

Memory Buffer Window, Telegram Trigger, Telegram +12