Interact with Telegram Bots in Laravel with Telegraph

Packages

March 1st, 2022

laravel-telegraph.png

Telegraph is a Laravel package for fluently interacting with Telegram Bots. It provides some key features that make it easier to set up and interact with users via Bots:

  • Create Bots
  • Add Bots to Chats
  • Create new Chats
  • Send Telegram Messages
  • Attach a keyboard to a message
  • Queue messages via Laravel queues
  • Make Telegram API calls
  • Webhooks to receive incoming Telegram messages

Attaching a keyboard to a message gives the user some easy options for responding to a message. For example, buttons to delete a resource or open a URL:

1Telegraph::message('hello world')
2 ->keyboard(Keyboard::make()->buttons([
3 Button::make('Delete')->action('delete')->param('id', '42'),
4 Button::make('open')->url('https://test.it'),
5 ]))->send();

This package provides a few settings that you can configure via the CLI or programmatically to create chats dynamically. For example, once you set up a Telegram bot, you can register programmatically:

1$bot = TelegraphBot::create([
2 'token' => $token,
3 'name' => $name,
4]);

View the Telegraph documentation to get started with this package. You can also view the source code on GitHub, which gives instructions on getting started in the README.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.

Laravel News Partners