Automation library · Content

Host a Telegram AI bot with a local model and Redis

Started by an incoming Telegram message, and works across Redis and Telegram. It puts a local model behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 41 steps, 4 branches, 2 loops or waits: large, and worth reading before you trust it with anything live.

LargeCalls a model: a local modelRetrieval

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

The flow

Starts it 1Model 5Logic 11Service 24

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

  1. 1Redis Chat MemoryMemory Redis ChatModel
  2. 2Redis Chat Memory1Memory Redis ChatModel
  3. 3Ollama Chat ModelLm Chat OllamaModel
  4. 4Telegram TriggerTelegram triggerStarts it
  5. 5AI Agent - chatAgentModel
  6. 6AI Agent - picAgentModel
  7. 7Set user telegram IDSetLogic
  8. 8Hold on a moment to allow redis propagationWaitLogic
  9. 9Send chat answerTelegramService
  10. 10Retrieve current contextRedisService
  11. 11Set-up the ComfyUI workflowCodeLogic
  12. 12Check user idIfLogic
  13. 13Reset context clone 2RedisService
  14. 14ComfyUI HTTP Request - startHttp RequestService
  15. 15Create base message formatSetLogic
  16. 16clone contextRedisService
  17. 17ComfyUI HTTP Request - checkHttp RequestService
  18. 18Get body definitionRedisService
  19. 19Check if image has been generatedIfLogic
  20. 20Get scene definitionRedisService
  21. 21ComfyUI HTTP Request - fetchHttp RequestService
  22. 22Check if ComfyUI erroredIfLogic
  23. 23Send initial typingTelegramService
  24. 24Send comfy picTelegramService
  25. 25Send pic errorTelegramService
  26. 26Send pic typingTelegramService
  27. 27Switch on command typeSwitchLogic
  28. 286. WaitWaitLogic
  29. 29reset existing contextRedisService
  30. 30pop messageRedisService
  31. 31Set body messageTelegramService
  32. 32Set body definitionRedisService
  33. 33Set scene messageTelegramService
  34. 34Set scene definitionRedisService
  35. 35Set base comfy entrySetLogic
  36. 36Set base ollama contextSetLogic
  37. 37Reset context cloneRedisService
  38. 38Send pop confirmationTelegramService
  39. 39Send body confirmationTelegramService
  40. 40Send scene confirmationTelegramService
  41. 41Send reset confirmationTelegramService

How it's built

Starts on
An incoming Telegram message
Steps
41, with 4 branches, 2 loops or waits
Size
Large: read it before trusting it with anything live
Connects to
Redis, Telegram
Model
a local model
Retrieval
Answers are drawn from documents you supply, not from the model alone

Questions

What does it need to run?

An n8n account, plus your own Redis and Telegram accounts, and a key for a local model. 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?

Yes. It calls a local model. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 41 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 41 steps before you point it at anything that matters.