PHPackages                             justify/telegram-bot-api - 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. justify/telegram-bot-api

AbandonedLibrary[API Development](/categories/api)

justify/telegram-bot-api
========================

Simple library for working with Telegram bot API

v1.1.0(7y ago)091MITPHPPHP &gt;= 5.6.0

Since Nov 17Pushed 7y agoCompare

[ Source](https://github.com/Cannon431/telegram-bot-api)[ Packagist](https://packagist.org/packages/justify/telegram-bot-api)[ RSS](/packages/justify-telegram-bot-api/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (0)

Simple library for working with Telegram bot API
================================================

[](#simple-library-for-working-with-telegram-bot-api)

Instalation
-----------

[](#instalation)

```
composer require justify/telegram-bot-api
```

Usage
-----

[](#usage)

### Creating client instance:

[](#creating-client-instance)

```
define('TELEGRAM_TOKEN', 'Your token');

$bot = new Justify\TelegramBotApi\Client(TELEGRAM_TOKEN);
```

### Sending requests

[](#sending-requests)

You can send requests uses harvested methods:

```
$bot->sendMessage($chatId, 'Hello!');
$bot->sendPhoto($chatId, 'File id || URL || path to file', [
    'caption' => 'My photo'
]);
```

Almost all API methods takes thirst argument **chat id** and last **optional params**

---

If you are missing inbuilt methods you can send requsest via `sendRequest` method:

```
$response = $bot->sendRequest('getFile', [
    'file_id' => $fileId
]);
```

### Handling requests

[](#handling-requests)

You can handling requests using `Justify\TelegramBotApi\Client` methods:

```
$bot->handler(function ($message) use ($bot) {
    // Actions ...
});
```

You can set conditions for handler:

```
// Will react on "start" command
$bot->command('start', function ($message) use ($bot) {
    // Actions ...
});

// Will react on "Some text" text
$bot->text('Some text', function ($message) use ($bot) {
    // Actions ...
});

// Will react if text messages will match to regexp pattern
$bot->regexp('Password (\d+)', function ($message, $matches) use ($bot) {
    // Actions ...
});

// Will react if message will have "photo" type
$bot->type('photo', function ($message) use ($bot) {
    // Actions ...
});
$
```

---

### Sending some media:

[](#sending-some-media)

```
$bot->sendPhoto($chatId, 'Pass file id or file url or path to file');
```

### Sending media group:

[](#sending-media-group)

```
$photo = new Justify\TelegramBotApi\Types\InputMediaPhoto('Pass file id or file url or path to file', [
    'caption' => 'My photo'
]);
$video = new Justify\TelegramBotApi\Types\InputMediaVideo('Pass file id or file url or path to file', [
    'caption' => 'My video'
]);

$bot->sendMediaGroup($chatId, [$photo, $video]);
```

### Sending keyboards:

[](#sending-keyboards)

```
$keyboard = new Justify\TelegramBotApi\Types\ReplyKeyboardMarkup([
    'resize_keyboard' => true,
    'ont_time_keyboard' => true
]);

$keyboard->row('1', '2', '3')
    ->row('4', '5', '6')
    ->row('7', '8', '9')
    ->row('0');

$bot->sendMessage($chatId, 'Choose a number', ['reply_markup' => $keyboard]);

// Removing keyboard
$removeKeyboard = new Justify\TelegramBotApi\Types\ReplyKeyboardRemove();
$bot->sendMessage($chatId, 'Removing keyboard', ['reply_markup' => $removeKeyboard]);
```

### Running application:

[](#running-application)

```
$bot->polling();
```

### Usage example:

[](#usage-example)

```
require_once __DIR__ . '/vendor/autoload.php';

define('TELEGRAM_TOKEN', 'Pass your token here');

$bot = new Justify\TelegramBotApi\Client(TELEGRAM_TOKEN);

$bot->command('start', function ($message) use ($bot) {
    $keyboard = new Justify\TelegramBotApi\Types\ReplyKeyboardMarkup([
        'resize_keyboard' => true
    ]);
    $keyboard->row('Photo', 'Audio')
        ->row('Document', 'Video')
        ->row('/stop');

    $bot->sendMessage($message->chat->id, 'Welcome!', ['reply_markup' => $keyboard]);
});

$bot->command('stop', function ($message) use ($bot) {
    $bot->sendMessage($message->chat->id, 'Completed', [
        'reply_markup' => new Justify\TelegramBotApi\Types\ReplyKeyboardRemove()
    ]);
});

$bot->text('Photo', function ($message) use ($bot) {
    $bot->sendPhoto($message->chat->id, 'File id || URL || path to file');
});

$bot->text('Audio', function ($message) use ($bot) {
    $bot->sendAudio($message->chat->id, 'File id || URL || path to file');
});

$bot->text('Document', function ($message) use ($bot) {
    $bot->sendDocument($message->chat->id, 'File id || URL || path to file');
});

$bot->text('Video', function ($message) use ($bot) {
    $bot->sendVideo($message->chat->id, 'File id || URL || path to file');
});

try {
    $bot->polling();
} catch (Justify\TelegramBotApi\Exception $e) {
    echo $e->getMessage();
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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 ~113 days

Total

2

Last Release

2622d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87ed5e8a16970b1c0a15bfbec154ac4abc43ffa2bd005123c24a23fb24837c90?d=identicon)[Elaxer](/maintainers/Elaxer)

---

Top Contributors

[![elaxer](https://avatars.githubusercontent.com/u/29579045?v=4)](https://github.com/elaxer "elaxer (6 commits)")

---

Tags

apibottelegram

### Embed Badge

![Health badge](/badges/justify-telegram-bot-api/health.svg)

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

###  Alternatives

[longman/telegram-bot

PHP Telegram bot

4.0k2.1M50](/packages/longman-telegram-bot)[zelenin/telegram-bot-api

Telegram Bot API Client

5917.2k](/packages/zelenin-telegram-bot-api)

PHPackages © 2026

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