Skip to content

Configuration

Configure TeleBot for your PHP projects with these essential settings.

TIP

Default configuration works for most use cases. Customize only when needed.

Basic Setup

Single Bot Configuration

php
use WeStacks\TeleBot\TeleBot;

$bot = new TeleBot([
    'token' => 'YOUR_BOT_TOKEN', // Required
    'name' => 'MyBot'
]);

Multiple Bot Management

php
use WeStacks\TeleBot\BotManager;

$bot = new BotManager([
    'primary' => new TeleBot('YOUR_BOT1_TOKEN'),
    'secondary' => [ // Auto-instantiated
        'token' => 'YOUR_BOT2_TOKEN',
        'name' => 'MyBot2'
    ]
]);

$bot->getMe(); // Uses primary bot (first bot)
$bot->bot('secondary')->getMe(); // Uses secondary bot

You may also specify a default bot explicitly:

php
$bot = new BotManager([
    'primary' => new TeleBot('YOUR_BOT1_TOKEN'),
    'secondary' => ['token' => 'YOUR_BOT2_TOKEN', 'name' => 'MyBot2'],
], 'secondary');

$bot->getMe(); // Uses secondary bot (now the default)

Core Parameters

Bot Configuration

ParameterTypeRequiredDefaultDescription
tokenstring✔️---Telegram bot token
namestringnullBot username for command parsing
api_urlstringTelegram API URLCustom API endpoint
httparray[]Custom Guzzle HTTP client options for API requests
kernelstring|arrayKernel::classKernel for update handling or array of handlers
storagestringFileStorage::classStorage driver for user states

Manager Configuration

The BotManager constructor takes two arguments:

ParameterTypeDefaultDescription
$botsarray[]Array of bot configs keyed by name
$defaultstring|int|nullnullDefault bot name (first bot if unset)