PHPackages                             dannsbass/bots - 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. dannsbass/bots

ActiveLibrary[API Development](/categories/api)

dannsbass/bots
==============

Simple Telegram Bot API library for PHP

v0.0.3(2y ago)0311MITPHP

Since Oct 25Pushed 2y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Bots
====

[](#bots)

Simple Telegram Bot API library for PHP

Quick Start
-----------

[](#quick-start)

Initiate with `setToken` and end with `run` method.

### Sample 1: Start

[](#sample-1-start)

```
require 'Bot.php';

Bot::setToken(BOT_TOKEN, BOT_USERNAME); //init (required)
Bot::start('Welcome, I am a bot.'); //event
Bot::run(); //launch (required)
```

[![](https://github.com/dannsbass/dannsbass.github.io/raw/master/assets/img/bot-start.png)](https://github.com/dannsbass/dannsbass.github.io/blob/master/assets/img/bot-start.png)

### Sample 2: Keyboard

[](#sample-2-keyboard)

```
Bot::chat('/help', function(){
    $keyboard = Bot::keyboard('
    [/info] [/admin]
    [/help]
    ');
    $options = ['reply_markup' => $keyboard];
    return Bot::sendMessage("List of Commands:", $options);
});
```

[![](https://github.com/dannsbass/dannsbass.github.io/raw/master/assets/img/keyboard.png)](https://github.com/dannsbass/dannsbass.github.io/blob/master/assets/img/keyboard.png)

### Sample 3: Inline Keyboard

[](#sample-3-inline-keyboard)

```
Bot::chat('/inline_keyboard', function(){
    $inline_keyboard = Bot::inline_keyboard('
    [Google|https://www.google.com] [Facebook|https://www.facebook.com]
    [More|more_data]
    ');
    $options = ['reply_markup' => $inline_keyboard];
    return Bot::sendMessage("Options:", $options);
});
```

[![](https://github.com/dannsbass/dannsbass.github.io/raw/master/assets/img/inline_keyboard.png)](https://github.com/dannsbass/dannsbass.github.io/blob/master/assets/img/inline_keyboard.png)

### Sample 4: Sending Document

[](#sample-4-sending-document)

```
Bot::chat('/send', function($file){
    if (file_exists($file)) return Bot::sendDocument($file);
    return Bot::sendMessage("$file not exists");
});
```

[![](https://github.com/dannsbass/dannsbass.github.io/raw/master/assets/img/send-document.png)](https://github.com/dannsbass/dannsbass.github.io/blob/master/assets/img/send-document.png)

### Sample 5: Chat Array

[](#sample-5-chat-array)

```
$help = function(){
    return Bot::sendMessage("This is bold and italic text.", ['parse_mode' => 'html']);
};

$info = function() {
    Bot::sendChatAction('typing');
    Bot::sendDocument('composer.json', ['caption' => 'for composer']);
};

Bot::chat_array([
    '/help' => $help,
    '/info' => $info,
]);
```

[![](https://github.com/dannsbass/dannsbass.github.io/raw/master/assets/img/chat_array.png)](https://github.com/dannsbass/dannsbass.github.io/blob/master/assets/img/chat_array.png)

### Sample 6: Regex

[](#sample-6-regex)

```
Bot::regex('/^\/start (\d+)$/', function($m){
    return Bot::sendMessage($m[1]);
});

Bot::start(function(){
    return Bot::sendMessage('Press button bellow:',
        [
            'reply_markup' => Bot::inline_keyboard('
                [BUTTON|https://t.me/Testing58384bot?start=1234567890]
            ')
        ]
    );
});
```

[![](https://github.com/dannsbass/dannsbass.github.io/raw/master/assets/img/regex1.png)](https://github.com/dannsbass/dannsbass.github.io/blob/master/assets/img/regex1.png)

[![](https://github.com/dannsbass/dannsbass.github.io/raw/master/assets/img/regex2.png)](https://github.com/dannsbass/dannsbass.github.io/blob/master/assets/img/regex2.png)

Documentation
-------------

[](#documentation)

Note that all properties and methods are static. For example: `Bot::$property` or `Bot::method()`.

### Bot Properties

[](#bot-properties)

PropertyTypeDescriptiontokenstringbot token from @BotFathernamestringbot name from @BotFatherurlstringtelegram URL for endpointgetUpdatesarrayparsed-JSON from Telegram serverinputObjectobjectdecoded-JSON from Telegram server\_commandarraylist of commands and responses\_onMessagearraylist of events (types) and the responsesversionintegerapp versionmessage\_idstringmessage IDmessage\_textstringmessage textuserstringfirst name (and last name)from\_idintegerfrom IDchat\_idintegerfrom IDadmin\_idintegeradmin ID### Bot Methods

[](#bot-methods)

MethodParameter(s)DescriptionsetToken`string` bot token, `string` bot namesetAdmin`integer` admin IDisAdminto check if user is adminnameto get bot namechat`string` command, `string or callable` responseto set command and its responsecmd`string` command, `string or callable` responseto set command and its responsechat\_array`associative array` list of command (key) and its response (value)to set command and its responsekeyboard`string` keyboard pattern, `string` input\_field\_placeholder = 'type here', `boolean` resize\_keyboard = true, `boolean` one\_time\_keyboard = trueto create keyboard(s) from stringinline\_keyboard`string` keyboard patternto create inline keyboard(s) from stringmessage\_idto get message idmessage\_textto get message textuserto get user first name (and last name)from\_idto get user IDchat\_idto get chat IDon`string` type, `string or callable` responseto set responseregex`string` pattern, `string or callable` responseto set responserunto run the botsend`string` method, `associative array` datato send request to Telegram serveranswerInlineQueryresult, `array` options = \[\]to answer Inline QueryanswerCallbackQuerytext, `array` options = \[\]to answer Callback Querymessageto get body of message JSON from usertypeto get type of message`__callStatic``string` method, `array` parametersto call any methodprosesPesan`string` teks, `array` data = nullto send a long messagebg\_exec`string` function name, `array` parameters, `string` PHP script to be loaded first, `integer` timeout = 1000to call function in background### Telegram Events

[](#telegram-events)

Note that event parameters up to 2 parameters. For example: `Bot::start($param1, $param2)`.

- `all` (when user sends anything, it's similar with `on('*', $response)` method)
- `start` (when user sends `/start` text message or presses `START` button)
- `text` (see: [docs](https://core.telegram.org/bots/api#message))
- `animation`
- `audio`
- `document`
- `photo`
- `sticker`
- `video`
- `video_note`
- `voice`
- `contact`
- `dice`
- `game`
- `poll`
- `venue`
- `location`
- `message_auto_delete_timer_changed`
- `pinned_message`
- `invoice`
- `successful_payment`
- `user_shared`
- `chat_shared`
- `write_access_allowed`
- `passport_data`
- `proximity_alert_triggered`
- `forum_topic_created`
- `forum_topic_edited`
- `forum_topic_closed`
- `forum_topic_reopened`
- `general_forum_topic_hidden`
- `general_forum_topic_unhidden`
- `voice_chat_scheduled`
- `voice_chat_started`
- `voice_chat_ended`
- `voice_chat_participants_invited`
- `inline_query`
- `callback_query`
- `edited_message`
- `channel_post`
- `edited_channel_post`

### Telegram Methods

[](#telegram-methods)

All Telegram methods are compatible with this bot. For example:

```
echo Bot::getMe();
echo Bot::setWebhook(WEBHOOK_URL);
echo Bot::getWebhookInfo();
echo Bot::deleteWebhook(true); //default is `false` for `drop_pending_updates`, see: https://core.telegram.org/bots/api#deletewebhook
```

See more:

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

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

Total

3

Last Release

857d ago

### Community

Maintainers

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

---

Top Contributors

[![dannsbass](https://avatars.githubusercontent.com/u/12822582?v=4)](https://github.com/dannsbass "dannsbass (45 commits)")

---

Tags

telegramtelegram bottelegram bot apiTelegram bot library

### Embed Badge

![Health badge](/badges/dannsbass-bots/health.svg)

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

###  Alternatives

[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[telegram-bot-sdk/telegram-bot-sdk

The Telegram Bot API PHP SDK

32480.5k](/packages/telegram-bot-sdk-telegram-bot-sdk)[tg-bot-api/bot-api-base

Clear and simple Telegram bot API

22278.8k2](/packages/tg-bot-api-bot-api-base)[luzrain/telegram-bot-bundle

Symfony bundle for Telegram Bot API

1228.1k](/packages/luzrain-telegram-bot-bundle)[luzrain/telegram-bot-api

PHP Wrapper for Telegram Bot API

1032.8k1](/packages/luzrain-telegram-bot-api)

PHPackages © 2026

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