<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mahbub Hasan Imon</title>
    <description>The latest articles on DEV Community by Mahbub Hasan Imon (@mhimon).</description>
    <link>https://dev.to/mhimon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F108278%2F088a2203-5266-46d8-b01f-7c74dd64aed8.jpg</url>
      <title>DEV Community: Mahbub Hasan Imon</title>
      <link>https://dev.to/mhimon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mhimon"/>
    <language>en</language>
    <item>
      <title>How to Send Trello Notifications to Telegram Group Topic Using PHP Webhooks</title>
      <dc:creator>Mahbub Hasan Imon</dc:creator>
      <pubDate>Thu, 31 Jul 2025 08:47:16 +0000</pubDate>
      <link>https://dev.to/mhimon/how-to-send-trello-notifications-to-telegram-group-topic-using-php-webhooks-2kn3</link>
      <guid>https://dev.to/mhimon/how-to-send-trello-notifications-to-telegram-group-topic-using-php-webhooks-2kn3</guid>
      <description>&lt;p&gt;Trello is a great tool for task management, but its notification system is often limited when working with real-time team collaboration. If you're already using Telegram for team discussions, wouldn't it be great to get Trello notifications directly into a Telegram group topic?&lt;/p&gt;

&lt;p&gt;In this guide, you’ll learn how to set up a Trello webhook that sends live updates (like card creation, movement, and comments) to your Telegram group using a PHP script.&lt;/p&gt;

&lt;p&gt;🛠 What You’ll Learn&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to get your Trello API key and token&lt;/li&gt;
&lt;li&gt;How to create a Telegram bot and get your group/topic IDs&lt;/li&gt;
&lt;li&gt;How to set up a webhook to listen to Trello board activity&lt;/li&gt;
&lt;li&gt;How to use a PHP script to forward notifications to Telegram&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;🔑 Step 1: Get Your Trello API Key, Secret, and Token&lt;/p&gt;

&lt;p&gt;To interact with the Trello API, you'll need an App Key and a Token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔗 Trello Power-Up Admin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to:&lt;br&gt;
👉 &lt;a href="https://trello.com/power-ups/admin" rel="noopener noreferrer"&gt;https://trello.com/power-ups/admin&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click Create a new Power-Up&lt;/li&gt;
&lt;li&gt;Name it and generate an App Key&lt;/li&gt;
&lt;li&gt;Save your API Key and API Secret&lt;/li&gt;
&lt;li&gt;Then go to this URL to generate your token: &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://trello.com/1/authorize?key=YOUR_API_KEY&amp;amp;name=TrelloToTelegram&amp;amp;expiration=never&amp;amp;response_type=token&amp;amp;scope=read,write" rel="noopener noreferrer"&gt;https://trello.com/1/authorize?key=YOUR_API_KEY&amp;amp;name=TrelloToTelegram&amp;amp;expiration=never&amp;amp;response_type=token&amp;amp;scope=read,write&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🧾 Step 2: Get Your Trello Board ID&lt;/p&gt;

