PHPackages                             alish/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. [API Development](/categories/api)
4. /
5. alish/telegram

AbandonedArchivedLibrary[API Development](/categories/api)

alish/telegram
==============

a laravel package for telegram bot

1.1.3(8y ago)470MITPHPPHP ^7.0

Since Jan 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pyramid-ali/telegram)[ Packagist](https://packagist.org/packages/alish/telegram)[ RSS](/packages/alish-telegram/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (4)Versions (10)Used By (0)

Laravel Telegram Bot
====================

[](#laravel-telegram-bot)

use this package for working with telegram api bot, this package develped to work well with laravel but with some minor change you can use this with raw php

INSTALLATION
------------

[](#installation)

```
composer require alish/telegram

```

### Additional Setup for Laravel 5 to 5.4

[](#additional-setup-for-laravel-5-to-54)

you need to add service provider and facade manually to config/app.php

```
'providers' => [
    //
    Alish\Telegram\TelegramServiceProvider::class

 ],

 'aliases' => [
    //
    'Telegram' => Alish\Telegram\Facades\Telegram::class

 ]

```

**for laravel 5.5 and above you don't need do this**

### Config file

[](#config-file)

publish config file

```
  php artisan vendor:publish --provider="Alish\Telegram\TelegramServiceProvider"

```

then you see config file in config/telegram.php

config file is like below

```
'defaults' => [
            'token_bot' => '',
            'webhook' => '',
        ],

        'commands' => [
            'active' => false,
            'list' => [
                'start' => 'App\Class'
            ]
        ],

        'handlers' => [
            'CallbackQuery'      => null,
            'ChannelPost'        => null,
            'ChosenInlineResult' => null,
            'EditedChannelPost'  => null,
            'EditedMessage'      => null,
            'InlineQuery'        => null,
            'Message'            => null,
            'ShippingQuery'      => null,
            'PreCheckoutQuery'   => null
        ],

        'loaders' => [

        ]

```

#### Defaults

[](#defaults)

fill token\_bot with token you get from [bot father](https://telegram.me/BotFather), and set webhook with your desire url (relative url)

#### Commands

[](#commands)

if you want to handle commands receive from telegram api bot in specific class ypu can declare it here, first set 'active' to true, then in 'list' array list your command with related Class handlers. classes specified in this file should inheret from `Alish\Telegram\TelegramCommand`then put your logic in handler function **Example**

```
use Alish\Telegram\TelegramCommand;
use App\Http\Bot\State;

class StartCommand extends TelegramCommand
{

    public function handler()
    {
        // put your logic here
    }
}

```

you have access to **Message** object with $this-&gt;message ([See Message Class](https://core.telegram.org/bots/api#message)) **NOTE**\*\*\* if you active commands handler then you'll not get message in MessageHandler in your handlers section

### Handlers

[](#handlers)

in this section we splited message type that receieve from telegram to seperate class handlers, then for handle each type you need to declare related class. class have been defined as handlers should inheret from **TelegramUpdateHandler**\_\_Example: \_\_

```
use Alish\Telegram\TelegramUpdateHandler;

class CallbackQueryHandler extends TelegramUpdateHandler
{

    public function handler()
    {
        // put your logic here
    }
}

```

you have access to Update object with $this-&gt;update [See Update Documentation](https://core.telegram.org/bots/api#update)

### Loaders

[](#loaders)

if you want to do some actions before handle message you can define loader classes. this class receive update object recieve from telegram api class have been define as loaders should inheret from **TelegramLoader****Example:**

```
use Alish\Telegram\TelegramLoader;

class StageHandler extends TelegramLoader
{

    public function process()
    {
         // put your logic here
    }
}

```

this loaders don't prevent from your defioned handlers to receive update, then be careful to use these

### Telegram Facade

[](#telegram-facade)

with this facade you can do all actions defined in telegram api bot (See Available Methods)\[\]

#### How to use this

[](#how-to-use-this)

you only need to use same methods in telegram api **Example:**

```
  // sending Message:
  // you must provide required filed, optional field is still optional
  Telegram::sendMessage(['chat_id' => 'user chat id', 'text' => 'Welcome to my bot']);

  // forward message
  Telegram::forwardMessage(['chat_id' => 'user chat id', 'from_chat_id' => 'from chat id']);

```

because chat\_id is require for all action except 1 or 2, you can use

```
  Telegram::chatId('user chat id')->sendMessage(['text' => 'Welcome to my bot']);

  // instead of
  // Telegram::sendMessage(['chat_id' => 'user chat id', 'text' => 'Welcome to my bot']);

```

### sending buttons

[](#sending-buttons)

for sending buttons you need to json\_encode button arrays **Example**

```

  $buttons = [
    [
      ['text' => 'some text'],
      ['text' => 'some text']
    ],
    [
      ['text' => 'some text']
    ]
  ];

  $replyMarkup = json_encode(['keyboard' => $buttons])

  Telegram::chatId('user chat id')->sendMessage(['text' => 'Welcome to my bot', 'reply_markup' => $replyMarkup]);

```

### sending files

[](#sending-files)

for sending files you need use getFile method from InputFile class **Example:**

```
  use Alish\Telegram\Template\InputFile;

  Telegram::chatId($chatId)->sendVideo(['caption' => $text, 'video' => InputFile::getFile($pathToFile), 'reply_markup' => $buttons, 'reply_to_message_id' => 'message id']);

```

### getUser

[](#getuser)

you can get telegram user in recevied update with below command: to see which information is in user object see (User Object)\[\]

```
  $telegramUser = Telegram::getUser();

```

### How this package works

[](#how-this-package-works)

all telegram object mapped to their classes, this means when an update receive from telegram api it maps to Update class, Update Class Contains:

```

  /**
     * @var integer $update_id
     * The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially.
     * This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order.
     */
    protected $update_id;

    /**
     * @var Message|null $message
     * Optional. New incoming message of any kind — text, photo, sticker, etc.
     */
    protected $message;

    /**
     * @var Message|null $edited_message
     * Optional. New version of a message that is known to the bot and was edited
     */
    protected $edited_message;

    /**
     * @var Message|null $channel_post
     * Optional. New incoming channel post of any kind — text, photo, sticker, etc.
     */
    protected $channel_post;

    /**
     * @var Message $edited_channel_post
     * Optional. New version of a channel post that is known to the bot and was edited
     */
    protected $edited_channel_post;

    /**
     * @var InlineQuery|null $inline_query
     * Optional. New incoming inline query
     */
    protected $inline_query;

    /**
     * @var ChosenInlineResult|null $chosen_inline_result
     * Optional. The result of an inline query that was chosen by a user and sent to their chat partner.
     * Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.
     */
    protected $chosen_inline_result;

    /**
     * @var CallbackQuery|null $callback_query
     * Optional. New incoming callback query
     */
    protected $callback_query;

    /**
     * @var ShippingQuery|null $shipping_query
     * Optional. New incoming shipping query. Only for invoices with flexible price
     */
    protected $shipping_query;

    /**
     * @var PreCheckoutQuery|null $pre_checkout_query
     * Optional. New incoming pre-checkout query. Contains full information about checkout
     */
    protected $pre_checkout_query;

```

you can't access directly to this properties because this should initiate from what receivedd from telegram api, if you want to access to each property use dynamic method with 'get' prefix for example for getting update\_id use getUpdateId() method if you want manipulate received message use set method to change properties, $update-&gt;setUpdateId('whatever');

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

7

Last Release

3087d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/216bcba65e7ebc9c9669dc6629806763ccfbe39b5b40d898e710dbacfcba6faa?d=identicon)[pyramidalish](/maintainers/pyramidalish)

---

Top Contributors

[![ali-shabani](https://avatars.githubusercontent.com/u/12711392?v=4)](https://github.com/ali-shabani "ali-shabani (1 commits)")

---

Tags

laraveltelegramtelegram bot

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M337](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M125](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M123](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M131](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[flat3/lodata

OData v4.01 Producer for Laravel

100351.7k](/packages/flat3-lodata)

PHPackages © 2026

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