March 6th, 2022

telegraph.png

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:

1Telegraph::message('hello')->send();

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.

fathom analytics Follow @LaravelMagazine on Twitter →

Comments

Marian Pop

PHP / Laravel Developer. Writing and maintaining @LaravelMagazine. Host of "The Laravel Magazine Podcast". Pronouns: vi/vim.

Newsletter

Get latest news, tutorials, community articles and podcast episodes delivered to your inbox every Friday!

We'll never share your email address and you can opt out at any time.