Automation library · Chat assistants

End of turn detection for smoother AI agent chats

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

LargeCalls a model: GeminiRetrieval

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

The flow

Starts it 2Model 5Logic 9Service 7

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

  1. 1Telegram TriggerTelegram triggerStarts it
  2. 2Google Gemini Chat ModelLm Chat Google GeminiModel
  3. 3Redis Chat MemoryMemory Redis ChatModel
  4. 4Google Gemini Chat Model1Lm Chat Google GeminiModel
  5. 5Prediction SubworkflowExecute Workflow triggerStarts it
  6. 6Is Bot command?IfLogic
  7. 7AI AgentAgentModel
  8. 8Predict End of UtteranceText ClassifierModel
  9. 9Get SessionRedisService
  10. 10Get ValuesSetLogic
  11. 11Update Session2RedisService
  12. 12Wait For WebhookWaitLogic
  13. 13Update SessionRedisService
  14. 14Call Prediction SubworkflowExecute WorkflowLogic
  15. 15Respond to UserTelegramService
  16. 16Get Session2RedisService
  17. 17Get Updated Session ValuesSetLogic
  18. 18Session Ended?IfLogic
  19. 19is New Session?IfLogic
  20. 20Session RefNo OpLogic
  21. 21Is Waiting?IfLogic
  22. 22Update Session1RedisService
  23. 23Resume Wait NodeHttp RequestService

How it's built

Starts on
An incoming Telegram message
Steps
23, with 4 branches, 1 loop or waits
Size
Large: read it before trusting it with anything live
Connects to
Redis, Telegram
Model
Gemini
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 Gemini. 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 Gemini. 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 23 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 23 steps before you point it at anything that matters.