n8n

How to Automate Gmail and Telegram Stats Reports?

Get a daily stats report created and sent without manual work. The flow collects public JSON data, ranks top creators and workflows, writes a clear summary with AI, and delivers it by email and Telegram. It is useful for community and marketing teams that share updates with their audience.

On a schedule, the workflow pulls two JSON files from a public URL. It parses the data, splits creators and workflows, and sorts by recent activity. It then takes the top creators and top workflows, and merges results for a clean report. Two AI models help write content: one drafts the full summary, and another builds a short top 10 list. Markdown is converted to HTML, emails are sent with Gmail, and a Telegram post shares highlights. The report is also saved to Google Drive, with an optional local markdown file for on-prem setups. It can also be called by another workflow to get stats for a single user on demand.

Setup needs API keys and OAuth for each service. After you connect OpenAI, Google Gemini, Gmail, Google Drive, and Telegram, set the schedule and data path. Expect to cut reporting time from hours to minutes and keep updates consistent. Great for weekly newsletters, internal updates, and public community highlights.

What are the key features?

  • Scheduled run collects fresh JSON data on a set cadence.
  • HTTP requests fetch creators and workflows data from a public path.
  • Sorting and limiting nodes rank recent activity and pick top lists.
  • OpenAI drafts a long form summary in clear markdown.
  • Google Gemini creates a concise top 10 list ready for sharing.
  • Markdown is converted to HTML for clean emails and posts.
  • Results are sent via Gmail and posted to Telegram, and saved to Google Drive.
  • Callable tool supports on demand lookups for a single username.

What are the benefits?

  • Reduce manual reporting work from 3 hours to 10 minutes
  • Automate 90% of the weekly report build and delivery
  • Improve ranking accuracy by eliminating copy paste errors
  • Share updates on two channels at once email and Telegram
  • Handle larger data sets by sorting and limiting top results

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with OpenAI, Google Gemini, Google Drive, Gmail and Telegram. See the Tools Required section above for links to create accounts with these services.
  3. Open the OpenAI node labeled gpt-4o-mini. In the credential dropdown, click Create new credential. Add your OpenAI API key from the OpenAI API keys page and save.
  4. Open the Google Gemini Chat Model node. Create a new credential. Use an API key from Google AI Studio, paste it, and save.
  5. Open the Gmail nodes. Create a new Gmail OAuth2 credential, sign in to your Google account, approve the requested scopes, and save.
  6. Open the Google Drive node. Create a new Google Drive OAuth2 credential, sign in, approve scopes, and select the target folder for uploads.
  7. Open the Telegram node. Create a bot with BotFather to get a bot token. In n8n, create a new Telegram credential with the bot token. Set the chat ID in the node so messages go to the right chat.
  8. Open the Global Variables node. Confirm the public path and file names for the JSON sources. Update these values if your data lives at a different URL.
  9. Check the Limit nodes for Take Top 10 Creators and Take Top 50 Workflows. Adjust these numbers if you want different list sizes.
  10. Open the Schedule Trigger and set the time zone and run time that match your reporting needs.
  11. Optional for self hosted use: If you do not want a local markdown file, disable the Save creator-summary.md node.
  12. Click Execute Workflow once to test. Confirm you receive an email in Gmail, see a Telegram message, and find the HTML or markdown saved in Google Drive.
  13. Troubleshooting: If emails fail, recheck Gmail OAuth. If Telegram does not send, verify bot token and chat ID. If data is empty, make sure the public URL is reachable and the JSON file names in Global Variables are correct.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Gmail

Sign up

No cost: Personal Gmail (Gmail API has no usage-based pricing; quotas apply)

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

Google Gemini

Sign up

Free tier: $0 via Gemini API; e.g., Gemini 2.5 Flash-Lite free limits 1,000 requests/day (15 RPM, 250k TPM). Paid from $0.10/1M input tokens and $0.40/1M output tokens.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Credits:
Author: teds-tech-talks
GitHub repository
Leaderboard site

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.