Automation library · Content

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

42 stepsLarge: read it before trusting it with anything live
6Branches: places the flow splits
0Loops or waits
2Services it connects to

The flow

Starts it 1Logic 12Service 29

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

  1. 1Telegram TriggerTelegram triggerStarts it
  2. 2Variables TGSetLogic
  3. 3InitializationSetLogic
  4. 4Start?IfLogic
  5. 5Welcome MessageTelegramService
  6. 6Define TypeSwitchLogic
  7. 7Upsert bot status on STARTPostgresService
  8. 8SwitchSwitchLogic
  9. 9New?IfLogic
  10. 10AnswersSwitchLogic
  11. 11Get Order PostgresService
  12. 12Get OrderPostgresService
  13. 13Add OrderPostgresService
  14. 14SuccessTelegramService
  15. 15Get Order PostgresService
  16. 16Get Shop List ChoicesPostgresService
  17. 17Get message_idPostgresService
  18. 18Get Shop ListPostgresService
  19. 19Get message_id PostgresService
  20. 20Get Shop List Choices PostgresService
  21. 21Get message_id PostgresService
  22. 22Active?IfLogic
  23. 23Update Shop List ChoicePostgresService
  24. 24Add Shop List ChoicePostgresService
  25. 25Delete Prev SMS TelegramService
  26. 26Convert statuses CodeLogic
  27. 27Delete Prev SMS TelegramService
  28. 28Union Number with TextSetLogic
  29. 29Get Shop List ChoicePostgresService
  30. 30Convert statusesCodeLogic
  31. 31Send TelegramService
  32. 32Union ListSummarizeService
  33. 33Convert statuses and antistatusesCodeLogic
  34. 34SendTelegramService
  35. 35Update message_id PostgresService
  36. 36Get message_id PostgresService
  37. 37EditTelegramService
  38. 38Update message_idPostgresService
  39. 39Delete Prev SMSTelegramService
  40. 40Update message_id PostgresService
  41. 41ResultsTelegramService
  42. 42Update message_id PostgresService

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.