Skip to main content

3 posts tagged with "nutgram"

View All Tags

ยท 4 min read

A Love Story Between PHP and Telegram Bots

Sometimes the best projects aren't born from grand visions or marketing strategies - they come from scratching your own itch. That's exactly how Nutgram came to life: two developers, real problems, and a shared frustration with existing tools.

Where It All Startedโ€‹

About six years ago, Luca got a simple request in a Telegram group: "Hey, can you rebuild this file conversion bot that just died?"

He built New File Converter Bot using TelegramBotPHP. But after a few weeks, the cracks started showing. Everything was arrays - no IDE autocompletion, no type safety, just implicit structures everywhere.

His solution was drastic: fork the whole thing into telegrambot-php and convert everything to proper objects. He manually created over 200 classes to implement DTOs. Tedious? Absolutely. Worth it? Hell yes.

Meanwhile, I was on my own parallel journey.

AnonyMeetBot v1: The BotMan Eraโ€‹

I had built AnonyMeetBot v1 using BotMan as an experiment to connect two platforms together: Facebook and Telegram. BotMan seemed like the perfect choice for multi-platform support.

But then Facebook tightened their API requirements and the Facebook support had to be dropped. AnonyMeetBot became Telegram-only, and suddenly BotMan's multi-platform approach felt like overkill. The Telegram implementation was incomplete and didn't really leverage Telegram's unique features.

As the bot grew and gained users, the problems became clear. Being an experimental project, v1 had its share of performance issues. But the real limitation was BotMan itself - too bulky, too generic, and not built to take advantage of what Telegram actually offers. I needed proper middleware, better code organization, and a framework actually built for Telegram.

I also looked at Zanzara, which was laser-focused on Telegram, but it got abandoned shortly after I found it.

Building Nutgramโ€‹

At some point you just have to build the tool yourself. I started working on AnonyMeetBot v2 from scratch, and with it, a new framework. I took everything I'd learned from BotMan and Zanzara and started designing something better.

The goal was simple: create something 100% Telegram-first, with modern developer experience and no compromises. A framework that understood conversation flows, made middleware feel natural, and gave proper structure without being too opinionated.

Once I had a working v1 of Nutgram, I deployed AnonyMeetBot v2. The improvements were obvious - cleaner architecture, better performance, and actually using Telegram's features properly.

Two Paths Convergeโ€‹

Around that time, Luca was facing similar issues. His bots were running on telegrambot-php, but he was hitting the same architectural walls. When he discovered Nutgram, he started rewriting his old bots with it.

And then something great happened: he didn't just use it, he started contributing. A lot. He brought fresh perspectives and pushed the framework forward with significant improvements.

We moved the repo into its own organization, and five years ago, Nutgram was officially born.

Why It Mattersโ€‹

Nutgram wasn't designed in a conference room. It was built because we couldn't find a good framework that provided high-level features for Telegram. Everything we tried was either too limited, too generic for multi-platform support, or abandoned.

We needed conversation management that actually worked, proper middleware, flexible handlers, and full support for Telegram's features. So we built it.

That's really all there is to it. Nutgram exists because we were frustrated with the available options and decided to make something better. Five years later, it's still solving the same problems for developers who want to build serious Telegram bots without fighting their framework.


Want to build your next Telegram bot with Nutgram? Check out the official website and see what a Telegram-first framework feels like.

ยท 2 min read

We are thrilled to unveil Nutgram 4.x, an exciting update packed with new features and improvements to enhance your Telegram bot development experience. Here's a closer look at the key changes:

PHP 8.2โ€‹

To ensure a smooth transition, make sure to update your dependencies as now is required PHP 8.2.0 or greater. This higher requirement unlocks new capabilities and improvements, so be sure to prepare your environment accordingly.

Endpoint Signatureโ€‹

One of the significant changes in 4.x is the conversion of all endpoint signatures from an array to named parameters. This update enables the convenient utilization of named parameters and improves parameter sorting. Mandatory parameters now come first, followed by optional ones, while the $clientOpt parameter, if present, will always be placed at the end.

For example, previously, you might have used:

$bot->sendMessage('my text', [
'disable_notification' => true
]);

In 4.x, has to be changed to:

$bot->sendMessage('my text',
disable_notification: true
);

->group Methodโ€‹

The group method has undergone modifications in its usage. Previously, it accepted the middleware as a parameter, but now the middleware is set using the middleware method. Update your code to reflect this change:

$bot->group(function (Nutgram $bot){
// Your handlers here
})->middleware(Middleware::class);

Enumsโ€‹

In 4.x, we have converted Attributes (Class with constants) to Enums. If you were directly using the value before, you will now need to use ->value to obtain the raw value. This change has a medium impact and should be addressed during the upgrade.

Laravel Support Moved to a Separate Packageโ€‹

With the latest update, we have separated the Laravel support into a new package called nutgram/laravel. You have to install this package using Composer:

composer require nutgram/laravel

To streamline the integration process, the previous package, nutgram/nutgram, is now included within nutgram/laravel. Once you have nutgram/laravel installed, you can safely remove nutgram/nutgram as it is already incorporated.

These high-impact changes require your attention to ensure a seamless transition to 4.x. Be sure to update your code accordingly to take full advantage of the new features and improvements.

We encourage you to explore the complete upgrade guide and review the changes in the repository on GitHub. Upgrade now and elevate your Telegram bot development to new heights. Happy coding!

ยท One min read

We are excited to announce that a new bundle is now available for developers using Symfony with Nutgram! ๐Ÿฅณ The bundle provides seamless integration with Symfony and unlocks new features and functionality for developers to create even more powerful and customizable bots. We believe this addition will enhance the development experience for our community and look forward to seeing what our users will create with this new tool.

Check out the new documentation page ๐Ÿ—„