PHPackages                             idct/php-telegram-sender - 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. idct/php-telegram-sender

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

idct/php-telegram-sender
========================

Simple PHP library which simplifies the task of sending bot messages using Telegram IM

1.0.0(6y ago)12.0k1[1 PRs](https://github.com/bpacholek/php-telegram-sender/pulls)MITPHPPHP ^7.1CI failing

Since Jan 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bpacholek/php-telegram-sender)[ Packagist](https://packagist.org/packages/idct/php-telegram-sender)[ RSS](/packages/idct-php-telegram-sender/feed)WikiDiscussions master Synced 1w ago

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

PHP Telegram Sender
===================

[](#php-telegram-sender)

Simple PHP library which simplifies the task of sending bot messages using Telegram IM.

[![Tests status](https://github.com/ideaconnect/php-telegram-sender/workflows/All%20tests%20using%20PHPUnit/badge.svg)](https://github.com/ideaconnect/php-telegram-sender/workflows/All%20tests%20using%20PHPUnit/badge.svg) [![Coverage Status](https://camo.githubusercontent.com/648996ddee2902a9a63b731edad9fbb84c3a85e11d92ecec44e97e8f20d9ad11/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f69646561636f6e6e6563742f7068702d74656c656772616d2d73656e6465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/ideaconnect/php-telegram-sender?branch=master) [![GitHub tag (latest SemVer)](https://camo.githubusercontent.com/a1208daf9038521e117344e6c0a70e49cca649c684fd7044096b791d82535cee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f69646561636f6e6e6563742f7068702d74656c656772616d2d73656e6465723f6c6162656c3d6c617465737425323076657273696f6e26736f72743d73656d766572)](https://camo.githubusercontent.com/a1208daf9038521e117344e6c0a70e49cca649c684fd7044096b791d82535cee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f69646561636f6e6e6563742f7068702d74656c656772616d2d73656e6465723f6c6162656c3d6c617465737425323076657273696f6e26736f72743d73656d766572)

Installation
------------

[](#installation)

The best way to install the library in your project is by using **Composer**:

```
composer require idct/php-telegram-sender
```

of course you can still manually include all the required files in your project using `using` statements yet **Composer** and autoloading is more than suggested.

Usage
-----

[](#usage)

Actions are handled via static methods as it is meant to be as simple as possible and at the moment there is no real benfit from instances of the main class.

To use it first add somewhere the `use` statement:

```
use IDCT\TelegramSender\TelegramSender;
```

Then you have few methods available:

- to check if a bot is valid by its bot id:

```
TelegramSender::checkIfBotIsValid(123123123);
```

where 123123123 is bot's id.

Returns `true` or `false` depending on the fact if bot id is valid.

- you can retrieve basic bot's information using:

```
TelegramSender::retrieveBotInfo(123123123);
```

where 123123123 is bot's id.

Returns an instance of `BotInfo`.

- the main method of the library is `sendMessage`:

```
TelegramSender::sendMessage(Bot $bot, Channel $channel, string $message, ParseMode $parseMode = null, bool $disableWebPagePreview = false, bool $disableAudioNotification = false, int $threadId = null);
```

Messages support **HTML** and **Markdown** depending on the `$parseMode` arguemnt's value.

`$channel` must be an instance of `PublicChannel` or `PrivateChannel`.

Example:

```
TelegramSender::sendMessage(
    new Bot(123123123, 'AAFKeyoJC6wHmHW85TfUktEMc2x5iz9melE'),
    new PrivateChannel(90808012),
    'my message'
);
```

Values for the `Bot` and `Channel` constructors can be obtained from the Telegram app: check descriptions below.

Method returns an array of elements listed here:

**TODO**: Message entity in the library.

How to create a new bot?
------------------------

[](#how-to-create-a-new-bot)

1. Contact `BotFather` user on Telegram

[![BotFather](https://camo.githubusercontent.com/b5ff091e8d81064aac7065c445ea7abb6df375eb550afab6018746af46ba113e/68747470733a2f2f696463742e706c2f7368617265642f74656c656772616d2d73656e6465722f626f74312e706e67)](https://camo.githubusercontent.com/b5ff091e8d81064aac7065c445ea7abb6df375eb550afab6018746af46ba113e/68747470733a2f2f696463742e706c2f7368617265642f74656c656772616d2d73656e6465722f626f74312e706e67)

2. Type `/newbot` to the `BotFather` and answer all the asked questions.

[![New bot](https://camo.githubusercontent.com/a11246c9de7991684c2d195f9aee9688c38c964f115c4f8a182c45eabd0d42d9/68747470733a2f2f696463742e706c2f7368617265642f74656c656772616d2d73656e6465722f626f74322e706e67)](https://camo.githubusercontent.com/a11246c9de7991684c2d195f9aee9688c38c964f115c4f8a182c45eabd0d42d9/68747470733a2f2f696463742e706c2f7368617265642f74656c656772616d2d73656e6465722f626f74322e706e67)

3. The part which looks like **635092640:AAGfG72lFg0L\_Uf8Cfhb5wBi4UFTm7R2lDY** are your bot's id and key. The part before `:` is the id and the part after is the key. So for the example above it would be:

`id: 635092640``key: AAGfG72lFg0L_Uf8Cfhb5wBi4UFTm7R2lDY`

so you would create an instance of the bot as follows:

```
$bot = new Bot(635092640, 'AAGfG72lFg0L_Uf8Cfhb5wBi4UFTm7R2lDY');
```

Where to get the channel's id from?
-----------------------------------

[](#where-to-get-the-channels-id-from)

1. Create a channel using your Telegram client (`New channel` option in the hamburger menu on the left usually).
2. Add your bot as the admin of the channel.
3. Open `https://web.telegram.org/` and sign in using your account.
4. Click on the desired channel. The url in your browser will change.
5. If the url changes to: `https://web.telegram.org/#/im?p=c1282543751_17534450962567305630` then `1282543751` is your channel's id. So basically the part between `c` and `_` after `?` (in the query string).
6. Use it to create `PrivateChannel` or `PublicChannel` instance depending on the visibility of your channel.

...I know it is quite complicated, but at the moment Telegram's API does not expose any method to get bot's channels.

Contribution
------------

[](#contribution)

In order to contribute open a Pull Request or an Issue. At the moment there are two major points where contribution is more than welcome: support for additional methods of Telegram's API and better unit tests. Handling of the responses: like creating an entity class for the response would be very useful too.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

Unknown

Total

1

Last Release

2325d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b76a5fac115d24d698d09cc939a6922bf309732ae61d0f2f215ae9e7397658ea?d=identicon)[ideaconnect](/maintainers/ideaconnect)

---

Top Contributors

[![bpacholek](https://avatars.githubusercontent.com/u/3039162?v=4)](https://github.com/bpacholek "bpacholek (1 commits)")[![gaka2](https://avatars.githubusercontent.com/u/4929074?v=4)](https://github.com/gaka2 "gaka2 (1 commits)")

---

Tags

phptelegraminstant messagetelegramim

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/idct-php-telegram-sender/health.svg)

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

PHPackages © 2026

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