This workflow follows the Agent → Googlegemini 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 →
{
"name": "PioneDream",
"nodes": [
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "16d97229-9076-4c88-bc06-76a52948c4b7",
"name": "full_name",
"value": "={{ $('Webhook_Zalo').item.json.body.message.from.display_name }}",
"type": "string"
},
{
"id": "dec8df0a-6acd-4469-bb28-866366672ef3",
"name": "id_chat",
"value": "={{ $('Webhook_Zalo').item.json.body.message.chat.id }}",
"type": "string"
},
{
"id": "14640f4f-2d13-4811-8dda-62e4713a0627",
"name": "message",
"value": "={{ $json.body.message.text }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1344,
640
],
"id": "ee1d6deb-8acd-483d-ab15-335b78b0c8a0",
"name": "Edit Fields"
},
{
"parameters": {},
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
1248,
992
],
"id": "d7fd1414-18cd-4f6e-ae0e-89bf3a371d40",
"name": "No Operation, do nothing"
},
{
"parameters": {
"triggerMode": "listenTrigger",
"channelName": "user_linked_event",
"options": {}
},
"type": "n8n-nodes-base.postgresTrigger",
"typeVersion": 1,
"position": [
576,
1312
],
"id": "ffab63af-5ec0-470b-b3da-12fa270102a9",
"name": "Postgres Trigger",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "executeQuery",
"query": "-- X\u00f3a function c\u0169 n\u1ebfu c\u00f3\nDROP FUNCTION IF EXISTS public.notify_user_linked_event();\n\n-- 1\ufe0f\u20e3 T\u1ea1o function\nCREATE OR REPLACE FUNCTION public.notify_user_linked_event()\nRETURNS TRIGGER AS $$\nDECLARE\n payload JSON;\nBEGIN\n -- Ch\u1ec9 k\u00edch ho\u1ea1t khi user \u0111\u01b0\u1ee3c li\u00ean k\u1ebft th\u00e0nh c\u00f4ng (c\u00f3 zalo_chat_id m\u1edbi)\n IF (TG_OP = 'UPDATE' AND NEW.zalo_chat_id IS NOT NULL AND OLD.zalo_chat_id IS DISTINCT FROM NEW.zalo_chat_id) THEN\n payload := json_build_object(\n 'event', 'user_linked',\n 'user_id', NEW.id,\n 'full_name', NEW.full_name,\n 'wallet_address', NEW.wallet_address,\n 'zalo_chat_id', NEW.zalo_chat_id,\n 'linked_at', now()\n );\n\n -- G\u1eedi th\u00f4ng b\u00e1o qua k\u00eanh \"user_linked_event\"\n PERFORM pg_notify('user_linked_event', payload::text);\n END IF;\n\n RETURN NEW;\nEND;\n$$ LANGUAGE plpgsql;\n\n-- 2\ufe0f\u20e3 X\u00f3a trigger c\u0169 n\u1ebfu c\u00f3\nDROP TRIGGER IF EXISTS trg_user_linked_event ON public.users;\n\n-- 3\ufe0f\u20e3 T\u1ea1o trigger m\u1edbi g\u1eafn v\u00e0o b\u1ea3ng users\nCREATE TRIGGER trg_user_linked_event\nAFTER UPDATE ON public.users\nFOR EACH ROW\nEXECUTE FUNCTION public.notify_user_linked_event();\n",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
560,
288
],
"id": "38009d93-e757-4b92-a74a-3a1982ad4e12",
"name": "trigger user_contact_update",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "=C\u00e2u h\u1ecfi c\u1ee7a ng\u01b0\u1eddi d\u00f9ng:\n\"{{ $('Webhook_Zalo').item.json.body.message.text }}\"\nV\u1edbi c\u00e1c th\u00f4ng ng\u01b0\u1eddi d\u00f9ng:\nH\u1ecd T\u00ean: {{ $('Webhook_Zalo').item.json.body.message.from.display_name }}\nId: {{ $json.id }}\nwallet_address: {{ $json.wallet_address }}",
"options": {
"systemMessage": "=\ud83c\udfaf Vai tr\u00f2 c\u1ee7a b\u1ea1n:\nB\u1ea1n l\u00e0 **GAIA.VN AI Agent**, tr\u1ee3 l\u00fd n\u00f4ng nghi\u1ec7p th\u00f4ng minh c\u1ee7a n\u1ec1n t\u1ea3ng DApp GAIA.VN. \nB\u1ea1n c\u00f3 kh\u1ea3 n\u0103ng:\n1\ufe0f\u20e3 Tr\u1ea3 l\u1eddi c\u00e1c c\u00e2u h\u1ecfi l\u00fd thuy\u1ebft, k\u1ef9 n\u0103ng, v\u00e0 ki\u1ebfn th\u1ee9c n\u00f4ng nghi\u1ec7p (\u0111\u1ea5t, n\u01b0\u1edbc, c\u00e2y tr\u1ed3ng, dinh d\u01b0\u1ee1ng, canh t\u00e1c, m\u00f4i tr\u01b0\u1eddng, IoT, AI, blockchain,...). \n2\ufe0f\u20e3 G\u1ecdi c\u00f4ng c\u1ee5 **User Lookup** \u0111\u1ec3 tra c\u1ee9u th\u00f4ng tin ng\u01b0\u1eddi d\u00f9ng hi\u1ec7n t\u1ea1i (v\u00ed d\u1ee5: v\u00ed blockchain, ID thi\u1ebft b\u1ecb, v\u1ecb tr\u00ed canh t\u00e1c, h\u1ecd t\u00ean...). \n3\ufe0f\u20e3 G\u1ecdi c\u00f4ng c\u1ee5 **Data Query** \u0111\u1ec3 truy xu\u1ea5t d\u1eef li\u1ec7u c\u1ea3m bi\u1ebfn, ph\u00e2n t\u00edch AI, ho\u1eb7c log blockchain c\u1ee7a ng\u01b0\u1eddi d\u00f9ng. \n\n---\n\n### \ud83e\udde9 C\u00e1ch ra quy\u1ebft \u0111\u1ecbnh:\n\n**N\u1ebfu c\u00e2u h\u1ecfi thu\u1ed9c nh\u00f3m l\u00fd thuy\u1ebft ho\u1eb7c ki\u1ebfn th\u1ee9c chung** \n\u2192 Kh\u00f4ng c\u1ea7n d\u00f9ng tool n\u00e0o. \n\u2192 Tr\u1ea3 l\u1eddi tr\u1ef1c ti\u1ebfp b\u1eb1ng ki\u1ebfn th\u1ee9c c\u1ee7a b\u1ea1n (ng\u1eafn g\u1ecdn, d\u1ec5 hi\u1ec3u, c\u00f3 v\u00ed d\u1ee5 th\u1ef1c t\u1ebf).\n\n**N\u1ebfu c\u00e2u h\u1ecfi y\u00eau c\u1ea7u th\u00f4ng tin c\u00e1 nh\u00e2n ho\u1eb7c d\u1eef li\u1ec7u ng\u01b0\u1eddi d\u00f9ng** \n(v\u00ed d\u1ee5: \u201cT\u00f4i l\u00e0 ai?\u201d, \u201cV\u00ed c\u1ee7a t\u00f4i l\u00e0 g\u00ec?\u201d, \u201cThi\u1ebft b\u1ecb c\u1ee7a t\u00f4i ID bao nhi\u00eau?\u201d) \n\u2192 G\u1ecdi **User Lookup Tool**. \n\u2192 Sau khi nh\u1eadn k\u1ebft qu\u1ea3, t\u00f3m t\u1eaft v\u00e0 tr\u1ea3 l\u1eddi th\u00e2n thi\u1ec7n. \n\n**N\u1ebfu c\u00e2u h\u1ecfi li\u00ean quan \u0111\u1ebfn d\u1eef li\u1ec7u th\u1ef1c t\u1ebf** \n(v\u00ed d\u1ee5: \u201cCh\u1ea5t l\u01b0\u1ee3ng n\u01b0\u1edbc h\u00f4m nay sao?\u201d, \u201cAI d\u1ef1 \u0111o\u00e1n c\u00e2y tr\u1ed3ng t\u00f4i th\u1ebf n\u00e0o?\u201d, \n\u201cD\u1eef li\u1ec7u IoT c\u1ee7a t\u00f4i g\u1ea7n nh\u1ea5t l\u00e0 g\u00ec?\u201d, \u201cD\u1eef li\u1ec7u \u0111\u00e3 l\u00ean blockchain ch\u01b0a?\u201d) \n\u2192 G\u1ecdi **Data Query Tool**. \n\u2192 Sau khi nh\u1eadn d\u1eef li\u1ec7u, di\u1ec5n gi\u1ea3i \u00fd ngh\u0129a, c\u1ea3nh b\u00e1o n\u1ebfu b\u1ea5t th\u01b0\u1eddng, \nv\u00e0 th\u00eam nh\u1eadn x\u00e9t ho\u1eb7c l\u1eddi khuy\u00ean n\u00f4ng nghi\u1ec7p ph\u00f9 h\u1ee3p.\n\n---\n\n### \ud83d\udcd8 H\u01b0\u1edbng d\u1eabn tr\u1ea3 l\u1eddi:\n- Tr\u1ea3 l\u1eddi b\u1eb1ng **ti\u1ebfng Vi\u1ec7t t\u1ef1 nhi\u00ean**, th\u00e2n thi\u1ec7n v\u00e0 d\u1ec5 hi\u1ec3u. \n- N\u1ebfu d\u1eef li\u1ec7u c\u00f3 v\u1ea5n \u0111\u1ec1 (pH < 5.5, \u0111\u1ed9 m\u1eb7n > 1.0\u2030, AI score < 6) \u2192 \u0111\u01b0a **c\u1ea3nh b\u00e1o nh\u1eb9 nh\u00e0ng** v\u00e0 **h\u01b0\u1edbng d\u1eabn x\u1eed l\u00fd**. \n- N\u1ebfu d\u1eef li\u1ec7u t\u1ed1t \u2192 \u0111\u01b0a l\u1eddi kh\u00edch l\u1ec7 (\u201cr\u1ea5t t\u1ed1t\u201d, \u201c\u1ed5n \u0111\u1ecbnh\u201d, \u201cduy tr\u00ec nh\u01b0 v\u1eady nh\u00e9 \ud83c\udf3f\u201d). \n- Th\u00eam m\u1ed9t \u00edt icon cho t\u1ef1 nhi\u00ean v\u00e0 \u0111\u1ecbnh d\u1ea1ng ch\u1eef th\u01b0\u1eddng kh\u00f4ng c\u1ea7n in \u0111\u1eadm,ngang,...\n- N\u1ebfu kh\u00f4ng c\u00f3 d\u1eef li\u1ec7u, tr\u1ea3 l\u1eddi: \u201cHi\u1ec7n t\u1ea1i h\u1ec7 th\u1ed1ng ch\u01b0a ghi nh\u1eadn d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n.\u201d \n- N\u1ebfu ng\u01b0\u1eddi d\u00f9ng h\u1ecfi ngo\u00e0i ph\u1ea1m vi (v\u00ed d\u1ee5 ch\u00ednh tr\u1ecb, t\u00f4n gi\u00e1o), h\u00e3y n\u00f3i l\u1ecbch s\u1ef1: \u201cT\u00f4i ch\u1ec9 h\u1ed7 tr\u1ee3 c\u00e1c v\u1ea5n \u0111\u1ec1 n\u00f4ng nghi\u1ec7p v\u00e0 d\u1eef li\u1ec7u m\u00f4i tr\u01b0\u1eddng.\u201d \n\n---\n\n### \u2699\ufe0f C\u1ea5u tr\u00fac logic:\n\n1\ufe0f\u20e3 Hi\u1ec3u c\u00e2u h\u1ecfi c\u1ee7a ng\u01b0\u1eddi d\u00f9ng \n2\ufe0f\u20e3 Quy\u1ebft \u0111\u1ecbnh: **Chat b\u00ecnh th\u01b0\u1eddng / G\u1ecdi User Lookup / G\u1ecdi Data Query** \n3\ufe0f\u20e3 N\u1ebfu g\u1ecdi tool \u2192 \u0111\u1ee3i k\u1ebft qu\u1ea3 \u2192 ph\u00e2n t\u00edch \u2192 tr\u1ea3 l\u1eddi \n4\ufe0f\u20e3 N\u1ebfu kh\u00f4ng c\u1ea7n tool \u2192 tr\u1ea3 l\u1eddi tr\u1ef1c ti\u1ebfp \n\n---\n\n### \ud83e\udde0 M\u1ee5c ti\u00eau cu\u1ed1i:\nT\u1ea1o tr\u1ea3i nghi\u1ec7m t\u1ef1 nhi\u00ean nh\u01b0 m\u1ed9t **chuy\u00ean gia n\u00f4ng nghi\u1ec7p \u1ea3o**, \nnh\u01b0ng v\u1eabn bi\u1ebft c\u00e1ch **truy xu\u1ea5t d\u1eef li\u1ec7u th\u1eadt c\u1ee7a ng\u01b0\u1eddi d\u00f9ng** khi c\u1ea7n. \nLu\u00f4n \u0111\u1ea3m b\u1ea3o \u0111\u1ed9 ch\u00ednh x\u00e1c, r\u00f5 r\u00e0ng v\u00e0 th\u00e2n thi\u1ec7n.\n"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 2.2,
"position": [
2416,
256
],
"id": "e7c0cc62-ec74-4f72-ba09-503e6d729d93",
"name": "AI Agent"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"typeVersion": 1,
"position": [
2304,
464
],
"id": "6dfa59e4-6d8c-4e5b-9bfc-3f212294b5f7",
"name": "Google Gemini Chat Model",
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## Trigger th\u00f4ng b\u00e1o li\u00ean k\u1ebft t\u00e0i kho\u1ea3n zalo th\u00e0nh c\u00f4ng\n",
"height": 304,
"width": 1296
},
"type": "n8n-nodes-base.stickyNote",
"position": [
480,
1216
],
"typeVersion": 1,
"id": "696fce10-7674-49fc-ab3f-80e666e9a9a5",
"name": "Sticky Note"
},
{
"parameters": {
"multipleMethods": true,
"httpMethod": [
"POST"
],
"path": "chat-zalo",
"responseMode": "lastNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
544,
752
],
"id": "bfe6cc8c-d75a-4ddb-a547-ef666be1cf27",
"name": "Webhook_Zalo"
},
{
"parameters": {
"method": "POST",
"url": "https://bot-api.zapps.me/bot2636990041745555077:sIBMRsWMvGYeFkBOgbNBuFglputEIxZtlVdRIeByFyZDfpFmaduLvoWPTpmMFcxT/setWebhook",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "http://36.50.135.18/webhook/chat-zalo"
},
{
"name": "secret_token",
"value": "ttadz123"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1232,
304
],
"id": "3a1a374b-9226-4745-bc33-8ce069592ab5",
"name": "SetWebHook"
},
{
"parameters": {
"method": "POST",
"url": "https://bot-api.zapps.me/bot2636990041745555077:sIBMRsWMvGYeFkBOgbNBuFglputEIxZtlVdRIeByFyZDfpFmaduLvoWPTpmMFcxT/deleteWebhook",
"sendBody": true,
"bodyParameters": {
"parameters": [
{}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1040,
304
],
"id": "cf4f8894-0df9-4c9a-bbd8-ffa4f19f8287",
"name": "DeleteWebHook"
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT event_object_table, trigger_name, action_timing, event_manipulation, action_statement\nFROM information_schema.triggers\nWHERE event_object_table = 'users';\n",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
768,
304
],
"id": "73563e17-1872-41be-8d1f-d8578f7f7031",
"name": "Execute a SQL query",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"table": {
"__rl": true,
"value": "users",
"mode": "list",
"cachedResultName": "users"
},
"where": {
"values": [
{
"column": "id",
"value": "={{ $('L\u1ea5y th\u00f4ng tin User').item.json.id }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
2624,
496
],
"id": "9f5ac789-9bae-41e0-8402-054ff3fedf93",
"name": "User Lookup",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"table": {
"__rl": true,
"value": "sensor_readings",
"mode": "list",
"cachedResultName": "sensor_readings"
},
"limit": 5,
"sort": {
"values": [
{
"column": "measured_at_vn",
"direction": "DESC"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
2736,
464
],
"id": "616317ca-730f-4c91-a19f-bc579e934852",
"name": "Data Query",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## Trigger g\u1eedi b\u00e1o c\u00e1o 20h h\u1eb1ng ng\u00e0y \n",
"height": 448,
"width": 2144
},
"type": "n8n-nodes-base.stickyNote",
"position": [
480,
1552
],
"typeVersion": 1,
"id": "a466a9e2-99cd-49c1-a2e1-11af1da74c8c",
"name": "Sticky Note1"
},
{
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 20
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
528,
1728
],
"id": "cb28e256-0564-41e7-8593-9e41e808a9d8",
"name": "Schedule Trigger"
},
{
"parameters": {
"modelId": {
"__rl": true,
"value": "models/gemini-2.5-flash",
"mode": "list",
"cachedResultName": "models/gemini-2.5-flash"
},
"messages": {
"values": [
{
"content": "=\ud83c\udf3e B\u1ea1n l\u00e0 tr\u1ee3 l\u00fd GAIA.VN AI n\u00f4ng nghi\u1ec7p th\u00f4ng minh.\n\nD\u01b0\u1edbi \u0111\u00e2y l\u00e0 d\u1eef li\u1ec7u trung b\u00ecnh c\u1ea3m bi\u1ebfn c\u1ee7a ng\u00e0y h\u00f4m nay:\n{{ JSON.stringify($json, null, 2) }}\n\n\nH\u00e3y vi\u1ebft m\u1ed9t **b\u1ea3n b\u00e1o c\u00e1o ng\u1eafn g\u1ecdn, d\u1ec5 hi\u1ec3u (4\u20136 c\u00e2u)** b\u1eb1ng ti\u1ebfng Vi\u1ec7t,\nd\u00e0nh cho ng\u01b0\u1eddi n\u00f4ng d\u00e2n (kh\u00f4ng k\u1ef9 thu\u1eadt, kh\u00f4ng li\u1ec7t k\u00ea s\u1ed1 li\u1ec7u d\u1ea1ng b\u1ea3ng).\n\nY\u00eau c\u1ea7u:\n1\ufe0f\u20e3 M\u1edf \u0111\u1ea7u b\u1eb1ng ng\u00e0y h\u00f4m nay (v\u00ed d\u1ee5: \"\ud83d\udcc5 B\u00e1o c\u00e1o ng\u00e0y 4/11/2025:\") - n\u1ebfu kh\u00f4ng c\u00f3 th\u00ec d\u1eef li\u1ec7u th\u00ec n\u00f3i kh\u00f4ng t\u00ecm th\u1ea5y d\u1eef li\u1ec7u n\u00e0o....\n2\ufe0f\u20e3 T\u00f3m t\u1eaft t\u00ecnh h\u00ecnh:\n - Nhi\u1ec7t \u0111\u1ed9 \u0111\u1ea5t & kh\u00f4ng kh\u00ed (m\u00e1t, n\u00f3ng, \u1ed5n \u0111\u1ecbnh)\n - \u0110\u1ed9 \u1ea9m \u0111\u1ea5t & kh\u00f4ng kh\u00ed (\u0111\u1ee7, thi\u1ebfu, cao)\n - pH \u0111\u1ea5t (trung t\u00ednh, chua, ki\u1ec1m)\n - T\u00ecnh h\u00ecnh m\u01b0a h\u00f4m nay (n\u1ebfu c\u00f3)\n3\ufe0f\u20e3 \u0110\u01b0a ra \u0111\u00e1nh gi\u00e1 t\u1ed5ng quan v\u1ec1 **s\u1ee9c kh\u1ecfe \u0111\u1ea5t** v\u00e0 **m\u00f4i tr\u01b0\u1eddng tr\u1ed3ng tr\u1ecdt** h\u00f4m nay.\n4\ufe0f\u20e3 N\u1ebfu c\u00f3 d\u1ea5u hi\u1ec7u b\u1ea5t th\u01b0\u1eddng (v\u00ed d\u1ee5 pH th\u1ea5p, \u0111\u1ea5t kh\u00f4, n\u00f3ng qu\u00e1), h\u00e3y th\u00eam c\u1ea3nh b\u00e1o ng\u1eafn.\n5\ufe0f\u20e3 Th\u00eam **g\u1ee3i \u00fd cho ng\u00e0y mai**: \n - N\u00ean l\u00e0m g\u00ec (t\u01b0\u1edbi th\u00eam, ki\u1ec3m tra pH, ngh\u1ec9 t\u01b0\u1edbi, b\u00f3n ph\u00e2n nh\u1eb9, v.v.)\n6\ufe0f\u20e3 K\u1ebft th\u00fac b\u1eb1ng l\u1eddi kh\u00edch l\u1ec7 t\u00edch c\u1ef1c, v\u00ed d\u1ee5:\n \u201cC\u1ea3m \u01a1n b\u1ea1n \u0111\u00e3 \u0111\u1ed3ng h\u00e0nh c\u00f9ng h\u1ec7 th\u1ed1ng AI N\u00f4ng Nghi\u1ec7p Th\u00f4ng Minh \ud83c\udf31.\u201d\n\nVi\u1ebft th\u00e0nh t\u1ef1 nhi\u00ean, th\u00e2n thi\u1ec7n, v\u00e0 truy\u1ec1n c\u1ea3m h\u1ee9ng.\nKh\u00f4ng c\u1ea7n hi\u1ec3n th\u1ecb s\u1ed1 c\u1ee5 th\u1ec3, h\u00e3y di\u1ec5n \u0111\u1ea1t c\u1ea3m nh\u1eadn t\u1ed5ng qu\u00e1t.\n"
}
]
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.googleGemini",
"typeVersion": 1,
"position": [
1040,
1728
],
"id": "40b2b498-47cc-471c-9d0c-b45018d183e3",
"name": "Message a model",
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
1648,
1680
],
"id": "497c53fb-fa92-4b15-8c28-03a30611eacd",
"name": "Loop Over Items"
},
{
"parameters": {},
"type": "n8n-nodes-base.noOp",
"name": "Replace Me",
"typeVersion": 1,
"position": [
2368,
1808
],
"id": "81c095cb-0390-4ae6-aba4-f8ffeba65522"
},
{
"parameters": {},
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
1984,
1568
],
"id": "718f4c6c-1af8-4370-a192-c3b601bcfdd8",
"name": "No Operation, do nothing1"
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $json.zalo_chat_id }}"
},
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1.3,
"position": [
2464,
480
],
"id": "252e82fd-0b8d-49d5-84ab-48b828bb84cc",
"name": "Postgres Chat Memory",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## Chat",
"height": 480,
"width": 1184,
"color": 6
},
"type": "n8n-nodes-base.stickyNote",
"position": [
2176,
176
],
"typeVersion": 1,
"id": "fc21c267-aa19-45cb-b40c-cce650eeabe2",
"name": "Sticky Note2"
},
{
"parameters": {
"content": "## Li\u00ean K\u1ebft",
"height": 512,
"width": 1184,
"color": 3
},
"type": "n8n-nodes-base.stickyNote",
"position": [
2176,
784
],
"typeVersion": 1,
"id": "04ee4854-33a4-4e39-858e-a4ab0d7543ae",
"name": "Sticky Note3"
},
{
"parameters": {
"method": "POST",
"url": "https://bot-api.zapps.me/bot2636990041745555077:sIBMRsWMvGYeFkBOgbNBuFglputEIxZtlVdRIeByFyZDfpFmaduLvoWPTpmMFcxT/sendChatAction",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $json.body.message.chat.id }}"
},
{
"name": "action",
"value": "typing"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
832,
768
],
"id": "35a7c463-8e68-4a10-b3a2-7c6de12c7723",
"name": "sendChatAction"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c082f5ab-4ca8-4c0c-bf2e-b137ce7eee9a",
"leftValue": "={{ $json.body.message.message_type }}",
"rightValue": "PRIVATE",
"operator": {
"type": "string",
"operation": "notExists",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1056,
736
],
"id": "5aff1ff2-6ed8-4ad4-ba5b-2fc0d91e3aef",
"name": "Ki\u1ec3m tra input"
},
{
"parameters": {
"operation": "executeQuery",
"query": "SELECT \n id,\n full_name,\n email,\n wallet_address,\n zalo_chat_id,\n 'Found user' AS result\nFROM public.users\nWHERE zalo_chat_id = '{{ $json.id_chat }}'\n\nUNION ALL\n\nSELECT \n NULL AS id,\n NULL AS full_name,\n NULL AS email,\n NULL AS wallet_address,\n 'null' AS zalo_chat_id,\n 'No user found' AS result\nWHERE NOT EXISTS (\n SELECT 1 FROM public.users WHERE zalo_chat_id = '{{ $json.id_chat }}'\n);\n",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
1664,
704
],
"id": "3078a701-a5f1-452d-82ce-1dfc86f9bfa4",
"name": "L\u1ea5y th\u00f4ng tin User",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "fb587806-ad80-43c9-8bc4-b82e81d13cae",
"leftValue": "={{ $json.result }}",
"rightValue": "Found user",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1936,
688
],
"id": "58220294-0701-4576-b951-9cd22729fdf8",
"name": "Ki\u1ec3m tra user li\u00ean k\u1ebft t\u00e0i kho\u1ea3n"
},
{
"parameters": {
"content": "## Zalo chatbot",
"height": 608,
"width": 1648,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"position": [
496,
528
],
"typeVersion": 1,
"id": "e82504b6-1ab6-4104-ac92-2e60d0216232",
"name": "Sticky Note4"
},
{
"parameters": {
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"table": {
"__rl": true,
"value": "zalo_link_sessions",
"mode": "list",
"cachedResultName": "zalo_link_sessions"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"token": "={{ $json.token }}",
"user_id": 0,
"zalo_id": "={{ $json.zalo_id }}",
"expires_at": "={{ $json.expiresAt }}"
},
"matchingColumns": [
"id"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "zalo_id",
"displayName": "zalo_id",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "token",
"displayName": "token",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "expires_at",
"displayName": "expires_at",
"required": true,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "created_at",
"displayName": "created_at",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "is_used",
"displayName": "is_used",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "user_id",
"displayName": "user_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
2704,
1008
],
"id": "7c654c8f-4b10-4703-8501-2a9f0ca35e32",
"name": "T\u1ea1o token session",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"action": "generate",
"encodingType": "base64"
},
"type": "n8n-nodes-base.crypto",
"typeVersion": 1,
"position": [
2272,
992
],
"id": "1e6d135e-5fcf-466b-866c-b4fad0ab149d",
"name": "T\u1ea1o Token"
},
{
"parameters": {
"jsCode": "const zalo_id = $('Edit Fields').first().json.id_chat;\nconst token = $input.first().json.data; \nconst expiresAt = new Date(Date.now() + 5 * 60 * 1000).toISOString();\n\nreturn [{ json: { token, zalo_id, expiresAt } }];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2496,
1024
],
"id": "2f63bc27-54e2-4368-b733-29b8389c3f4e",
"name": "X\u1eed l\u00fd d\u1eef li\u1ec7u"
},
{
"parameters": {
"jsCode": "const body = {\n recipient: {\n id: $input.first().json.zalo_id\n },\n message: {\n text:\n \"\ud83c\udf3e Xin ch\u00e0o \" + $('Edit Fields').first().json.full_name + \" !\\n\\n\" +\n \"\u0110\u1ec3 ho\u00e0n t\u1ea5t x\u00e1c minh v\u00e0 li\u00ean k\u1ebft t\u00e0i kho\u1ea3n c\u1ee7a b\u1ea1n v\u1edbi h\u1ec7 th\u1ed1ng, vui l\u00f2ng b\u1ea5m v\u00e0o li\u00ean k\u1ebft d\u01b0\u1edbi \u0111\u00e2y:\\n\\n\" +\n \"\ud83d\udd17 \" + \"https://163-61-183-90.nip.io/linkaccount?token=\" + $input.first().json.token + \"\\n\\n\" +\n \"\u23f0 L\u01b0u \u00fd: Li\u00ean k\u1ebft n\u00e0y ch\u1ec9 c\u00f3 hi\u1ec7u l\u1ef1c trong 5 ph\u00fat \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o an to\u00e0n. Sau th\u1eddi gian n\u00e0y, b\u1ea1n c\u1ea7n y\u00eau c\u1ea7u li\u00ean k\u1ebft l\u1ea1i.\\n\\n\" +\n \"C\u1ea3m \u01a1n b\u1ea1n \u0111\u00e3 tin t\u01b0\u1edfng v\u00e0 s\u1eed d\u1ee5ng h\u1ec7 th\u1ed1ng c\u1ee7a ch\u00fang t\u00f4i \ud83d\udc9a\"\n }\n};\n\nreturn [{ data: body }];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2944,
992
],
"id": "6fc36f48-9e4c-4f09-a0f4-ebb32441922e",
"name": "T\u1ea1o tin nh\u1eafn li\u00ean k\u1ebft"
},
{
"parameters": {
"method": "POST",
"url": "https://bot-api.zapps.me/bot2636990041745555077:sIBMRsWMvGYeFkBOgbNBuFglputEIxZtlVdRIeByFyZDfpFmaduLvoWPTpmMFcxT/sendMessage",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "=chat_id",
"value": "={{ $('Ki\u1ec3m tra user li\u00ean k\u1ebft t\u00e0i kho\u1ea3n').item.json.zalo_chat_id }}"
},
{
"name": "text",
"value": "={{ $json.output }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
3168,
288
],
"id": "39fef5b2-22ef-452d-a031-fedf3c15705a",
"name": "sendMessage_Chat"
},
{
"parameters": {
"method": "POST",
"url": "https://bot-api.zapps.me/bot2636990041745555077:sIBMRsWMvGYeFkBOgbNBuFglputEIxZtlVdRIeByFyZDfpFmaduLvoWPTpmMFcxT/sendMessage",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $json.data.recipient.id }}"
},
{
"name": "text",
"value": "={{ $json.data.message.text }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
3184,
1008
],
"id": "e47bf10c-7f8d-4b6b-83d1-9028e2aa347b",
"name": "sendMessage_Link"
},
{
"parameters": {
"jsCode": "// L\u1ea5y d\u1eef li\u1ec7u t\u1eeb payload c\u1ee7a trigger\nconst data = $json.payload || $json;\n\n// Format gi\u1edd Vi\u1ec7t Nam (n\u1ebfu c\u1ea7n d\u00f9ng)\nconst date = new Date(data.linked_at);\nconst linkedAtVN = date.toLocaleString('vi-VN', { timeZone: 'Asia/Ho_Chi_Minh' });\n\n// Tin nh\u1eafn ch\u00e0o m\u1eebng\nconst message = `\n\ud83c\udf3e *Xin ch\u00e0o ${data.full_name}!*\n\n\ud83c\udf89 B\u1ea1n \u0111\u00e3 *li\u00ean k\u1ebft th\u00e0nh c\u00f4ng* t\u00e0i kho\u1ea3n v\u1edbi h\u1ec7 th\u1ed1ng *AI N\u00f4ng Nghi\u1ec7p Th\u00f4ng Minh*.\n\nT\u1eeb b\u00e2y gi\u1edd, b\u1ea1n c\u00f3 th\u1ec3:\n- \ud83d\udcca Theo d\u00f5i d\u1eef li\u1ec7u IoT t\u1eeb c\u1ea3m bi\u1ebfn \u0111\u1ea5t, nhi\u1ec7t \u0111\u1ed9, \u0111\u1ed9 \u1ea9m, m\u01b0a...\n- \ud83e\udd16 Nh\u1eadn ph\u00e2n t\u00edch v\u00e0 khuy\u1ebfn ngh\u1ecb t\u1eeb AI gi\u00fap c\u1ea3i thi\u1ec7n n\u0103ng su\u1ea5t c\u00e2y tr\u1ed3ng.\n- \ud83d\udd17 L\u01b0u tr\u1eef d\u1eef li\u1ec7u minh b\u1ea1ch tr\u00ean *Zero Blockchain* \u2014 \u0111\u1ea3m b\u1ea3o an to\u00e0n v\u00e0 kh\u00f4ng th\u1ec3 b\u1ecb s\u1eeda \u0111\u1ed5i.\n- \ud83d\udcf1 Truy c\u1eadp tr\u1ef1c ti\u1ebfp DApp \u0111\u1ec3 xem bi\u1ec3u \u0111\u1ed3, d\u1ef1 b\u00e1o v\u00e0 t\u01b0 v\u1ea5n canh t\u00e1c.\n\nC\u1ea3m \u01a1n b\u1ea1n \u0111\u00e3 tin t\u01b0\u1edfng \u0111\u1ed3ng h\u00e0nh c\u00f9ng ch\u00fang t\u00f4i! \n\ud83d\udc9a Ch\u00fac b\u1ea1n m\u1ed9t m\u00f9a v\u1ee5 b\u1ed9i thu v\u00e0 canh t\u00e1c hi\u1ec7u qu\u1ea3 c\u00f9ng c\u00f4ng ngh\u1ec7 \ud83c\udf31\n`;\n\n// Tr\u1ea3 output cho node k\u1ebf ti\u1ebfp (g\u1eedi Zalo, Telegram, Discord,...)\nreturn [{\n json: {\n message,\n full_name: data.full_name,\n linked_at: linkedAtVN\n }\n}];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
992,
1344
],
"id": "c260886f-d78f-48cf-b91b-824e06768e54",
"name": "T\u1ea1o tin nh\u1eafn li\u00ean k\u1ebft th\u00e0nh c\u00f4ng"
},
{
"parameters": {
"method": "POST",
"url": "https://bot-api.zapps.me/bot2636990041745555077:sIBMRsWMvGYeFkBOgbNBuFglputEIxZtlVdRIeByFyZDfpFmaduLvoWPTpmMFcxT/sendMessage",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $('Postgres Trigger').item.json.payload.zalo_chat_id }}"
},
{
"name": "text",
"value": "={{ $json.message }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1504,
1280
],
"id": "4aa616f6-b0d0-4a9c-b7db-39eb916c85a9",
"name": "sendMessage_linksuccess"
},
{
"parameters": {
"method": "POST",
"url": "https://163-61-183-90.nip.io/api/ai/analyze-daily-insights",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
784,
1776
],
"id": "e79d53a3-9ac6-4835-bc97-5dffaea493f6",
"name": "Analyze_Daily_Insights"
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"table": {
"__rl": true,
"value": "users",
"mode": "list",
"cachedResultName": "users"
},
"where": {
"values": [
{
"column": "zalo_chat_id",
"condition": "IS NOT NULL"
}
]
},
"options": {
"outputColumns": [
"full_name",
"farm_name",
"email",
"zalo_chat_id"
]
}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
1408,
1696
],
"id": "9e677fde-0fe3-4d37-b3f6-3086a24c2dfd",
"name": "L\u1ea5y zalo id",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://bot-api.zapps.me/bot2636990041745555077:sIBMRsWMvGYeFkBOgbNBuFglputEIxZtlVdRIeByFyZDfpFmaduLvoWPTpmMFcxT/sendMessage",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "={{ $json.zalo_chat_id }}"
},
{
"name": "text",
"value": "={{ $('Message a model').item.json.content.parts[0].text }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1984,
1760
],
"id": "a374dd52-7165-4883-a159-816af7d914c3",
"name": "sendMessage_report",
"onError": "continueRegularOutput"
}
],
"connections": {
"Edit Fields": {
"main": [
[
{
"node": "L\u1ea5y th\u00f4ng tin User",
"type": "main",
"index": 0
}
]
]
},
"Postgres Trigger": {
"main": [
[
{
"node": "T\u1ea1o tin nh\u1eafn li\u00ean k\u1ebft th\u00e0nh c\u00f4ng",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "sendMessage_Chat",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Webhook_Zalo": {
"main": [
[
{
"node": "sendChatAction",
"type": "main",
"index": 0
}
],
[]
]
},
"trigger user_contact_update": {
"main": [
[]
]
},
"User Lookup": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Data Query": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Analyze_Daily_Insights",
"type": "main",
"index": 0
}
]
]
},
"Message a model": {
"main": [
[
{
"node": "L\u1ea5y zalo id",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "No Operation, do nothing1",
"type": "main",
"index": 0
}
],
[
{
"node": "sendMessage_report",
"type": "main",
"index": 0
}
]
]
},
"Replace Me": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Postgres Chat Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"sendChatAction": {
"main": [
[
{
"node": "Ki\u1ec3m tra input",
"type": "main",
"index": 0
}
]
]
},
"Ki\u1ec3m tra input": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"L\u1ea5y th\u00f4ng tin User": {
"main": [
[
{
"node": "Ki\u1ec3m tra user li\u00ean k\u1ebft t\u00e0i kho\u1ea3n",
"type": "main",
"index": 0
}
]
]
},
"Ki\u1ec3m tra user li\u00ean k\u1ebft t\u00e0i kho\u1ea3n": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
],
[
{
"node": "T\u1ea1o Token",
"type": "main",
"index": 0
}
]
]
},
"T\u1ea1o token session": {
"main": [
[
{
"node": "T\u1ea1o tin nh\u1eafn li\u00ean k\u1ebft",
"type": "main",
"index": 0
}
]
]
},
"T\u1ea1o Token": {
"main": [
[
{
"node": "X\u1eed l\u00fd d\u1eef li\u1ec7u",
"type": "main",
"index": 0
}
]
]
},
"X\u1eed l\u00fd d\u1eef li\u1ec7u": {
"main": [
[
{
"node": "T\u1ea1o token session",
"type": "main",
"index": 0
}
]
]
},
"T\u1ea1o tin nh\u1eafn li\u00ean k\u1ebft": {
"main": [
[
{
"node": "sendMessage_Link",
"type": "main",
"index": 0
}
]
]
},
"T\u1ea1o tin nh\u1eafn li\u00ean k\u1ebft th\u00e0nh c\u00f4ng": {
"main": [
[
{
"node": "sendMessage_linksuccess",
"type": "main",
"index": 0
}
]
]
},
"Analyze_Daily_Insights": {
"main": [
[
{
"node": "Message a model",
"type": "main",
"index": 0
}
]
]
},
"L\u1ea5y zalo id": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"sendMessage_report": {
"main": [
[
{
"node": "Replace Me",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"callerPolicy": "workflowsFromSameOwner",
"errorWorkflow": "1UGVnWBRTYUpHbXy"
},
"versionId": "4b08c0ac-1481-4424-963d-2bb6ad53c984",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "1UGVnWBRTYUpHbXy",
"tags": []
}
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.
googlePalmApipostgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
PioneDream. Uses postgresTrigger, postgres, agent, lmChatGoogleGemini. Event-driven trigger; 38 nodes.
Source: https://github.com/minhe51805/Pione_AIBlockchainIoT-WAGTeam/blob/09912054f0749c3355677f6e081c85725f693cb1/n8n/chatBot.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
CLINICAINTEGRAL_secretary. Uses postgres, mcpClientTool, googleDriveTool, toolWorkflow. Webhook trigger; 89 nodes.
Remi 1.1. Uses lmChatOpenAi, memoryPostgresChat, openAi, postgres. Webhook trigger; 89 nodes.
Bitlab-Chatbot. Uses telegramTrigger, telegram, snowflake, httpRequest. Event-driven trigger; 87 nodes.
my-secretary. Uses postgres, mcpClientTool, googleDriveTool, toolWorkflow. Webhook trigger; 86 nodes.
secretaria. Uses postgres, n8n-nodes-evolution-api, openAi, httpRequest. Webhook trigger; 71 nodes.