Interact with Telegram Bots in Laravel with Telegraph
Published on by Paul Redmond
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:
Telegraph::message('hello world') ->keyboard(Keyboard::make()->buttons([ Button::make('Delete')->action('delete')->param('id', '42'), Button::make('open')->url('https://test.it'), ]))->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:
$bot = TelegraphBot::create([ 'token' => $token, 'name' => $name,]);
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.