Skip to main content
Tutorials & Guides

Building Resilient Automation: Telegram Bot Publishing & Webhooks in TypeScript

Dispatching instant notifications to Telegram channels when new technical articles go live.

Makhlwf
4 min read
Updated Nov 4, 2026

Automated Syndication #

Broadcasting newly published articles to subscriber channels ensures your readership is alerted immediately without relying on algorithm-driven social feeds.

typescript
interface TelegramPublishPayload {
  title: string;
  url: string;
  excerpt: string;
  category: string;
}

export async function broadcastToTelegram(
  botToken: string,
  chatId: string,
  article: TelegramPublishPayload
): Promise<boolean> {
  const message = [
    `🚀 *New Article Published*`,
    ``,
    `*\${article.title}*`,
    `_\${article.excerpt}_`,
    ``,
    `🏷 Category: #\${article.category}`,
    `🔗 Read more: \${article.url}`,
  ].join('\n');

  const endpoint = `https://api.telegram.org/bot\${botToken}/sendMessage`;
  const response = await fetch(endpoint, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      chat_id: chatId,
      text: message,
      parse_mode: 'Markdown',
      disable_web_page_preview: false,
    }),
  });

  return response.ok;
}

With this modular approach, notifications trigger asynchronously in the background as soon as an article transitions to published status.

Share:PostShareTelegram
M

Published by Makhlwf

A five years junior engineer. specialized in Python, C# and website designing.