Telegram Notification Channel icon

Telegram Notification Channel

This plugin is no longer maintained.

Telegram Notification Channel plugin for Craft Notifications

A Telegram notification channel for the Craft Notifications plugin

Requirements

Setting up your Telegram Bot

Talk to @BotFather and generate a Bot API Token.

Then, configure your Telegram Bot API Token either through the plugin settings or by copying the config.php file to config/telegram-notification-channel.php and setting the token there.

Using the Telegram Notification Channel

You can now add telegram to your via() function. You will also have to provide a toTelegram function to create your message.

use rias\notifications\models\Notification;
use rias\telegramnotificationchannel\models\TelegramMessage;

/**
 * Get the notification's delivery channels.
 *
 * @return array
 */
public function via()
{
    return ['telegram' => '<YOUR_USER_ID/CHAT_ID>'];
}

public function toTelegram()
{
    $blogpost = $this->event->sender;

    return TelegramMessage::create()
        //->to($this->user->telegram_user_id) // You can provide a different user or chat to send to here.
        ->content("A new blogpost has been added:\n*{$blogpost->title}*") // Markdown supported.
        ->button('View blogpost', $blogpost->url); // Inline Button
}

Here's a screenshot preview of the above notification on Telegram Messenger:

Message screenshot

Available message methods

  • to($chatId): (integer) Recipient's chat id or user id.
  • content(''): (string) Notification message, supports markdown. For more information on supported markdown styles, check out these docs.
  • button($text, $url): (string) Adds an inline "Call to Action" button. You can add as many as you want and they'll be placed 2 in a row.
  • options([]): (array) Allows you to add additional or override sendMessage payload (A Telegram Bot API method used to send message internally). For more information on supported parameters, check out these docs.

Credits

Brought to you by Rias

Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
0
Version
1.0.1
License
MIT
Compatibility
Craft 3
Last release
May 21, 2018
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs