What Is a Plugin?

We want grammY to be concise and minimal, but extensible. Why? Because not everyone uses everything! Plugins are designed as extra functionalities added to said pieces of software.

Plugins in grammY

Some plugins are right built-in into the grammY core library because we assume that many bots need them. This makes it easier for new users to use them, without having to install a new package first.

Most plugins are published alongside the core package of grammY, we call them official plugins. They are installed from @grammyjs/* on npm, and they are published under the @grammyjsopen in new window organization on GitHub. We coordinate their releases with the releases of grammY, and we make sure that everything works well together. Every section of the plugin docs for an official plugin has the package name in its title. As an example, the grammY runner plugin (runner) needs to be installed via npm install @grammyjs/runner. (If you are using Deno and not Node.js, you should import the plugin from https://deno.land/x/open in new window instead, so from the grammy_runner module’s mod.ts file.)

There are also a few third-party plugins. Anyone can publish them. We don’t provide any guarantees that they are up to date, well-documented, or work together with other plugins. If you want, your own third-party plugin can also be listed on the website so that more people can find out about it.

Overview

We compiled a neat overview for you with short descriptions for each plugin. Installing plugins is fun and easy, and we want you to know what we have in store for you.

Click on any package name to learn more about the respective plugin.

PluginPackageDescription
Sessionsbuilt-inStore user data in your database
Inline and Custom Keyboardsbuilt-inSimplifies building inline and custom keyboards
Auto-retryauto-retryAutomatically handle rate limiting
ConversationsconversationsBuild powerful conversational interfaces and dialogs
EmojiemojiSimplify using emoji in code
FilesfilesEasy file handling
HydrationhydrateCall methods on objects returned from API calls
Internationalizationi18n or fluentLet your bot speak multiple languages
Interactive MenusmenuDesign dynamic button menus with flexible navigation
Parse Modeparse-modeSimplify message formatting
Rate LimiterratelimiterAutomatically restrict users who spam your bot
RouterrouterRoute messages to different parts of your code
RunnerrunnerLong polling concurrently at scale
Stateless Questionstateless-questionCreate dialogs without a data storage
Flood Controltransformer-throttlerAutomatically queue API calls to prevent flood wait

We also have some third-party plugins! You can find them in the navigation menu under Plugins > Third-Party. Be sure to check them out, too!

Types of Plugins in grammY

All that glitters is gold, right? Well, a different kind of gold! grammY can take advantage of two types of plugins: middleware plugins and transformer plugins. In simple terms, plugins in grammY return either a middleware function or a transformer one. Let’s talk about the differences.

Type I: Middleware Plugins

Middleware is a function that handles incoming data in various forms. Middleware plugins are plugins that are fed to a bot as—well, you guessed it—middleware. This means that you install them via bot.use.

Type II: Transformer Plugins

A transformer function is the opposite of middleware! It is a function that handles outgoing data. Transformer plugins are plugins that are fed to a bot as a—crazy! guessed it again—transformer function. This means that you install them via bot.api.config.use.

Create Your Own Plugins

If you want to develop a plugin and share it with other users (even published on the official website of grammY), there is a useful guide that you can check out.

Ideas for More Plugins

We are collecting ideas for new plugins on GitHub in this issueopen in new window.