1. Opening Problem Statement
Meet Anna, an avid reader and writer who often receives documents and ebooks from friends and colleagues via Telegram. The problem? Anna wants to read these files comfortably on her Kindle, but emailing each document manually is tedious and time-consuming. It often takes her 10-15 minutes for each file upload—she even missed some great reads because she forgot to send the files to her Kindle. This manual process wastes her valuable time and disrupts her reading flow.
Imagine receiving files daily and manually forwarding each to your Kindle address. Over a week, this can add up to hours lost and increased frustration. Anna needs a smart, automated solution to bridge Telegram and Kindle effortlessly.
2. What This Automation Does
This n8n workflow automates sending files received through a Telegram bot directly to a Kindle email address. Here’s what happens when the workflow runs:
- Whenever a user sends a file to your Telegram bot, it automatically detects the file.
- It checks if the incoming message actually contains a file; if not, it politely warns the sender.
- The workflow renames the file properly to maintain its original filename.
- It sends the file as an email attachment to your Kindle email address using Microsoft Outlook.
- After successful sending, it confirms in the Telegram chat that the file was sent.
This automation can save Anna up to 15 minutes per file, eliminating the repetitive steps and minimizing the chance of forgetting to send files.
3. Prerequisites ⚙️
- Telegram account with a bot created via BotFather 📱
- Microsoft Outlook email account with SMTP configured in n8n 📧 🔑
- Kindle device or app registered to receive documents via your Kindle email address 🔐
- n8n account set up and running (self-hosting optional for more control)
4. Step-by-Step Guide
Step 1: Create a Telegram Bot and Connect It to n8n
Go to Telegram and search for BotFather. Use the command /newbot to create a new bot. Note the bot token provided. In your n8n instance, navigate to Credentials and add a new Telegram Bot credential with this token.
Expected: Your bot is now ready to receive messages via n8n.
Common Mistake: Using the wrong bot token or not enabling message updates can cause the workflow not to trigger.
Step 2: Set Up the Telegram Trigger Node “receive file message from telegram bot”
In n8n, create a new workflow. Drag in a Telegram Trigger node.
Configure it to listen to message updates and enable the option to download files received automatically.
You should see your webhook URL generated; this connects Telegram messages to your workflow.
Step 3: Add an IF Node to Check for File Existence
Add an IF node named “check if there is a file in the message.” Configure it to check if the incoming Telegram message contains a document (file) using the expression {{$json.message.document}} with the condition “exists.”
This ensures the workflow only processes messages with files.
Step 4: Reply with a Warning if No File Is Present
Add a Telegram node named “reply to warn that file is missing.” Connect it to the IF node’s false branch. Configure this node to send a message back to the chat ID from the original message with the text: “There is no file in message. Please check.” Also, set it to reply to the original message.
Step 5: Rename the File Properly for Email Attachment
Add a Code node named “rename file to as attachment out email.” Use the following JavaScript code:
// Loop over input items and rename the file
for (const item of $input.all()) {
item.binary.data.fileName = item.json.message.document.file_name;
}
return $input.all();
This step renames the downloaded file in the binary data to match the original filename, ensuring the attachment is correctly named when sent by email.
Step 6: Send the Email with the File Attached to Kindle
Drag a Microsoft Outlook node named “send email with the file as attchament to kindle.” Configure it as follows:
- Subject: “book from telegram bot”
- Body Content: Use the expression
=This is a book named {{ $json.message.document.file_name }} from telegram bot. - To Recipients: Your Kindle email address (e.g., [email protected])
- Attachments: Map the binary file data named
dataas attachment
When this runs, the email with the file attached will be sent to your Kindle.
Step 7: Confirm Successful File Send Back in Telegram Chat
Add a final Telegram node named “reply to telegram chat that the file has been sent successfully.” Connect it after the email node. Configure it to send a confirmation message to the same chat ID with text: “file is sent to kindle successfully!” Also, set reply to the original message.
5. Customizations ✏️
- Change Recipient Email: In the Microsoft Outlook node, update the
toRecipientsfield to any email address you want to forward files to, for example, another ebook reader email. - Adjust Bot Response Messages: Modify the text in the Telegram nodes to personalize your bot’s replies, such as including sender names or timestamps.
- Support Multiple File Types: Enhance the IF node with additional conditions to handle photos or videos by checking
message.photoormessage.videoobjects. - Integrate With Other Email Services: Replace the Microsoft Outlook node with Gmail or SMTP nodes to better fit your email provider.
6. Troubleshooting 🔧
Problem: “No file found” despite sending a file.
Cause: The IF node condition is not correctly set to detect the document.
Solution: Double-check the IF node expression uses {{$json.message.document}} and the operator is “exists.” Test with a supported file like PDF.
Problem: Email fails to send.
Cause: Invalid Outlook credentials or missing permissions to send to Kindle.
Solution: Verify Outlook credentials in n8n, ensure your email is allowed in Kindle settings under “Approved Personal Document E-mail List.” Test sending a manual email through Outlook.
7. Pre-Production Checklist ✅
- Confirm Telegram bot is actively receiving messages with downloaded files.
- Verify IF node correctly branches only for messages with documents.
- Test Code node renaming by checking filenames in email attachments.
- Confirm Microsoft Outlook credentials work and emails are sent without errors.
- Send test files and verify delivery to your Kindle device.
8. Deployment Guide
Activate your workflow by toggling it from inactive to active in n8n. Make sure your Telegram webhook is accessible online, especially if self-hosting. Monitor the executions tab for any errors or failures. You can enable execution saving for audit or debugging.
9. FAQs
- Q: Can I use Gmail instead of Microsoft Outlook?
A: Yes, you can replace the Microsoft Outlook node with Gmail or SMTP nodes with similar configuration. - Q: Does this use API credits?
A: Telegram bot usage is typically free with some limits; Outlook email sending depends on your email plan. - Q: Is my data secure?
A: Your files pass through n8n and email servers; ensure secure credentials and HTTPS webhook usage for best security.
10. Conclusion
By following this guide, you’ve automated sending Telegram files directly to your Kindle via email using n8n. This workflow saves up to 15 minutes per file and removes manual hassles, improving your reading experience. Next, consider automating file conversion before sending, integrating document storage backups, or adding OCR for scanned books. Let your automation free your time and enhance your Kindle reading journey!