yii2-telegram-support-bot Support chat for site based on Telegram bot

  1. Requirements
  2. Usage
  3. Installation

The Bot logic based on 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!

The links of this extension

Github: https://github.com/onmotion/yii2-telegram
Packagist: https://packagist.org/packages/onmotion/yii2-telegram

Requirements

Yii 2.0 or above

Usage

Installation

The preferred way to install this extension is through composer.

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!
        'PASSPHRASE' => 'passphrase for login'
    ]
    //more...
 ]
 

and to console config:

 'bootstrap' => [   
 //other bootstrap components...
                'telegram'],
 'modules' => [
         //...
     'telegram' => [
         'class' => 'onmotion\telegram\Module',
         'API_KEY' => 'forexample241875489:AdfgdfFuVJdsKa1cycuxra36g4dfgt66',
         'BOT_NAME' => 'YourBotName_bot',
     ]
 ],       

run migrations:

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

go to

https://yourhost.com/telegram/default/set-webhook

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

if you click it:

client chat

and server side:

client chat

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
0 0
2 followers
0 downloads
Yii Version: 2.0
License: MIT
Category: Others
Developed by: onmotion
Created on: Aug 22, 2016
Last updated: 4 years ago

Related Extensions