1. Opening Problem Statement
Meet Alice, a freelance graphic designer who often finds her day slipping away with distractions and lack of proper breaks. She tried using various Pomodoro timer apps but struggled to keep track of her sessions and breaks efficiently, especially across multiple devices. Alice wastes roughly 2 hours daily restarting timers, forgetting breaks, and manually logging her progress. The scattered logs make it hard for her to analyze productivity trends and plan better workdays.
Imagine you want a solution where your Pomodoro sessions can be triggered and controlled directly via Telegram chat, with automatic notifications and session logs stored neatly in Google Sheets for review. Alice’s problem is precisely the kind that this n8n automation workflow solves uniquely.
2. What This Automation Does
This n8n workflow automates a Pomodoro timer cycle managed entirely via Telegram messages, with session data recorded on Google Sheets. Here’s what happens every time you interact with it:
- Start a Pomodoro session: Send
/startin Telegram to begin a 25-minute deep work block. - Receive real-time session updates: After each 25-minute focus period, you get notified to take a short break (default 5 minutes).
- Track completed cycles: The workflow tracks completed Pomodoro counts per user using static data storage in n8n.
- Record detailed session logs: Each work and break session is appended to a Google Sheet with timestamps, session IDs, counts, and durations.
- Automate long breaks after 4 cycles: After four Pomodoro sessions, the user receives a long break notification and relevant log entry.
- Stop sessions anytime: Send
/stopand the workflow gracefully halts the timer, clears user state data, and informs the user.
This setup saves users hours of manual tracking and helps maintain productivity rhythms perfectly synchronized with their messaging habits.
3. Prerequisites ⚙️
- n8n account (cloud or self-hosted) with access to create workflows 🔑
- Telegram bot account with API token and chat access 📧
- Google Sheets API credentials with a spreadsheet ready for logging 📊
- Basic familiarity with n8n interface and Node editing (recommended but not mandatory)
4. Step-by-Step Guide
Step 1: Initialize Static Data for User Session States
Navigate to the Initiate Static Data code node. This runs a small JavaScript snippet that creates a global object in n8n’s static data storage to keep track of each user’s Pomodoro session states across workflow runs.
let workflowStaticData = $getWorkflowStaticData('global');
if (!workflowStaticData.telegramStates) {
workflowStaticData.telegramStates = {};
}
return workflowStaticData;
Run this node once by clicking “Execute Node” before activating the workflow. This sets up the persistent storage needed for multi-user tracking.
Common mistake: Forgetting this step will cause your workflow to fail managing multiple sessions.
Step 2: Configure Telegram Trigger
Set up the Telegram Trigger node to listen to user messages arriving at your bot. Specify to listen for message updates only.
Ensure your bot credentials are correctly added in n8n’s credentials panel. Test your webhook URL from Telegram, and confirm the bot is responding to messages.
This node starts the workflow whenever someone types commands or messages to your bot.
Step 3: Add Conditional Routing Based on Command
The If node checks whether the incoming message from Telegram starts with /, meaning it’s a command.
If true, it routes to the next condition node start or stop?. Otherwise, it triggers the Instructions Message node to send a help message back.
Step 4: Start or Stop Session Decision
The start or stop? node tests if the command is /start. If yes, the flow proceeds to notify the user and start the Pomodoro cycle with Start Cycle Notification.
Otherwise, it triggers End of Session Notification, informing the user that their session was stopped, and clears session data afterwards.
Step 5: Notify User and Begin Deep Work Timer
The Start Cycle Notification Telegram node sends a motivating message like “⏰ Time to focus! 25 minutes of deep work starts now.” to the user’s chat ID.
Immediately afterward, the Deep Work wait node starts a 25-minute timer.
Step 6: Record Deep Work Session and Notify Short Break
Once the deep work wait finishes, the workflow increments the Pomodoro count with the Increment Count code node. This node updates the static data object for the user, creating a session ID if new and increasing the Pomodoro counter.
The user gets notified to take a short break with the Short Break Notification Telegram node.
The Record Deep Work Google Sheets node appends a row logging this deep work block with all relevant details including date, time, session ID, and user ID.
Step 7: Short Break Timer
The Break wait node runs a 5-minute timer (default, can be customized). When it finishes, a Back to Work Notification Telegram node informs the user that the break is over and it’s time to resume focus.
Step 8: Loop Control for 4 Pomodoro Cycles
The < 4 Cycles If node checks whether the user’s Pomodoro count exceeds 4. If the count is less, the workflow loops back to start another focus cycle.
If the user has completed 4 cycles, the Long Break Notification Telegram node reminds the user to take a longer break (typically 15 min).
The Record Long Break Google Sheets node then logs this long break session similarly to the work sessions.
Step 9: Clearing User State on Session End
The Clear Variables1 and Clear Variables2 code nodes delete the user’s session data from the static object in n8n once the session is stopped or long break completes, ensuring a fresh state for future sessions.
Step 10: Instructions for Invalid Commands
If a user sends a message not starting with a command, the Instructions Message Telegram node sends a friendly message explaining available commands: /start and /stop.
5. Customizations ✏️
- Adjust timer lengths: In the Deep Work and Break wait nodes, change the
amountparameter from 25 or 5 minutes to any duration to fit your workflow. - Modify Google Sheets columns: Update the Record Deep Work and Record Long Break nodes’ mapped fields to include new data points like task description or project ID.
- Change notification messages: Edit the text content in Telegram nodes like Start Cycle Notification and Short Break Notification to match your motivational style or branding.
- Add multi-language support: Add an extra If node to detect user language preferences from the Telegram profile and adjust messages accordingly.
- Enable session pause/resume: Introduce additional commands in the workflow to allow pausing and resuming Pomodoro sessions via Telegram commands.
6. Troubleshooting 🔧
Problem: “Workflow doesn’t trigger on Telegram messages.”
Cause: Incorrect bot webhook setup or missing webhook URL in Telegram BotFather.
Solution: Go to Telegram BotFather, ensure your webhook URL matches the one provided by the Telegram Trigger node in n8n, then restart the bot.
Problem: “Pomodoro counts not updating or session ID missing.”
Cause: Static data not initialized or code node not running.
Solution: Run the Initiate Static Data code node once before starting sessions to create the global object.
Problem: “Google Sheets API errors on append.”
Cause: Invalid credentials or sheet not shared properly.
Solution: Verify Google Sheets API credentials, ensure the correct spreadsheet ID and sheet name are used, and the sheet is shared with the service account email.
7. Pre-Production Checklist ✅
- Run and verify Initiate Static Data node executed successfully.
- Test Telegram bot receiving and responding to messages.
- Confirm Google Sheets credentials and sheet access with a test append operation.
- Send
/startcommand and verify notifications and session logging. - Send
/stopcommand and confirm workflow stops and clears user state. - Ensure handlers for invalid commands respond correctly.
- Backup Google Sheets data periodically to prevent data loss.
8. Deployment Guide
Activate the workflow in n8n’s interface by toggling the active status. The bot now listens 24/7 for Telegram messages to start or stop Pomodoro sessions.
Monitor workflow executions via n8n’s execution history tab to catch issues or errors in real time.
Optionally, self-host your n8n instance for full control over data privacy and uptime. For self-hosting, consider reliable providers like Hostinger with tutorials at buldrr.com/hostinger.
9. FAQs
Q: Can I use another messaging platform instead of Telegram?
A: This workflow specifically uses Telegram’s webhook integration. With modifications, you might adapt to other platforms but would need different trigger nodes.
Q: Does logging each session to Google Sheets consume API credits?
A: Yes, but typical personal or small team usage is within free tier limits unless excessively high frequency.
Q: Is my session data safe?
A: All data is stored within your n8n instance and Google Sheets under your account security settings. Using HTTPS for Telegram webhook and Google API ensures encryption in transit.
Q: Can this handle multiple users simultaneously?
A: Yes, user sessions are managed separately using n8n’s global static data object keyed by Telegram user IDs.
10. Conclusion
By following this tutorial, you’ve built a Telegram-integrated Pomodoro timer using n8n that logs each session and break to Google Sheets automatically. You’ve eliminated the manual tracking hassle and gotten an easy way to stay focused and motivated.
This automation can save you and your team hours of tracking and improve productivity patterns with logged data for analysis.
Next steps could include adding task-specific logging, integrating with calendar apps to schedule Pomodoro sessions, or expanding the bot with AI-powered motivational messages.
Keep experimenting and enjoy your newfound productivity with automation!