This workflow follows the Execute Workflow Trigger → Postgres 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 →
{
"updatedAt": "2025-12-24T09:23:41.326Z",
"createdAt": "2025-12-23T09:30:31.267Z",
"id": "G0XzfbZiT3P98B4S",
"name": "Route_Message",
"description": null,
"active": false,
"isArchived": false,
"nodes": [
{
"parameters": {
"inputSource": "passthrough"
},
"type": "n8n-nodes-base.executeWorkflowTrigger",
"typeVersion": 1.1,
"position": [
-12848,
8080
],
"id": "91f732dd-8250-4342-ae01-365e0b336809",
"name": "ReceiveEvent"
},
{
"parameters": {
"operation": "executeQuery",
"query": "-- Reset next_pulse to NOW so proactive agent can respond after user activity\nUPDATE config \nSET value = NOW()::text, updated_at = NOW()\nWHERE key = 'next_pulse';\n\n-- Insert if not exists\nINSERT INTO config (key, value)\nVALUES ('next_pulse', NOW()::text)\nON CONFLICT (key) DO NOTHING;",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.4,
"position": [
-12624,
8400
],
"id": "reset-next-pulse",
"name": "ResetNextPulse",
"credentials": {
"postgres": {
"name": "<your credential>"
}
},
"onError": "continueRegularOutput"
},
{
"parameters": {
"resource": "message",
"operation": "react",
"guildId": {
"__rl": true,
"value": "={{ $json.ctx.event.guild_id }}",
"mode": "id"
},
"channelId": {
"__rl": true,
"value": "={{ $json.ctx.event.channel_id }}",
"mode": "id"
},
"messageId": "={{ $json.ctx.event.message_id }}",
"emoji": "=\ud83d\udd35"
},
"type": "n8n-nodes-base.discord",
"typeVersion": 2,
"position": [
-12624,
7984
],
"id": "476cc1ef-8e72-4df6-ab57-42bda8f06403",
"name": "ReactWith\ud83d\udd35",
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1000,
"credentials": {
"discordBotApi": {
"name": "<your credential>"
}
},
"onError": "continueRegularOutput"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "has-tag",
"leftValue": "={{ $json.ctx.event.tag }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
-12400,
8400
],
"id": "c3c18343-a082-4961-8b41-20c2af7240dc",
"name": "HasTag?"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "in-thread",
"leftValue": "={{ $json.ctx.event.thread_id }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
-12624,
8176
],
"id": "6f431c36-8c0b-4d84-9d44-a78ab41eadd1",
"name": "InThread?"
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "// Add projection type to ctx for Capture_Projection workflow\n// Derive type from tag (!! = activity, .. = note, $$ = todo)\nconst tag = $json.ctx.event.tag;\nconst tagToType = { '!!': 'activity', '..': 'note', '$$': 'todo' };\nconst projectionType = tagToType[tag] || 'activity';\n\nreturn {\n ctx: {\n ...$json.ctx,\n projection: {\n type: projectionType\n }\n }\n }\n \n;"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-11952,
8080
],
"id": "a1b2c3d4-prep-proj-type-node",
"name": "PrepareProjection"
},
{
"parameters": {
"workflowId": {
"__rl": true,
"value": "Gu9mVRTwvJCq0Fpf",
"mode": "list",
"cachedResultUrl": "/workflow/Gu9mVRTwvJCq0Fpf",
"cachedResultName": "Capture_Projection"
},
"workflowInputs": {
"mappingMode": "defineBelow",
"value": {},
"matchingColumns": [],
"schema": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"options": {}
},
"type": "n8n-nodes-base.executeWorkflow",
"typeVersion": 1.3,
"position": [
-11728,
8080
],
"id": "e5f6g7h8-capture-projection-node",
"name": "CaptureProjection"
},
{
"parameters": {
"workflowId": {
"__rl": true,
"value": "9z0gv8DzdPC76trq",
"mode": "list",
"cachedResultUrl": "/workflow/9z0gv8DzdPC76trq",
"cachedResultName": "Start_Thread"
},
"workflowInputs": {
"mappingMode": "defineBelow",
"value": {},
"matchingColumns": [],
"schema": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"options": {}
},
"type": "n8n-nodes-base.executeWorkflow",
"typeVersion": 1.3,
"position": [
-11952,
8272
],
"id": "4f5dbc85-1925-42ca-9d48-7cfdb8bc862f",
"name": "StartThread"
},
{
"parameters": {
"workflowId": {
"__rl": true,
"value": "ZwuxCuNFykFxgD3e",
"mode": "list",
"cachedResultUrl": "/workflow/ZwuxCuNFykFxgD3e",
"cachedResultName": "Execute_Command"
},
"workflowInputs": {
"mappingMode": "defineBelow",
"value": {},
"matchingColumns": [],
"schema": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"options": {}
},
"type": "n8n-nodes-base.executeWorkflow",
"typeVersion": 1.3,
"position": [
-11952,
8464
],
"id": "be0f00ad-4e2f-4338-bfef-8816cee4777f",
"name": "ExecuteCommand"
},
{
"parameters": {
"workflowId": {
"__rl": true,
"value": "yj2EUpsI7s3mLlRH",
"mode": "list",
"cachedResultUrl": "/workflow/yj2EUpsI7s3mLlRH",
"cachedResultName": "Capture_Thread"
},
"workflowInputs": {
"mappingMode": "defineBelow",
"value": {},
"matchingColumns": [],
"schema": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"options": {}
},
"type": "n8n-nodes-base.executeWorkflow",
"typeVersion": 1.3,
"position": [
-12176,
7840
],
"id": "15a4061b-cde3-4fce-89b9-8d2864c1ad53",
"name": "CaptureThread"
},
{
"parameters": {
"workflowId": {
"__rl": true,
"value": "mbX1lCt14Yi75gTE",
"mode": "list",
"cachedResultUrl": "/workflow/mbX1lCt14Yi75gTE",
"cachedResultName": "Continue_Thread"
},
"workflowInputs": {
"mappingMode": "defineBelow",
"value": {},
"matchingColumns": [],
"schema": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"options": {}
},
"type": "n8n-nodes-base.executeWorkflow",
"typeVersion": 1.3,
"position": [
-12176,
8032
],
"id": "c2a931b5-275e-4fbc-bd3c-4ad40bfcca18",
"name": "ContinueThread"
},
{
"parameters": {
"workflowId": {
"__rl": true,
"value": "DX0m48INGS7vEwbu",
"mode": "list",
"cachedResultUrl": "/workflow/DX0m48INGS7vEwbu",
"cachedResultName": "Multi_Capture"
},
"workflowInputs": {
"mappingMode": "defineBelow",
"value": {},
"matchingColumns": [],
"schema": [],
"attemptToConvertTypes": false,
"convertFieldsToString": true
},
"options": {}
},
"type": "n8n-nodes-base.executeWorkflow",
"typeVersion": 1.3,
"position": [
-12176,
8512
],
"id": "multi-extract-node",
"name": "MultiCapture"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "0ceb9e91-e374-4346-8706-97df7d95cfe6",
"leftValue": "={{ $json.ctx.event.tag }}",
"rightValue": "--",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
-12400,
7936
],
"id": "aebd154b-14e4-4927-b668-9adf8d7107f4",
"name": "TagIs"
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "intent-activity",
"leftValue": "={{ $json.ctx.event.tag }}",
"rightValue": "!!",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "!!"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "intent-note",
"leftValue": "={{ $json.ctx.event.tag }}",
"rightValue": "..",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": ".."
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "intent-todo",
"leftValue": "={{ $json.ctx.event.tag }}",
"rightValue": "$$",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "$$"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "intent-chat",
"leftValue": "={{ $json.ctx.event.tag }}",
"rightValue": "++",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "++"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"id": "intent-command",
"leftValue": "={{ $json.ctx.event.tag }}",
"rightValue": "::",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "::"
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"id": "52b76dff-86bf-4376-896a-ffd61ade887b",
"name": "RouteByTag",
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"position": [
-12176,
8224
]
}
],
"connections": {
"ReceiveEvent": {
"main": [
[
{
"node": "ReactWith\ud83d\udd35",
"type": "main",
"index": 0
},
{
"node": "InThread?",
"type": "main",
"index": 0
},
{
"node": "ResetNextPulse",
"type": "main",
"index": 0
}
]
]
},
"HasTag?": {
"main": [
[
{
"node": "RouteByTag",
"type": "main",
"index": 0
}
],
[
{
"node": "MultiCapture",
"type": "main",
"index": 0
}
]
]
},
"InThread?": {
"main": [
[
{
"node": "TagIs",
"type": "main",
"index": 0
}
],
[
{
"node": "HasTag?",
"type": "main",
"index": 0
}
]
]
},
"PrepareProjection": {
"main": [
[
{
"node": "CaptureProjection",
"type": "main",
"index": 0
}
]
]
},
"TagIs": {
"main": [
[
{
"node": "CaptureThread",
"type": "main",
"index": 0
}
],
[
{
"node": "ContinueThread",
"type": "main",
"index": 0
}
]
]
},
"RouteByTag": {
"main": [
[
{
"node": "PrepareProjection",
"type": "main",
"index": 0
}
],
[
{
"node": "PrepareProjection",
"type": "main",
"index": 0
}
],
[
{
"node": "PrepareProjection",
"type": "main",
"index": 0
}
],
[
{
"node": "StartThread",
"type": "main",
"index": 0
}
],
[
{
"node": "ExecuteCommand",
"type": "main",
"index": 0
}
],
[
{
"node": "MultiCapture",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"errorWorkflow": "NOJ7FqVhVLqw0n8D",
"availableInMCP": false,
"executionOrder": "v1"
},
"staticData": null,
"meta": null,
"versionId": "5a853904-4ddf-43f2-b4c9-e4e0ebfe9f5a",
"activeVersionId": null,
"versionCounter": 217,
"triggerCount": 0,
"shared": [
{
"updatedAt": "2025-12-23T09:30:31.267Z",
"createdAt": "2025-12-23T09:30:31.267Z",
"role": "workflow:owner",
"workflowId": "G0XzfbZiT3P98B4S",
"projectId": "erM3nntdLL53noWi",
"project": {
"updatedAt": "2025-12-23T09:23:39.658Z",
"createdAt": "2025-12-23T09:16:56.460Z",
"id": "erM3nntdLL53noWi",
"name": "Chris Irineo <chriskevini@gmail.com>",
"type": "personal",
"icon": null,
"description": null,
"projectRelations": [
{
"updatedAt": "2025-12-23T09:16:56.460Z",
"createdAt": "2025-12-23T09:16:56.460Z",
"userId": "2a851a2d-b7e5-4b3c-aefb-6eaaa79e0659",
"projectId": "erM3nntdLL53noWi",
"user": {
"updatedAt": "2025-12-24T08:40:46.063Z",
"createdAt": "2025-12-23T09:16:54.881Z",
"id": "2a851a2d-b7e5-4b3c-aefb-6eaaa79e0659",
"email": "chriskevini@gmail.com",
"firstName": "Chris",
"lastName": "Irineo",
"personalizationAnswers": {
"version": "v4",
"personalization_survey_submitted_at": "2025-12-23T09:23:43.723Z",
"personalization_survey_n8n_version": "1.123.5"
},
"settings": {
"userActivated": true,
"firstSuccessfulWorkflowId": "CgUAxK0i4YhrZ2Wp",
"userActivatedAt": 1766487000077,
"easyAIWorkflowOnboarded": true
},
"disabled": false,
"mfaEnabled": false,
"lastActiveAt": "2025-12-24",
"isPending": false
}
}
]
}
}
],
"tags": [],
"activeVersion": null
}
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.
discordBotApipostgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Route_Message. Uses executeWorkflowTrigger, postgres, discord. Event-driven trigger; 14 nodes.
Source: https://github.com/chriskevini/kairon/blob/ab924f228ceb22522b9a4dfa1ab4589eb86273ad/n8n-workflows/Route_Message.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.
Execute_Command. Uses executeWorkflowTrigger, postgres, discord, httpRequest. Event-driven trigger; 47 nodes.
Handle_Quality_Rating. Uses executeWorkflowTrigger, postgres, discord. Event-driven trigger; 5 nodes.
03 - Command Handler. Uses executeWorkflowTrigger, telegram, executeCommand, postgres. Event-driven trigger; 53 nodes.
Unlock low-cost, high-control generative media workflows directly from n8n by integrating with ComfyUI. Ideal for indie creators, AI developers, or small teams seeking scalable media automation—from i
This workflow will backup all of your existed workflows to a single Github repository.