westacks/telebot-laravel
A Laravel integration for the Telegram Bot API that simplifies building bots with a fluent interface, webhook and polling support, and framework-friendly configuration for sending messages, handling updates, and managing bot commands in PHP applications.
Architecture fit
TeleBot facade, BotManager for multi-bot registration, publishable config/telebot.php, artisan generators. This lands in the existing Laravel mental model rather than adding a second paradigm.UpdateHandler / CommandHandler / CallbackHandler / RequestInputHandler), with trigger()/handle() and "return a value to stop the pipeline." Familiar to anyone who has written middleware or listeners; the implicit "return null to continue" control flow is the one subtlety.toTelegram + via(['telegram'])) and log driver make Telegram a delivery channel alongside mail/Slack rather than a separate application — this is the highest-leverage fit for typical Laravel products.$update->get('message.from.id')) reduce the array-shape guessing that plagues raw API integrations.Integration feasibility
composer require, php artisan telebot:install, two env vars, one handler. A first working webhook is an hours-not-weeks task.UpdateRequest checks POST/JSON, bot token match, secret token, single update type), command registration, and bot command sync (telebot:commands) are all provided — no glue code to own.Technical risk
westacks/telebot library; adapter version bumps are coupled to upstream bumps./telebot/webhook/{bot}/{token} — the bot token is in the URL path. Secret-token validation exists but is optional in the published config. A token in a path will leak into access logs, proxies, and error trackers.FileStorage — a single-node assumption. Any multi-instance deployment (LB, containers, autoscaling) silently breaks conversation state until a StorageContract implementation on DB/Redis is written.Key questions
update_id delivery?Stack fit
Migration path (three scenarios, materially different costs)
irazasyed/telegram-bot-sdk or BotMan: not lift-and-shift. The handler/dispatch model differs; expect a handler-layer rewrite (~1–2 weeks), plus re-registering the webhook URL. Only worth it if the pipeline + notification channel materially reduce code.Compatibility
Notification classes gain a toTelegram method.ShouldQueue on the notification should work, but package-specific queue semantics are undocumented — verify in the spike, don't assume.telebot:install registers webhook routes. Check for collisions with catch-all routes, global middleware, and CSRF/exception handling before shipping..env in a repo) up front.Sequencing (each phase with an exit criterion)
/start command, telebot:webhook --setup then --info. Exit: end-to-end round trip confirmed._rescue policy, outbound queueing. Exit: signed-off ADR.Non-negotiable guardrails
secret_token; do not run with the optional validation disabled.FileStorage before the second node exists.Maintenance
Support
^ ranges on a low-adoption dependency in a production bot.Scaling
_rescue for inspecting 429 and retry_after, but provides no managed retry queue — outbound sends must go through our queue with backoff.FileStorage is single-node by construction; a StorageContract implementation on our DB or Redis is required for any HA deployment and should be treated as a day-one deliverable, not a follow-up.Failure modes
| Mode | Signal | Response |
|---|---|---|
| 401 invalid/revoked token | Exception on any API call | Boot-time env validation + health check; no retry |
| 403 blocked / no rights | Send failures to a chat | Log and skip; do not retry |
| 429 rate limited | retry_after in error |
Queue + backoff; _rescue inspects getCode() |
| Network / DNS / timeout | Guzzle exception | One short retry, then surface via _rescue |
| Handler exception | No reply, non-2xx → Telegram retries | Global try/catch + report(), respond 200 fast, offload to queue |
| Duplicate updates | Same update_id processed twice |
Idempotency key on update_id; do not assume exactly-once |
| Missing/disabled secret token | Unauthenticated POSTs accepted | Make secret_token mandatory; keep UpdateRequest validation |
| Webhook + polling both configured | Lost or duplicated updates | Startup check / operational policy |
| Storage unavailable | Input state lost mid-flow | Fail closed with a user-facing message |
Ramp-up
TPM recommendation Viable for a bounded, non-critical Telegram surface — notifications, internal ops bots, moderate command/callback bots — where the Laravel-native adapter saves real glue code. Proceed only with: mandatory secret token, DB/Redis state storage, queued outbound sends with backoff, idempotent update handling, pinned versions, and a documented fork-and-patch exit plan. The 15-star adoption signal and thin support model are the deciding constraints; do not place revenue-critical or high-volume conversational flows on this package without those mitigations funded and owned.
How can I help you explore Laravel packages today?