Registering a bot with Telegraph
Any number of bots can be created, both programmatically and through an artisan command
through artisan command
You can add a new bot issuing the dedicated artisan command:
php artisan telegraph:new-bot
you will be guided through a bot creation wizard that will (optionally) allow you to add a new chat and setup a bot webhook as well
For an end-to-end setup with installation, BotFather token, webhook, and a test, see Build your first Telegram bot with Telegraph.
programmatically
If you are implementing a custom bot creation logic, you can create a new bot using the TelegraphBot model:
First, store the bot token in your application environment:
TELEGRAM_BOT_TOKEN=123456:replace-with-your-bot-token
Then expose it from config/services.php:
'telegram' => [ 'bot_token' => env('TELEGRAM_BOT_TOKEN'), ],
use DefStudio\Telegraph\Models\TelegraphBot; $bot = TelegraphBot::create([ 'token' => config('services.telegram.bot_token'), 'name' => 'Support Bot', ]);