&lt;p&gt;You need the Board ID to create a webhook.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find your board short link (e.g. &lt;a href="https://trello.com/b/7G08MJrU/project-name" rel="noopener noreferrer"&gt;https://trello.com/b/7G08MJrU/project-name&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Use this endpoint (replace key and token):&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://api.trello.com/1/boards/7G08MJrU?key=YOUR_API_KEY&amp;amp;token=YOUR_TOKEN" rel="noopener noreferrer"&gt;https://api.trello.com/1/boards/7G08MJrU?key=YOUR_API_KEY&amp;amp;token=YOUR_TOKEN&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It returns JSON like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
  "id": "63f8c1c1234567890abcdef1",&lt;br&gt;
  "name": "Project Board",&lt;br&gt;
  ...&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Copy the id — that’s your full Board ID.&lt;/p&gt;

&lt;p&gt;🤖 Step 3: Create a Telegram Bot &amp;amp; Get Topic ID&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://t.me/BotFather" rel="noopener noreferrer"&gt;@BotFather&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Use /newbot to create a bot&lt;/li&gt;
&lt;li&gt;Copy the bot token&lt;/li&gt;
&lt;li&gt;Add the bot to your Telegram group and make it an admin&lt;/li&gt;
&lt;li&gt;Enable topics in your group (Group Settings &amp;gt; Manage Topics)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now send any message to your desired topic.&lt;/p&gt;

&lt;p&gt;Get your topic ID (message_thread_id):&lt;/p&gt;

&lt;p&gt;Visit &lt;a href="https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates" rel="noopener noreferrer"&gt;https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look for: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;"message_thread_id": 1253&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Save the topic ID and your group’s chat_id (like -1001842173606)&lt;/p&gt;

&lt;p&gt;🧰 Step 4: Create the PHP Webhook Handler&lt;/p&gt;

&lt;p&gt;Create a file like trello-to-telegram.php and upload it to your hosting.&lt;/p&gt;

&lt;p&gt;Here’s a complete, production-ready script:&lt;/p&gt;

&lt;p&gt;`&amp;lt;?php&lt;br&gt;
$telegramToken = 'YOUR_TELEGRAM_BOT_TOKEN';&lt;br&gt;
$chatId = '-100YOUR_GROUP_ID';&lt;br&gt;
$topicId = 1253; // Topic ID in Telegram&lt;/p&gt;

&lt;p&gt;if ($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'HEAD') {&lt;br&gt;
    http_response_code(200);&lt;br&gt;
    exit;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;$input = file_get_contents('php://input');&lt;br&gt;
$data = json_decode($input, true);&lt;/p&gt;

&lt;p&gt;file_put_contents(&lt;strong&gt;DIR&lt;/strong&gt; . '/log.txt', date('Y-m-d H:i:s') . " " . $input . PHP_EOL, FILE_APPEND);&lt;/p&gt;

&lt;p&gt;if (!isset($data['action'])) {&lt;br&gt;
    http_response_code(400);&lt;br&gt;
    echo 'Invalid webhook';&lt;br&gt;
    exit;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;$actionId = $data['action']['id'] ?? '';&lt;br&gt;
$cacheFile = &lt;strong&gt;DIR&lt;/strong&gt; . '/actions_cache.txt';&lt;br&gt;
$processed = file_exists($cacheFile) ? explode("\n", trim(file_get_contents($cacheFile))) : [];&lt;/p&gt;

&lt;p&gt;if (in_array($actionId, $processed)) {&lt;br&gt;
    http_response_code(200);&lt;br&gt;
    exit;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;file_put_contents($cacheFile, $actionId . "\n", FILE_APPEND);&lt;/p&gt;

&lt;p&gt;$allowedActions = ['createCard', 'commentCard', 'updateCard'];&lt;br&gt;
$action = $data['action'];&lt;br&gt;
$actionType = $action['type'] ?? '';&lt;/p&gt;

&lt;p&gt;if (!in_array($actionType, $allowedActions)) {&lt;br&gt;
    http_response_code(200);&lt;br&gt;
    exit;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;$user = $action['memberCreator']['fullName'] ?? 'Someone';&lt;br&gt;
$cardName = $action['data']['card']['name'] ?? '';&lt;br&gt;
$cardShortLink = $action['data']['card']['shortLink'] ?? '';&lt;br&gt;
$cardUrl = $cardShortLink ? "&lt;a href="https://trello.com/c/$cardShortLink" rel="noopener noreferrer"&gt;https://trello.com/c/$cardShortLink&lt;/a&gt;" : '';&lt;br&gt;
$boardName = $action['data']['board']['name'] ?? '';&lt;br&gt;
$message = "📋 &lt;em&gt;Board:&lt;/em&gt; &lt;em&gt;{$boardName}&lt;/em&gt;\n";&lt;/p&gt;

&lt;p&gt;if ($actionType === 'createCard') {&lt;br&gt;
    $message .= "🆕 &lt;em&gt;$user&lt;/em&gt; created a card:\n*{$cardName}*";&lt;/p&gt;

&lt;p&gt;} elseif ($actionType === 'commentCard') {&lt;br&gt;
    $comment = $action['data']['text'] ?? '[No comment]';&lt;br&gt;
    $commentUrl = $cardShortLink ? "&lt;a href="https://trello.com/c/$cardShortLink#comment-%7B$actionId%7D" rel="noopener noreferrer"&gt;https://trello.com/c/$cardShortLink#comment-{$actionId}&lt;/a&gt;" : '';&lt;br&gt;
    $message .= "💬 &lt;em&gt;$user&lt;/em&gt; commented on &lt;em&gt;{$cardName}&lt;/em&gt;:\n\"{$comment}\"\n🔗 &lt;a href="https://dev.to$commentUrl"&gt;View Comment&lt;/a&gt;";&lt;/p&gt;

&lt;p&gt;} elseif ($actionType === 'updateCard') {&lt;br&gt;
    $fromList = $action['data']['listBefore']['name'] ?? null;&lt;br&gt;
    $toList = $action['data']['listAfter']['name'] ?? null;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if ($fromList &amp;amp;&amp;amp; $toList) {
    $message .= "🔄 *$user* moved *{$cardName}* from _{$fromList}_ to _{$toList}_";
} else {
    $message .= "✏️ *$user* updated *{$cardName}*";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;if ($cardUrl) {&lt;br&gt;
    $message .= "\n🔗 &lt;a href="https://dev.to$cardUrl"&gt;View Card&lt;/a&gt;";&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;$sendUrl = "&lt;a href="https://api.telegram.org/bot$telegramToken/sendMessage" rel="noopener noreferrer"&gt;https://api.telegram.org/bot$telegramToken/sendMessage&lt;/a&gt;";&lt;br&gt;
$params = [&lt;br&gt;
    'chat_id' =&amp;gt; $chatId,&lt;br&gt;
    'message_thread_id' =&amp;gt; $topicId,&lt;br&gt;
    'text' =&amp;gt; $message,&lt;br&gt;
    'parse_mode' =&amp;gt; 'Markdown',&lt;br&gt;
];&lt;br&gt;
$options = [&lt;br&gt;
    'http' =&amp;gt; [&lt;br&gt;
        'header'  =&amp;gt; "Content-type: application/json",&lt;br&gt;
        'method'  =&amp;gt; 'POST',&lt;br&gt;
        'content' =&amp;gt; json_encode($params),&lt;br&gt;
        'timeout' =&amp;gt; 10,&lt;br&gt;
    ],&lt;br&gt;
];&lt;br&gt;
$context = stream_context_create($options);&lt;br&gt;
file_get_contents($sendUrl, false, $context);&lt;/p&gt;

&lt;p&gt;http_response_code(200);&lt;br&gt;
echo 'OK';&lt;br&gt;
?&amp;gt;`&lt;/p&gt;

&lt;p&gt;🔗 Step 5: Create the Webhook in Trello&lt;/p&gt;

&lt;p&gt;Use the Trello API to create a webhook:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curl -X POST "https://api.trello.com/1/webhooks?key=YOUR_API_KEY&amp;amp;token=YOUR_TOKEN" \&lt;br&gt;
  -H "Content-Type: application/json" \&lt;br&gt;
  -d '{&lt;br&gt;
    "description": "Trello to Telegram",&lt;br&gt;
    "callbackURL": "https://yourdomain.com/trello-to-telegram.php",&lt;br&gt;
    "idModel": "YOUR_BOARD_ID"&lt;br&gt;
}'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;✅ If it responds with &lt;code&gt;"active": true,&lt;/code&gt; your webhook is working.&lt;/p&gt;

