# Telegram bot for item multi select and saving to Postgres: n8n workflow

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

Source: https://millionrounds.com/workflow/telegram-bot-for-item-multi-select-and-saving-to-postgres (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Content](https://millionrounds.com/workflows?category=Content#library)

# Telegram bot for item multi select and saving to Postgres

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

Large

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Ftelegram-bot-for-item-multi-select-and-saving-to-postgres)

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

**6** Branches: places the flow splits

**0** Loops or waits

**2** Services it connects to

## The flow

Starts it 1 Logic 12 Service 29

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 **Welcome Message** Telegram *Service*
- 6 **Define Type** Switch *Logic*
- 7 **Upsert bot status on START** Postgres *Service*
- 8 **Switch** Switch *Logic*
- 9 **New?** If *Logic*
- 10 **Answers** Switch *Logic*
- 11 **Get Order** Postgres *Service*
- 12 **Get Order** Postgres *Service*
- 13 **Add Order** Postgres *Service*
- 14 **Success** Telegram *Service*
- 15 **Get Order** Postgres *Service*
- 16 **Get Shop List Choices** Postgres *Service*
- 17 **Get message_id** Postgres *Service*
- 18 **Get Shop List** Postgres *Service*
- 19 **Get message_id** Postgres *Service*
- 20 **Get Shop List Choices** Postgres *Service*
- 21 **Get message_id** Postgres *Service*
- 22 **Active?** If *Logic*
- 23 **Update Shop List Choice** Postgres *Service*
- 24 **Add Shop List Choice** Postgres *Service*
- 25 **Delete Prev SMS** Telegram *Service*
- 26 **Convert statuses** Code *Logic*
- 27 **Delete Prev SMS** Telegram *Service*
- 28 **Union Number with Text** Set *Logic*
- 29 **Get Shop List Choice** Postgres *Service*
- 30 **Convert statuses** Code *Logic*
- 31 **Send** Telegram *Service*
- 32 **Union List** Summarize *Service*
- 33 **Convert statuses and antistatuses** Code *Logic*
- 34 **Send** Telegram *Service*
- 35 **Update message_id** Postgres *Service*
- 36 **Get message_id** Postgres *Service*
- 37 **Edit** Telegram *Service*
- 38 **Update message_id** Postgres *Service*
- 39 **Delete Prev SMS** Telegram *Service*
- 40 **Update message_id** Postgres *Service*
- 41 **Results** Telegram *Service*
- 42 **Update message_id** Postgres *Service*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 42, with 6 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 42 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 42 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-bot-for-item-multi-select-and-saving-to-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 content, with the same services where possible, closest in size first.

- [**Telegram video merger bot with FTP and Postgres** 42 steps · FTP, Postgres](https://millionrounds.com/workflow/telegram-video-merger-bot-with-ftp-and-postgres)
- [**Automatic Instagram content creation with OpenAI and Telegram** 42 steps · calls a model · Airtable, Telegram](https://millionrounds.com/workflow/automatic-instagram-content-creation-with-openai-and-telegra)
- [**Generate Blog Posts on Autopilot with Tavily and WordPress** 42 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/generate-blog-posts-on-autopilot-with-tavily-and-wordpress)
- [**Automate Telegram channel posts with Postgres** 43 steps · Postgres, Telegram](https://millionrounds.com/workflow/automate-telegram-channel-posts-with-postgres)
- [**Generate a full startup plan from one sentence with Postgres** 43 steps · Gmail, Google Drive](https://millionrounds.com/workflow/generate-a-full-startup-plan-from-one-sentence-with-postgres)
- [**Verify Telegram channel subscriptions with Postgres** 41 steps · Google Drive, Postgres](https://millionrounds.com/workflow/verify-telegram-channel-subscriptions-with-postgres)
