Lightweight Telegram Support Desk with Postgres Backend - n8n Workflow

Use this powerful n8n workflow to build a complete support ticket system managed entirely through Telegram, backed by a PostgreSQL database. Perfect n8n templates for custom CRM and operations.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Markdown-formatted text:

Small business owners needing a simple, consolidated support intake system.
Developers looking for advanced n8n templates utilizing Telegram and database integration.
Teams seeking to automate initial customer service interaction and ticket routing.
Users who want to leverage the core logic of an n8n workflow for custom CRM solutions.

Overview

This sophisticated n8n workflow transforms a Telegram bot and a PostgreSQL database into a fully functional, lightweight help desk solution. This complete n8n workflow allows external users to create new support tickets, check the status of existing tickets, and receive automatic notifications upon updates, all via simple Telegram commands.

The system handles four primary commands: /start, /new, /status, and operator-only commands like /update and /list. This n8n automation provides robust data handling, including parsing free-form text, generating unique correlation IDs, and implementing strict security checks to protect update and list functions. It’s an excellent example of leveraging complex n8n node logic and database integration to create reliable n8n templates for operational needs.

How it Works

The process begins with the 01 Telegram Trigger: Intake + Status n8n trigger, which listens for any message directed to the connected bot. This n8n node immediately passes the incoming command to the 02 Switch: Route by Command node, which acts as the core flow control, splitting the n8n workflow based on the command.


  1. Ticket Creation (/new): The data flows to the 03a FN: Normalize + Hash Code n8n node, which uses Python to parse the requester's details (Name, Email, Subject) from the message text, generates a UUID correlation ID, and calculates a deduplication key. This standardized data is then sent to the 04a DB: Upsert Ticket Postgres n8n node, which inserts the new record. An acknowledgment is returned via Telegram.

  2. Status Check (/status): The workflow parses the correlation ID. IF n8n nodes validate the ID format and presence. The 04b DB: Get Ticket Status Postgres n8n node retrieves the ticket details. Subsequent IF nodes ensure that only the original requester (based on Telegram Chat ID) can view the status before the 05b Telegram: Status Reply node sends the result.

  3. Ticket Update (/update): This critical path is secured by an IF n8n node (03c0 IF: Is Operator) checking if the user is an authorized operator. If authorized and the status is valid, the 04c DB: Update Ticket Status Postgres n8n node updates the record. The workflow then uses multiple Telegram n8n nodes to notify both the operator and the original customer of the change (e.g., Ticket Resolved notification).

  4. Admin List (/list): Secured by the Check Admin IF n8n node, this command triggers the DB: List Tickets Postgres n8n node to fetch recent records, which are then formatted by a JavaScript Code n8n node and sent back to the admin via Telegram.

Installation Guide

Markdown-formatted text:


  1. Import the n8n workflow: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Set up Credentials: This n8n workflow requires two credentials:

Telegram Bot: Configure your Telegram API key credentials, ensuring the bot is linked and can receive messages.
PostgreSQL: Configure your database credentials. Ensure the PostgreSQL database is accessible and contains the required tickets, ticketaudit, and workflowerrors tables, along with the custom upsertticket stored function (details are in the Sticky Notes within the n8n template).

  1. Replace Placeholders: Locate the following IF n8n nodes and Code n8n nodes and replace the dummy values:

YOURADMINID (in Check Admin node for /list access).
YOUR
OPERATOR_ID (in 03c0 IF: Is Operator node for /update access).

  1. Activate the n8n trigger: Activate the workflow. The 01 Telegram Trigger: Intake + Status n8n trigger is now live, waiting for incoming commands.

Node Details

Markdown-formatted text:

01 Telegram Trigger: Intake + Status (Telegram Trigger n8n node):
Function: Serves as the primary entry point and n8n trigger for the entire system, initiating the flow upon receiving any Telegram message.
Key Configuration: Configured to listen for message updates.
02 Switch: Route by Command (Switch n8n node):
Function: Routes the n8n workflow execution to distinct branches based on the first word of the message text (e.g., /new, /status).
03a FN: Normalize + Hash (Code n8n node - Python):
Function: Parses multi-line input text to extract structured data (Name, Email, Subject), generates a unique UUID correlationid, and computes a SHA-256 dedupekey for data integrity.
04a DB: Upsert Ticket (Postgres n8n node):
Function: Executes a complex SQL query utilizing a custom upsertticket function to atomically insert a new ticket or update an existing one based on the correlation ID.
04b DB: Get Ticket Status (Postgres n8n node):
Function: Retrieves the current status, subject, and timestamps for a specific ticket using its correlation ID, necessary for the /status check functionality.
03c0 IF: Is Operator (IF n8n node):
Function: Acts as a security gate, ensuring that only messages originating from the hardcoded YOUROPERATOR_ID are allowed to proceed to the update logic, restricting the /update command.
04c DB: Update Ticket Status (Postgres n8n node):
Function: Modifies the status column for a given ticket ID, serving as the central action for the operator update flow.
05a Telegram Ack (Telegram n8n node):
* Function: Sends formatted acknowledgment messages back to the user, including the crucial new correlation ID.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Automation consultant specializing in n8n workflows that save businesses time and reduce costs. Experienced in designing ticketing systems, email parsers, and integrations with Postgres, Telegram, and APIs. I publish workflows to help teams streamline operations and build internal efficiency.

Featured*