&lt;p&gt;🔍 Logging and Debugging&lt;/p&gt;

&lt;p&gt;To debug or view logs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check log.txt to see incoming payloads&lt;/li&gt;
&lt;li&gt;Check actions_cache.txt to avoid duplicate alerts&lt;/li&gt;
&lt;li&gt;Use getUpdates API in Telegram to inspect recent messages: &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates" rel="noopener noreferrer"&gt;https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;✅ Final Result&lt;/p&gt;

&lt;p&gt;Whenever someone:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creates a card&lt;/li&gt;
&lt;li&gt;Moves a card&lt;/li&gt;
&lt;li&gt;Comments on a card&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your Telegram topic gets an instant notification. 🔔&lt;/p&gt;

&lt;p&gt;👋 Conclusion&lt;/p&gt;

&lt;p&gt;This setup is simple yet powerful for connecting Trello boards to Telegram using webhooks and plain PHP. You can customize it further to support checklist items, due dates, or even button-based interactions.&lt;/p&gt;

</description>
      <category>trello</category>
      <category>telegram</category>
      <category>php</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to register custom Gutenberg Block Category</title>
      <dc:creator>Mahbub Hasan Imon</dc:creator>
      <pubDate>Wed, 07 Jun 2023 12:24:43 +0000</pubDate>
      <link>https://dev.to/mhimon/how-to-register-custom-gutenberg-block-category-67c</link>
      <guid>https://dev.to/mhimon/how-to-register-custom-gutenberg-block-category-67c</guid>
      <description>&lt;p&gt;You might be familiar with Gutenberg, the new block-grounded editor introduced in WordPress 5, If you are a WordPress developer Gutenberg allows you to create custom blocks, which are basically applicable pieces of content that you can use to build pages and posts.&lt;/p&gt;

&lt;p&gt;By default, Gutenberg comes with some built-in block categories, such as Text, Media, Design, Widgets, etc. However, if you want to create custom blocks for your clients or someone you can create your own custom &lt;strong&gt;block category&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here’s how we can do it, and still maintain the backward compatibility for WordPress lower than 5.8.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Create Block Category.
function mh_custom_block_category( $categories ) {
    return array_merge(
      $categories,
        array(
            array(
                'slug'  =&amp;gt; 'custom-blocks',
                'title' =&amp;gt; __( 'Custom Blocks', 'textdomain' ),
            ),
        )
    );
}
global $wp_version;
add_filter( 'block_categories' . ( version_compare( $wp_version, '5.8', '&amp;gt;=' ) ? '_all' : '' ), 'mh_custom_block_category', 99 );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change your custom block category to custom-blocks&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "custom-blocks/tabs",
  "version": "0.1.0",
  "title": "Custom Blocks",
  "category": "custom-blocks",
  "icon": "smiley",
  "description": "Custom Blocks"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;save and you will see your custom category.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Syd-HszG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gimwb4zb3pinz7aw34mh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Syd-HszG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gimwb4zb3pinz7aw34mh.png" alt="Image description" width="800" height="804"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading! I hope this post will help you. If you have any questions related to this post please feel free to leave them below.&lt;/p&gt;

&lt;p&gt;Thanks again!&lt;/p&gt;

</description>
      <category>gutenberg</category>
      <category>wordpress</category>
      <category>blockdevelopment</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
