Console Commands
This package ships interactive Artisan commands for Laravel applications. They use Laravel Prompts for modern console input and keep tokens, webhook secrets, chat IDs, and message text out of logs.
Commands
Command | Purpose |
|---|---|
| Publish package config and print copy-ready Laravel env/config snippets. |
| Diagnose bot config, webhook secret policy, route registration, and Telegram API reachability. |
| Scaffold webhook command, update-type, or fallback handler classes. |
| Verify a configured bot token and print Telegram bot identity fields. |
| Send a delivery test message to a configured channel, chat, forum topic, or direct messages topic. |
| Register a Telegram webhook with optional secret token and allowed update types. |
| Delete the Telegram webhook, optionally dropping pending updates. |
| Show Telegram webhook delivery status. |
| Fetch updates and print parsed |
All commands accept --bot=<name> when the host application has multiple configured bots.
Install
Run:
The command publishes config/telegram-bot.php, asks for bot/channel names when needed, optionally validates a bot token through getMe, and prints copy-ready environment values:
Non-interactive example:
The command does not write secrets into .env. Store real bot tokens and webhook secrets in the host application's environment or secret manager.
Make Handler
Scaffold webhook handlers directly into the host Laravel app:
The command creates classes under app/Telegram/Commands or app/Telegram/Handlers, adds the matching webhook contract, and prints the config/telegram-bot.php registration snippet. Use --force only when you intentionally want to overwrite an existing handler file.
Bot Identity
Use telegram-bot:me when you want a standalone token/config check without running the installer:
The command calls Telegram getMe and prints fields such as id, username, can_join_groups, supports_inline_queries, can_connect_to_business, and supports_guest_queries.
For raw Telegram JSON:
Doctor
Use telegram-bot:doctor when checking a host application before or after deploy:
The command checks:
configured bot resolution;
webhook secret policy, including fail-closed production settings;
package webhook route registration;
live
getMeandgetWebhookInfocalls.
For CI jobs or offline config checks, skip Telegram network calls:
Set Webhook
Interactive:
Non-interactive:
Useful options:
Option | Description |
|---|---|
| Public HTTPS webhook URL. |
| Telegram webhook secret token. The command never prints the value. |
| Register the webhook without a secret token. Not recommended for production. |
| Repeatable update type filter. Omit to let Telegram send all default updates. |
| Telegram webhook max connections. |
| Fixed IP address for Telegram webhook delivery. |
| Drop pending updates while setting the webhook. |
The secret token must match Telegram's contract: 1-256 characters using only A-Z, a-z, 0-9, _, and -.
Webhook Info
The command displays a table with url, pending_update_count, last error fields, max connections, and allowed updates.
For raw Telegram JSON:
Delete Webhook
Interactive:
Non-interactive:
Drop pending updates at the same time:
Discover Chat IDs And Thread IDs
Telegram getUpdates and webhooks are mutually exclusive. If a webhook is active, the command warns you. In interactive mode it can delete the webhook before polling; in automation use --delete-webhook or skip the check with --skip-webhook-check.
Add the bot to the target chat, channel, group, or topic.
Send a fresh test message in the exact destination.
Run:
The command prints parsed rows instead of raw JSON:
Update | Type | Source | Chat ID | Thread ID | DM Topic ID | Message ID | Chat Type | Title |
|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
It also prints copy-ready values:
Use chat_id for normal channel mappings. Use message_thread_id only when the destination is a forum topic. For direct messages topics, use direct_messages_topic_id.
Non-interactive examples:
If a webhook is active and you want to poll updates:
Raw JSON remains available for debugging:
Send A Test Message
Use telegram-bot:send-test after configuring a channel or after discovering IDs. This verifies the full Laravel path from configured bot token to Telegram delivery.
Interactive:
Send to a configured channel:
Send to a configured forum topic channel:
Send to an explicit chat or channel ID:
Send to an explicit forum topic:
Send to an explicit direct messages topic:
Useful options:
Option | Description |
|---|---|
| Configured Laravel channel name from |
| Explicit Telegram chat ID or target channel username. |
| Forum topic ID for explicit chat targets. |
| Direct messages topic ID for explicit chat targets. |
| Test message text. Defaults to |
| Optional parse mode: |
| Send the test message silently. |
| Protect the message content from forwarding and saving. |
Multi-Bot Usage
For a named bot:
Configure named bots in config/telegram-bot.php:
Safety Notes
Do not paste real tokens or secrets into committed files.
Use
telegram-bot:mebefore webhook setup when you need to verify which bot token is loaded.Use
telegram-bot:send-testaftertelegram-bot:updatesto confirm the bot can write to the selected chat or topic.Use
telegram-bot:webhook:infoafter deployment to verify Telegram sees the expected URL.Use
telegram-bot:updatesonly for discovery or polling workflows; if a webhook is active, Telegram will not also deliver the same updates throughgetUpdates.Keep
TELEGRAM_WEBHOOK_REQUIRE_SECRET=truein production.