Jump to content

Recommended Posts

Posted

Hi ProcessWire community! πŸ‘‹

I'm excited to share a new module I've been working on: TeleWire - a Telegram notifications module that brings instant messaging capabilities to your ProcessWire sites.

The Problem with Current Notification Solutions

After running several e-commerce sites and experimenting with different notification systems, I've encountered these recurring issues:

πŸ“§ Email (SMTP/WireMail):

  • Requires SMTP server configuration (WireMailSMTP)
  • Google App Passwords setup complexity
  • Emails constantly landing in spam folders
  • Delayed delivery (sometimes 5-10 minutes)
  • No guarantee the recipient will see it quickly

πŸ“± SMS (Twilio, etc):

  • Monthly fees just to keep a phone number active (~$1-15/month)
  • Per-message charges (can add up quickly)
  • US compliance requirements (verification, regulations)
  • Not everyone wants to share their phone number

πŸ’¬ WhatsApp Business API:

  • Requires business verification
  • Complex setup process
  • API fees and restrictions
  • Limited to business accounts

πŸ”” Push services (Pushover, etc):

  • Requires purchasing apps ($5-10 per platform)
  • Recipient needs to install and configure the app
  • Additional barrier to entry

Why Telegram?

  • πŸ†“ Completely free - No monthly fees, no per-message charges, no app purchases
  • 🌍 Universally accessible - 900+ million users worldwide, already installed on most devices
  • ⚑ Instant delivery - Messages arrive in 1-2 seconds, not minutes
  • 🎯 Zero configuration barrier - Just start a conversation with your bot, that's it
  • πŸ”’ Reliable - No spam filters, no deliverability issues, no carrier restrictions
  • πŸ“± Multi-platform - iOS, Android, Web, Desktop - works everywhere
  • 🎨 Rich features - HTML formatting, emojis, photos, documents, links

Key Features

  • πŸš€ Send text notifications with HTML/Markdown formatting
  • πŸ“Έ Send photos and documents
  • πŸ‘₯ Support for multiple recipients (users and groups)
  • πŸ”§ Simple admin interface with test button
  • πŸ“Š Optional logging and debug mode
  • ⚑ Optimized performance with configurable timeouts
  • 🎯 Easy to integrate with hooks

Real-World Use Cases

E-commerce order notifications:

$wire->addHookAfter('FormBuilderProcessor::processInputDone', function($event) {
    $form = $event->object;
    
    if($form->name === 'order-form') {
        $telewire = $this->modules->get('TeleWire');
        
        $message = 'πŸ›’ <b>New Order</b>' . "\n\n";
        $message .= 'πŸ‘€ Customer: ' . $form->get('customer_name')->value . "\n";
        $message .= 'πŸ’° Total: $' . $form->get('total')->value;
        
        $telewire->send($message);
    }
});

Failed login attempts monitoring:

$wire->addHookAfter('Session::loginFailed', function($event) {
    $telewire = $this->modules->get('TeleWire');
    $name = $event->arguments(0);
    
    $message = '⚠️ <b>Failed Login Attempt</b>' . "\n\n";
    $message .= 'Username: ' . $name . "\n";
    $message .= 'IP: ' . $this->session->getIP();
    
    $telewire->send($message);
});

Content updates:

$wire->addHookAfter('Pages::saved', function($event) {
    $page = $event->arguments(0);
    
    if($page->template == 'article' && !$page->isNew()) {
        $telewire = $this->modules->get('TeleWire');
        
        $message = 'πŸ“ <b>Article Updated</b>' . "\n";
        $message .= 'Title: ' . $page->title . "\n";
        $message .= 'By: ' . $this->user->name;
        
        $telewire->send($message);
    }
});

Send photos with captions:

$telewire = $modules->get('TeleWire');

// Product photo when new product added
$telewire->sendPhoto(
    $page->images->first()->httpUrl,
    "New product: {$page->title} - \${$page->price}"
);

Send documents (invoices, reports):

$telewire = $modules->get('TeleWire');

// Send generated PDF invoice
$telewire->sendDocument(
    '/site/assets/invoices/invoice-123.pdf',
    'Invoice #123 for Order #456'
);

Installation

  1. Get a bot token from @BotFather on Telegram (takes 30 seconds)
  2. Install the module from GitHub
  3. Configure your bot token and chat IDs
  4. Click "Send Test Message" to verify everything works

Requirements: PHP 8.2+ and ProcessWire 3.0.210+

Admin Interface Features

The configuration page includes:

  • βœ… Real-time connection status indicator
  • πŸ§ͺ One-click test message button (AJAX, no page reload)
  • βš™οΈ Configurable parse mode (HTML/Markdown/MarkdownV2)
  • πŸ“ Optional logging with debug mode for troubleshooting
  • ⏱️ Adjustable API timeouts
  • πŸ”‡ Silent mode option (no notification sound)
  • πŸ“Š Message length handling (auto-split long messages)

Production Ready

This module is currently running on several production sites:

  • 🍫 E-commerce shop - order notifications, stock alerts
  • 🍷 Wine/liquor business - order confirmations, delivery updates
  • πŸ“° News portal - content publishing notifications

Average response time: ~150-300ms per notification

Getting Your Chat ID

  1. Find @userinfobot in Telegram
  2. Send any message - it will reply with your Chat ID
  3. Important: Start conversation with your bot by sending /start
  4. Enter the Chat ID in module configuration

For groups: Add the bot to your group, make it admin, and use the negative Chat ID

API Documentation

// Get module instance
$telewire = $modules->get('TeleWire');

// Simple text message
$telewire->send('Hello from ProcessWire!');

// HTML formatted message
$message = '<b>Bold</b> <i>italic</i> <code>code</code>';
$telewire->send($message);

// Send with custom options
$telewire->send('Silent notification', [
    'disable_notification' => true,
    'parse_mode' => 'Markdown'
]);

// Send photo
$telewire->sendPhoto('/path/to/photo.jpg', 'Optional caption');

// Send document
$telewire->sendDocument('/path/to/file.pdf', 'Document caption');

Feedback Welcome!

I'd love to hear your thoughts, use cases, and suggestions. If you've been frustrated with email deliverability or SMS costs for notifications, give this a try!

GitHub: https://github.com/mxmsmnv/TeleWire

Thanks to the ProcessWire community for the inspiration and all the great modules that helped me learn the PW module system! πŸ™


Bottom line: If your users have Telegram (and most do), you can send them instant, reliable, free notifications without fighting spam filters or paying monthly fees. Simple as that.Β 

  • Like 2
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Γ—
Γ—
  • Create New...