Skip to main content

Create secure human-in-the-loop approval flows with Postgres and Telegram

Workflow preview

Workflow preview
100%
Create secure human-in-the-loop approval flows with Postgres and Telegram preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Human in the Loop Approval Flow (n8n + Postgres + Telegram) Who’s it for Teams that need a manager approval step before a ticket or request can change status. Great for internal ops, IT reque...

Best for

  • Ticket Management automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.code, n8n-nodes-base.postgres, n8n-nodes-base.if, n8n-nodes-base.telegram, n8n-nodes-base.switch, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Mohammad.

Original n8n.io source

1.1 Workflow description

Title
Create secure human-in-the-loop approval flows with Postgres and Telegram
Workflow name
Create secure human-in-the-loop approval flows with Postgres and Telegram

🔐 Human-in-the-Loop Approval Flow (n8n + Postgres + Telegram)

👥 Who’s it for

Teams that need a manager approval step before a ticket or request can change status. Great for internal ops, IT requests, or any workflow where “a human must sign off.”

⚡ What it does

  • 📨 Manager receives approval/reject link
  • 🔑 Link is signed with HMAC + expiry (secure & tamper-proof)
  • 🗄️ Postgres updates the ticket status
  • 📝 Audit trail records every decision
  • 📲 Telegram notifies both manager and requester
  • ⏰ Expired or invalid links trigger alerts and logs

🛠 Requirements

  • n8n instance (self-hosted)
  • Postgres database (with tickets, ticket_audit, workflow_errors)
  • Telegram bot token
  • One environment variable set: SECRET_KEY

⚙️ How to set up

  1. Set SECRET_KEY in .env
  2. Create Postgres tables (SQL provided)
  3. Add Telegram + Postgres credentials in n8n
  4. Import the workflow JSON
  5. Test by opening an approval/reject link in your browser

🎨 How to customize

  • Change who the “manager” is (currently hardcoded in the Code node).
  • Swap Telegram for Slack or email notifications.
  • Extend the audit schema to include more metadata (IP, username).

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - 01 Webhook Trigger: Approval Decision

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 2 - 02 FN: Verify Signature + TTL

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - 04c DB: Update Ticket Status

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 4 - 04c1 DB: Get Ticket Owner

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 5 - 04c1a IF: Resolved or In Progress

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 6 - 05c1a Telegram: Notify Resolved

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 7 - 05c1b Telegram: Notify In Progress

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 8 - 05c Telegram: Update Confirmation

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 9 - Notify Failed?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 10 - Execute a SQL query

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 11 - 04c2 DB: Insert Audit Row

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 12 - Text (reject)

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 13 - 04r0 DB: Get Ticket ID

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 14 - Execute a SQL query1

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 15 - If Resolved

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 16 - If in_progress

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 17 - Actions

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 18 - 04e DB: Insert Audit Expired

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 19 - 04i DB: Insert Audit Invalid

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 20 - 05e Telegram: Notify Expired

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 21 - 05i Telegram: Alert Invalid

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 22 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 26 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Create secure human-in-the-loop approval flows with Postgres and Telegram
Complexity advanced
Nodes 26
Categories Ticket Management
Author Mohammad
Published 28 Sept 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9039/9039.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Create secure human-in-the-loop approval flows with Postgres and Telegram do?

Human in the Loop Approval Flow (n8n + Postgres + Telegram) Who’s it for Teams that need a manager approval step before a ticket or request can change status. Great for internal ops, IT reque...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Ticket Management use case.