Fluently interaction with Telegram Bots in Laravel
Not a long time ago (Feb. 25th), Fabio Ivona announced the release of a package called "Telegraph" whis is "a Laravel package for fluently interaction with Telegram Bots". The package looks really interesting because it simplifies the process of working with Telegram's API.
It's as easy as:
Just relased a new @laravelphp package:— Fabio Ivona (@FabioIvona) February 25, 2022
Telegraph, a fluent tool to handle @telegram Bots as easy as:
it supports sending messages, button keyboards, command and callback query handling, and much more! pic.twitter.com/pBUYgBndvP
Registering a bot with Telegraph
The process of creating a new both is pretty straightforward. The package supports two ways:
Running an artisan command:
1php artisan telegraph:new-bot
After running this command, you'll be directed through a bot creation process, which will allow you to establish a new conversation and set up a bot webhook.
The second way in wich you can create a new bot is by using the TelegraphBot model to generate the new bot and that's useful if you're implementing custom logic:
1$bot = TelegraphBot::create([2 'token' => $token,3 'name' => $name,4]);
I'm planing to create a Telegram channel for Laravel Magazine and I will play with this package more and I intend to maybe come up with either a video or a tutorial how to work with Telegraph in a Laravel application.
I reccomend checking out Telegraph's documentation and the Github Repo for more useful informations and an installation guide.
PHP / Laravel Developer. Writing and maintaining @LaravelMagazine. Host of "The Laravel Magazine Podcast". Pronouns: vi/vim.