# Telegram giveaways among channel subscribers with Postgres: n8n workflow

> Started by an incoming Telegram message, and works across Postgres and Telegram. 37 steps, 8 branches: large, and worth reading before you trust it with...

Source: https://millionrounds.com/workflow/telegram-giveaways-among-channel-subscribers-with-postgres (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Alerts and monitoring](https://millionrounds.com/workflows?category=Alerts+and+monitoring#library)

# Telegram giveaways among channel subscribers with Postgres

Started by an incoming Telegram message, and works across Postgres and Telegram. 37 steps, 8 branches: large, and worth reading before you trust it with anything live.

Large

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Ftelegram-giveaways-among-channel-subscribers-with-postgres)

**37 steps** Large: read it before trusting it with anything live

**8** Branches: places the flow splits

**0** Loops or waits

**2** Services it connects to

## The flow

Starts it 1 Logic 12 Service 24

The steps in the order they run, from what starts it.

- 1 **Telegram Trigger** Telegram trigger *Starts it*
- 2 **Variables TG** Set *Logic*
- 3 **Initialization** Set *Logic*
- 4 **Start?** If *Logic*
- 5 **Referal?** If *Logic*
- 6 **Button?** If *Logic*
- 7 **Welcome message Referal** Telegram *Service*
- 8 **Welcome message Manager** Telegram *Service*
- 9 **Buttons** Switch *Logic*
- 10 **Get Bot Status** Postgres *Service*
- 11 **Update bot status and referal** Postgres *Service*
- 12 **Upsert bot status on START** Postgres *Service*
- 13 **Update bot status on GIVEAWAY RUN** Postgres *Service*
- 14 **Define flow** Switch *Logic*
- 15 **Add participant in Giveaway** Postgres *Service*
- 16 **Create Giveaway** Telegram *Service*
- 17 **Commands** Switch *Logic*
- 18 **Add channel** Postgres *Service*
- 19 **Define Step Giveaway** Switch *Logic*
- 20 **List Channels** Telegram *Service*
- 21 **Request New Channel** Telegram *Service*
- 22 **Channel Exists** Telegram *Service*
- 23 **Get Participants** Postgres *Service*
- 24 **Update bot status on GIVEAWAY REQUEST CHANNEL** Postgres *Service*
- 25 **Random Participants** Sort *Logic*
- 26 **Get Channels** Postgres *Service*
- 27 **Telegram** Telegram *Service*
- 28 **Union Statuses** Aggregate *Logic*
- 29 **Check Success?** If *Logic*
- 30 **Check Success** Telegram *Service*
- 31 **SMS for Winner** Telegram *Service*
- 32 **Check Failed** Telegram *Service*
- 33 **SMS for Manager** Telegram *Service*
- 34 **Delete Channels** Postgres *Service*
- 35 **Delete Participants** Postgres *Service*
- 36 **Update bot status on START** Postgres *Service*
- 37 **End Message** Telegram *Service*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 37, with 8 branches
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Postgres, Telegram
- **Model:** None. This is plumbing, not judgement

## Questions

What does it need to run?

An n8n account, plus your own Postgres and Telegram accounts. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an incoming Telegram message.

Does it use AI?

No. Every step is fixed logic or a call to a service, so it does the same thing every time.

How long does it take to set up?

Take your time. At 37 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 37 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Ftelegram-giveaways-among-channel-subscribers-with-postgres)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Postgres](https://millionrounds.com/workflows?service=Postgres#library)[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

Also alerts and monitoring, with the same services where possible, closest in size first.

- [**Automated range trading with Uniswap V3 and Telegram** 37 steps · Telegram](https://millionrounds.com/workflow/automated-range-trading-with-uniswap-v3-and-telegram)
- [**Automated BTC & ETH market analysis alerts for Discord & Telegram** 37 steps · calls a model · Discord, RSS](https://millionrounds.com/workflow/automated-btc-and-eth-market-analysis-alerts-for-discord-and)
- [**Manage on-campus event attendance with Google Sheets** 35 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/manage-on-campus-event-attendance-with-google-sheets)
- [**Onboard frontline workers with Telegram and DeepSeek** 35 steps · Notion, Telegram](https://millionrounds.com/workflow/onboard-frontline-workers-with-telegram-and-deepseek)
- [**Manage Supabase database records with Telegram** 34 steps · Supabase, Telegram](https://millionrounds.com/workflow/manage-supabase-database-records-with-telegram)
- [**Create and optimize B2B LinkedIn AI posts with Groq** 34 steps · calls a model · LinkedIn, Telegram](https://millionrounds.com/workflow/create-and-optimize-b2b-linkedin-ai-posts-with-groq)
