Skip to content

Introduction

Telegram Bot Essentials (package name essence, namespace TelegramBotEssentials\Essence) is a Laravel package for building multi-tenant Telegram bots with a structured request-routing architecture. Instead of one giant update handler, incoming webhook updates are dispatched through typed buses: Commands, ReplyKeys, CallbackQueries, and StateAnswers.

It is the core of a small ecosystem of packages, all namespaced under TelegramBotEssentials\* and installed via Composer into a host Laravel application.

Why it exists

Telegram bots built directly on top of an SDK tend to accumulate one of two problems as they grow: a single sprawling switch statement over every possible update shape, or ad-hoc session state stored in whatever column happened to be convenient. Essence fixes both by giving every kind of incoming update (slash command, keyboard button, inline button, freeform text while a flow is active) its own bus and its own class-based handler, and by giving multi-step flows a real state machine (bot_users.state + StateData) instead of scattered flags.

Because each bot is a stancl/tenancy tenant, the same Laravel application can run many independent bots — each with its own admins, users, settings, and billing — without duplicating code per bot.

The Ecosystem

PackageComposer namePurpose
Essence (core)telegram-bot-essentials/essenceWebhook routing, buses, state machine, multi-tenancy, access control
Settingstelegram-bot-essentials/settingsPer-bot key/value settings with typed accessors
Billingtelegram-bot-essentials/billingInvoices, payments, and a gateway abstraction
Gateway: Cardtelegram-bot-essentials/gateway-cardManual card-to-card payment gateway for Billing
Gateway: Zibaltelegram-bot-essentials/gateway-zibalZibal payment gateway integration for Billing
User Managementtelegram-bot-essentials/user-managementAdmin user list, sortable/filterable columns
User Wallettelegram-bot-essentials/user-walletPer-user balance/credit wallet, plugs into User Management as a sort
Affiliatestelegram-bot-essentials/affiliatesReferral tracking and commission payout via the wallet
Announcementstelegram-bot-essentials/announcementsBulk broadcast to bot users with live progress and retraction

Two standalone (non-Telegram) API clients complete the toolkit for bots that resell VPN/proxy services:

PackageComposer namePurpose
Marzban APIelyar/marzban-apiPHP client for the Marzban panel API
Rebecca APIelyar/rebecca-apiPHP client for the Rebecca panel API

All companion packages depend on Essence and register themselves into its buses and event system from their own service providers — see Extending and Events & Listeners.

Where to go next