监控血库库存并发送低血型警报
这是一个Miscellaneous, Multimodal AI领域的自动化工作流,包含 6 个节点。主要使用 Code, Cron, WhatsApp, GoogleSheets, SplitInBatches 等节点。 使用 Google Sheets 和 WhatsApp 监控血库库存并发送低库存告警
- •Google Sheets API 凭证
{
"id": "gwxWo0IhhGanHkLX",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "监控血库库存并发送低血型警报",
"tags": [],
"nodes": [
{
"id": "629d6117-e428-43ca-ba31-91bef4bed7b8",
"name": "检查库存可用性",
"type": "n8n-nodes-base.code",
"position": [
-340,
360
],
"parameters": {
"jsCode": "// Check for low blood stock levels\nconst items = $input.all();\nconst lowBloodStock = [];\n\nfor (const item of items) {\n const bloodStock = item.json;\n // Threshold per blood group, can be set in data or default to 10 units\n const threshold = bloodStock.threshold || 10;\n if (bloodStock.quantity <= threshold) {\n lowBloodStock.push({\n blood_group: bloodStock.blood_group,\n quantity: bloodStock.quantity,\n threshold: threshold,\n alert_message: `Low blood stock alert: ${bloodStock.blood_group} has only ${bloodStock.quantity} units left (threshold: ${threshold})`\n });\n }\n}\n\nreturn lowBloodStock.map(blood => ({ json: blood }));\n"
},
"typeVersion": 2
},
{
"id": "edc2d357-9e97-47f4-b81d-b5152cf26d1a",
"name": "发送警报消息",
"type": "n8n-nodes-base.whatsApp",
"position": [
-120,
515
],
"webhookId": "c1770fb6-0bed-4d94-9653-a3008d42e728",
"parameters": {
"textBody": "=⚠️ Blood Stock Alert – {{ $now }}\n\nBlood group(s) low or unavailable:\n{{ $json.lowBloodList }}\n\nPlease arrange urgent replenishment to ensure availability for patients in need.\n\nFor help, contact the blood bank team.\n\nThank you!",
"operation": "send",
"phoneNumberId": "=+919998887765",
"additionalFields": {},
"recipientPhoneNumber": "=+919988223377"
},
"credentials": {
"whatsAppApi": {
"id": "b0PxTDPdWzznWnfG",
"name": "WhatsApp-test "
}
},
"typeVersion": 1
},
{
"id": "96e4c613-da63-4e26-9d49-4155837b6ade",
"name": "获取血液库存",
"type": "n8n-nodes-base.googleSheets",
"position": [
-780,
515
],
"parameters": {
"range": "Stock!A:E",
"options": {},
"sheetId": "{{your_google_sheet_id}}",
"authentication": "serviceAccount"
},
"credentials": {
"googleApi": {
"id": "ScSS2KxGQULuPtdy",
"name": "Google Sheets- test"
}
},
"typeVersion": 2
},
{
"id": "cf195b8e-8bd0-401e-8ea7-23af2e6eca09",
"name": "每日检查血液库存",
"type": "n8n-nodes-base.cron",
"position": [
-1000,
515
],
"parameters": {
"triggerTimes": {
"item": [
{
"hour": 8
}
]
}
},
"typeVersion": 1
},
{
"id": "5e38254b-2b2d-4aa4-b44a-0d7b20a7f2ed",
"name": "获取所有库存",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-560,
515
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "0189887f-a549-46fb-a92f-f045f7737209",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1140,
40
],
"parameters": {
"color": 4,
"width": 520,
"height": 360,
"content": "## 工作流程"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "8bf5da17-7278-4dba-887f-9bc593416aac",
"connections": {
"Get All Stock ": {
"main": [
[],
[
{
"node": "Check Stock Availability",
"type": "main",
"index": 0
}
]
]
},
"Fetch Blood Stock": {
"main": [
[
{
"node": "Get All Stock ",
"type": "main",
"index": 0
}
]
]
},
"Send Alert Message": {
"main": [
[
{
"node": "Get All Stock ",
"type": "main",
"index": 0
}
]
]
},
"Check Stock Availability": {
"main": [
[
{
"node": "Send Alert Message",
"type": "main",
"index": 0
}
]
]
},
"Daily Check Blood Stock ": {
"main": [
[
{
"node": "Fetch Blood Stock",
"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.
分享此工作流