PHPackages                             onmotion/yii2-telegram - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. onmotion/yii2-telegram

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

onmotion/yii2-telegram
======================

Support chat for site based on Telegram bot

v0.8.6(7y ago)526.3k23[1 issues](https://github.com/onmotion/yii2-telegram/issues)MITPHPPHP &gt;=5.5.0

Since Aug 9Pushed 7y ago10 watchersCompare

[ Source](https://github.com/onmotion/yii2-telegram)[ Packagist](https://packagist.org/packages/onmotion/yii2-telegram)[ RSS](/packages/onmotion-yii2-telegram/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (21)Used By (0)

**Telegram support Bot for Yii2**
=================================

[](#telegram-support-bot-for-yii2)

[![Latest Stable Version](https://camo.githubusercontent.com/7b70908bb2ed43b37bd149ac0e7caad3a7972b087497103b1b206ec583028684/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6d6f74696f6e2f796969322d74656c656772616d2f762f737461626c65)](https://packagist.org/packages/onmotion/yii2-telegram) [![Total Downloads](https://camo.githubusercontent.com/792e8b854c812ca497dc18d2b8f1f69e298c74adf3498a8b5c49eace72d24760/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6d6f74696f6e2f796969322d74656c656772616d2f646f776e6c6f616473)](https://packagist.org/packages/onmotion/yii2-telegram) [![License](https://camo.githubusercontent.com/c4e6b04416f607d1cf2edd3d8bb7082ef968346565a6ffa452ce443c990f71ee/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6d6f74696f6e2f796969322d74656c656772616d2f6c6963656e7365)](https://packagist.org/packages/onmotion/yii2-telegram) [![Daily Downloads](https://camo.githubusercontent.com/291b238d07aa0e058defd30aa8c0266b4a24025db0955d47a5dbcab8e8272b41/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6d6f74696f6e2f796969322d74656c656772616d2f642f6461696c79)](https://packagist.org/packages/onmotion/yii2-telegram) [![Monthly Downloads](https://camo.githubusercontent.com/393e7a872a940def9b6e577c444be3c8fa2fc723de293334a9dc02cdcbf4312a/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6d6f74696f6e2f796969322d74656c656772616d2f642f6d6f6e74686c79)](https://packagist.org/packages/onmotion/yii2-telegram)

**Support chat for site based on Telegram bot**

The Bot logic based on [akalongman/php-telegram-bot](https://github.com/akalongman/php-telegram-bot), so you can read Instructions by longman how to register Telegram Bot and etc.

***Now only telegram webhook api support. You need SSL cert! Doesn't work on http!***

**Installation**
----------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Run

```
composer require onmotion/yii2-telegram

```

add to your web config:

```
 'modules' => [
     //...
    'telegram' => [
        'class' => 'onmotion\telegram\Module',
        'API_KEY' => 'forexample241875489:AdfgdfFuVJdsKa1cycuxra36g4dfgt66',
        'BOT_NAME' => 'YourBotName_bot',
        'hook_url' => 'https://yourhost.com/telegram/default/hook', // must be https! (if not prettyUrl https://yourhost.com/index.php?r=telegram/default/hook)
        'PASSPHRASE' => 'passphrase for login',
        // 'db' => 'db2', //db file name from config dir
        // 'userCommandsPath' => '@app/modules/telegram/UserCommands',
        // 'timeBeforeResetChatHandler' => 60
    ]
    //more...
 ]

```

and to console config:

```
 'bootstrap' => [
 //other bootstrap components...
                'telegram'],
 'modules' => [
         //...
     'telegram' => [
         'class' => 'onmotion\telegram\Module',
         'API_KEY' => 'forexample241875489:AdfgdfFuVJdsKa1cycuxra36g4dfgt66',
         'BOT_NAME' => 'YourBotName_bot',
     'hook_url' => 'https://yourhost.com/telegram/default/hook', // must be https! (if not prettyUrl https://yourhost.com/index.php?r=telegram/default/hook)
         'PASSPHRASE' => 'passphrase for login',
     ]
 ],

```

run migrations:

```
php yii migrate --migrationPath=@vendor/onmotion/yii2-telegram/migrations #that add 4 tables in your DB

```

or add to your config file

```
'controllerMap' => [
    ...
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationNamespaces' => [
            'onmotion\telegram\migrations',
        ],
    ],
    ...
],

```

and run

```
php yii migrate/up

```

go to  (if not prettyUrl )

Now you can place where you want

```
echo \onmotion\telegram\Telegram::widget(); //that add chat button in the page

```

in bottom right corner you can see:

[![chat button](https://github.com/onmotion/yii2-telegram/raw/wiki/_wiki/04.png?raw=true)](https://github.com/onmotion/yii2-telegram/blob/wiki/_wiki/04.png?raw=true)

if you click it:

[![client chat](https://github.com/onmotion/yii2-telegram/raw/wiki/_wiki/03.png?raw=true)](https://github.com/onmotion/yii2-telegram/blob/wiki/_wiki/03.png?raw=true)

and server side:

[![client chat](https://github.com/onmotion/yii2-telegram/raw/wiki/_wiki/02.png?raw=true)](https://github.com/onmotion/yii2-telegram/blob/wiki/_wiki/02.png?raw=true)

If you want to limit the storage period of messages history, add to you crontab:

```
#leave 5 days (if empty - default = 7)
php yii telegram/messages/clean 5

```

Also you can use custom commands. To do this, you can copy UserCommands dir from /vendor/onmotion/yii2-telegram/Commands and add path to this in config, for example:

```
'userCommandsPath' => '@app/modules/telegram/UserCommands'

```

**timeBeforeResetChatHandler** - the number of minutes before chat handler will be killed (if he forgot do /leavedialog). Never kill if 0 or not setted.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~44 days

Recently: every ~168 days

Total

19

Last Release

2758d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e5407caa213f6975f2d554a7a9d62a443c96b3c7b854fb71622479017ee227b?d=identicon)[onmotion](/maintainers/onmotion)

---

Top Contributors

[![onmotion](https://avatars.githubusercontent.com/u/12899080?v=4)](https://github.com/onmotion "onmotion (9 commits)")[![margori](https://avatars.githubusercontent.com/u/1149126?v=4)](https://github.com/margori "margori (3 commits)")[![drtsb](https://avatars.githubusercontent.com/u/11088965?v=4)](https://github.com/drtsb "drtsb (2 commits)")

---

Tags

hacktoberfestsupport-chattelegram-botyii2yii2-extensionyii2-modulesyii2-telegramyii2extensionmodulebotchattelegram

### Embed Badge

![Health badge](/badges/onmotion-yii2-telegram/health.svg)

```
[![Health](https://phpackages.com/badges/onmotion-yii2-telegram/health.svg)](https://phpackages.com/packages/onmotion-yii2-telegram)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
