Oct 23, 2025

Convert Email to Webpage & Telegram Alert

Convert Email to Webpage & Telegram Alert Turn incoming emails into short-lived HTML webpages and get instant Telegram notifications with a compact n8n workflow. This automation saves the email body as a private GitHub Gist, posts a preview link to Telegram, and automatically cleans up both the Gist and Telegram message after a short delay. […]

Convert Email to Webpage & Telegram Alert

Convert Email to Webpage & Telegram Alert

Turn incoming emails into short-lived HTML webpages and get instant Telegram notifications with a compact n8n workflow. This automation saves the email body as a private GitHub Gist, posts a preview link to Telegram, and automatically cleans up both the Gist and Telegram message after a short delay.

Why this automation?

This workflow is ideal when you want to preview an email in a browser without forwarding or storing it permanently on your server. Use cases include: one-time access to invoice previews, secure sharing of email content between team members, or quickly surfacing important messages to a Telegram channel.

How the workflow works (overview)

  • IMAP Email Trigger: Watches your inbox for new/unseen messages.
  • Create GitHub Gist: Saves the email’s HTML content as a private Gist named email.html.
  • Telegram Notification Sender: Sends a Telegram message with an inline button linking to the rendered Gist page.
  • Deletion Delay: Waits (e.g., 3 hours) to keep the shared page ephemeral.
  • Delete GitHub Gist & Telegram Message Deleter: Removes the Gist and deletes the Telegram notification after the delay.

Step-by-step setup

1. IMAP Email Trigger

Configure the node to monitor the mailbox (for example, INBOX) and use options to fetch only UNSEEN messages. The node provides the message in resolved format containing html, from, and to fields that subsequent nodes can reference.

2. Create GitHub Gist (HTTP Request)

This node posts the email HTML to the GitHub Gist API. Use a predefined GitHub API credential in n8n to authenticate securely. The request body is JSON with the gist file called email.html. Example request body (n8n expression-friendly):

{
  "description": "{{ $json.date }} - from {{ JSON.stringify($json.from.value[0].address).slice(1, -1) }}",
  "public": false,
  "files": {
    "email.html": {
      "content": "{{ JSON.stringify($json.html).slice(1, -1) }}"
    }
  }
}

Important headers: set Accept: application/vnd.github+json. The Gist is created privately (public: false), but you will share a short-lived link to a rendering endpoint or your GitHub Pages proxy.

3. Telegram Notification Sender

Send a message to your Telegram chat or channel with HTML parse mode enabled. Use an inline keyboard with a button that links to the public rendering of the gist. Example message template:

📧 <b>You've got mail!</b>

A new email arrived from: <code>{{ $node["IMAP Email Trigger"].json.from.value[0].address }}</code>

🔗 Preview: [Open email](<gist-render-url>)

Set disable_web_page_preview to true if you prefer not to show link previews in Telegram. Use environment variables for the Telegram chat ID (for example, $env.TELEGRAM_CHAT_ID) so you don’t hard-code sensitive values.

4. Deletion Delay

The wait node delays downstream actions for the configured amount of time (e.g., 3 hours). This makes the ephemeral content available briefly before automatic cleanup.

5. Delete GitHub Gist and Telegram Message

After the wait, send a DELETE to https://api.github.com/gists/{{id}} to remove the gist. Then call Telegram’s deleteMessage operation with the saved message_id to remove the notification.

Security & privacy considerations

  • Keep your GitHub API credential and Telegram bot token secret. Use n8n credentials or environment variables to store them.
  • Use private gists (public: false) and short expiry windows (e.g., 1–6 hours) to reduce exposure.
  • If you need stricter access control, host an authenticated renderer on your domain rather than linking directly to raw Gist content.
  • Be careful with attachments and embedded remote images in email HTML (they may expose external resource calls). Consider sanitizing or inlining resources if necessary.

Hosting the rendered page

Raw Gist HTML can be viewed by direct URL patterns or rendered through a lightweight proxy application or GitHub Pages. The example template uses a small renderer (referenced in the original repo) that lets you serve the created gist at a friendly URL like:

http://your-domain/?iloven8n=project&id={{gist_id}}

If you host a simple renderer, you can control styling, add auth, or limit access by IP or token.

Troubleshooting & tips

  • If the Gist creation fails, verify the GitHub token scopes include gists.
  • Make sure the IMAP node’s credentials allow access and that mailbox names are correct (case-sensitive for some servers).
  • For Telegram message deletion to work, the message must have been posted by your bot and the bot needs permission to delete messages in the chat.
  • Use n8n’s splitInBatches or rate-limiting if you expect high email volume.

Possible enhancements

  • Sanitize or strip tracking pixels and external requests from email HTML to protect privacy.
  • Automatically extract attachments and upload them to a secure file store instead of embedding.
  • Change retention dynamically based on message priority — e.g., immediate deletion for low-priority messages.
  • Log deletions to a secure audit store for compliance reviews.

Wrap-up and call-to-action

This n8n template offers a compact way to convert emails into short-lived web previews and notify teams via Telegram. It’s perfect for quick sharing without long-term storage.

Try the template in your n8n instance: configure GitHub and Telegram credentials, set your IMAP account, and enable the workflow. If you found this guide helpful, star the project repository, share your improvements, or reach out for custom automation help.

Ready to deploy? Import the workflow into n8n, configure your credentials, and run a test email. Need help customizing it to your use case? Contact us or leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *