Auto-Publish Blogger Posts to Telegram Channel
As a blogger, sharing your content across social media platforms is crucial for traffic. While tools like IFTTT or Zapier exist, they often come with limitations, delays, or premium pricing.
Here, I am going to share a completely free, serverless, and instant method to automatically send your new Blogger (Blogspot) posts to your Telegram Channel using Cloudflare Workers.
This method is fast, customizable, and runs 24/7 without costing a penny.
Prerequisites
Before we start, make sure you have:
- A Blogger website (obviously!).
- A Cloudflare account (Free tier is enough).
- A Telegram account.
Step 1: Create a Telegram Bot
We need a bot to act as the "sender" in your Telegram Channel.
- Open Telegram and search for @BotFather.
- Start a chat and send the command:
/newbot - Give your bot a name (e.g., MyBlogUpdateBot) and a unique username (ending in
bot). - BotFather will give you an HTTP API Token.
Keep this token safe; we will need it later.
Step 2: Set Up Your Telegram Channel
- Create a new Telegram Channel (or use an existing one).
- Add your new Bot as an Administrator to this channel (this allows the bot to post messages).
- Get your Channel ID:
- Send a generic message (e.g., "Hello") to your channel.
- Forward that message to a bot called @userinfobot or @JsonDumpBot.
- It will reply with an ID that looks like
-100123456789. Copy this ID.
Step 3: Create a Cloudflare Worker
Now, let's set up the automation engine.
- Log in to your Cloudflare Dashboard.
- Go to Workers & Pages on the left sidebar.
- Click Create Application > Create Worker.
- Name your worker (e.g.,
blogger-to-telegram) and click Deploy. - Once deployed, click on Edit Code.
Step 4: The Automation Code
Delete the existing code in the editor and paste the JavaScript code provided below.
Note: Don't forget to replace the BOT_TOKEN, CHAT_ID, and RSS_URL at the top with your own details.
const BOT_TOKEN = 'YOUR_TELEGRAM_BOT_TOKEN';
const CHAT_ID = 'YOUR_TELEGRAM_CHAT_ID';
const RSS_URL = 'https://www.yourblog.com/feeds/posts/default?alt=rss';
export default {
async scheduled(event, env, ctx) {
ctx.waitUntil(handleTask(env));
},
async fetch(request, env, ctx) {
return new Response(await handleTask(env));
}
};
async function handleTask(env) {
try {
const response = await fetch(RSS_URL);
const xml = await response.text();
const match = xml.match(/<link>(.*?)<\/link>/);
if (!match) return "RSS feed error.";
const lastPostLink = match[1];
const lastSent = await env.MY_STORE.get("last_post");
if (lastPostLink !== lastSent) {
const message = `New Blog Post!\n\n${lastPostLink}`;
const telegramUrl = `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${CHAT_ID}&text=${encodeURIComponent(message)}&parse_mode=Markdown`;
await fetch(telegramUrl);
await env.MY_STORE.put("last_post", lastPostLink);
return "Success: Post sent to Telegram.";
}
return "No new posts.";
} catch (err) {
return "Error: " + err.message;
}
}
Step 5: Configure KV Namespace (Crucial Step!)
To prevent the bot from sending the same post repeatedly, we use Cloudflare KV (Key-Value) storage to remember the last sent post.
- Go back to the Cloudflare Dashboard (leave the code editor for a moment).
- Navigate to Workers & Pages > KV.
- Click Create a Namespace. Name it
MY_STORE_KVand click Add. - Now, go back to your Worker settings:
- Click on your Worker name > Settings > Variables.
- Scroll down to KV Namespace Bindings.
- Click Add Binding.
- Variable name:
MY_STORE(Must match the code exactly!). - KV Namespace: Select
MY_STORE_KVfrom the dropdown. - Click Save and Deploy.
Step 6: Set Up Automation (Cron Triggers)
Finally, we need to tell Cloudflare to check your blog automatically.
- Go to your Worker > Triggers.
- Scroll to Cron Triggers.
- Click Add Cron Trigger.
- Select a frequency. I recommend every 30 minutes or 1 hour. (Cron expression:
*/30 * * * *). - Click Add Trigger.
Conclusion
That's it! Now, every time you publish a new article on Blogger, your Cloudflare Worker will wake up, detect the new link, and instantly share it with your Telegram audience.
Why use this method?
- Zero Cost: Cloudflare Workers allow 100,000 requests per day for free.
- No Third Parties: You don't need to give access to Zapier or IFTTT.
- Fast: The execution takes milliseconds.
If you found this guide helpful, share it with other bloggers! Happy blogging!