Automation library · Chat assistants

AI Email Agent with Gmail and Telegram Approval

Started by an incoming Telegram message, and works across Gmail, Redis and Telegram. It hands the judgement calls to Gemini and OpenAI. 38 steps, 8 branches: large, and worth reading before you trust it with anything live.

LargeCalls a model: Gemini, OpenAI

38 stepsLarge: read it before trusting it with anything live
8Branches: places the flow splits
0Loops or waits
3Services it connects to

The flow

Starts it 3Model 5Logic 13Service 17

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

  1. 1Gmail TriggerGmail triggerStarts it
  2. 2Chat with GeminiChat triggerStarts it
  3. 3Gmail Label toolGmail ToolService
  4. 4Gmail Draft ToolGmail ToolService
  5. 5Google Gemini Chat ModelLm Chat Google GeminiModel
  6. 6Telegram Trigger get selected tl buttonTelegram triggerStarts it
  7. 7OpenAI Chat ModelLm Chat Open AiModel
  8. 8Code in JavaScriptCodeLogic
  9. 9Gemini Chat AgentAgentModel
  10. 10AI AgentAgentModel
  11. 11verify btn clk frm our mailbotIfLogic
  12. 12AI Agent1AgentModel
  13. 13output cleaner javascriptCodeLogic
  14. 14Switch cb query or msgSwitchLogic
  15. 15Draft modify AI agent output cleaningCodeLogic
  16. 16IfIfLogic
  17. 17Switch cb containsSwitchLogic
  18. 18Extracting Message ID from Tweak messageRedisService
  19. 19send reply draft to reciever2TelegramService
  20. 20save updated draft on redisRedisService
  21. 21draftId isExist in redis for deleteIfLogic
  22. 22send reply draft to recieverTelegramService
  23. 23RedisRedisService
  24. 24Redis get contains idRedisService
  25. 25Redis get contains id1RedisService
  26. 26Redis get contains id2RedisService
  27. 27Delete a draftGmailService
  28. 28SwitchSwitchLogic
  29. 29Id found but cancle frm TLSwitchLogic
  30. 30Id found Edit(Tweak) frm TLSwitchLogic
  31. 31cln out frm redis & convert draft into htmlCodeLogic
  32. 32msgId not found in redis Already took actionTelegramService
  33. 33get draft id to dltCodeLogic
  34. 34msgId found in redis tweak click msgTelegramService
  35. 35Reply to a messageGmailService
  36. 36msgId not found in redis Cancle click msgTelegramService
  37. 37Reply sentTelegramService
  38. 38Delete msgId frm RedisRedisService

How it's built

Starts on
An incoming Telegram message
Steps
38, with 8 branches
Size
Large: read it before trusting it with anything live
Connects to
Gmail, Redis, Telegram
Model
Gemini, OpenAI

Questions

What does it need to run?

An n8n account, plus your own Gmail, Redis and Telegram accounts, and a key for Gemini and OpenAI. 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 and OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

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