End-To-End Setup Guide
This guide explains the full path from an empty Telegram account to a working Laravel integration:
create a bot;
get the bot token, bot username, and bot ID;
create a channel or group;
add the bot to the destination;
get the channel or group ID, plus optional topic identifiers when the destination uses topics;
install and configure the Laravel package;
send a safe test message.
Primary Telegram references:
1. Values You Will Need
Keep these values separate:
Value | Example | Required by this package | Where it comes from |
|---|---|---|---|
Bot token |
| Yes | BotFather |
Bot username |
| No, but useful for adding/searching the bot | BotFather |
Bot ID |
| Usually no |
|
Destination chat ID |
| Yes |
|
Topic ID |
| Optional; only for forum topics |
|
Do not commit real tokens, private chat IDs, webhook secrets, or screenshots containing them.
For production webhooks, also plan queue and duplicate-update settings:
Value | Recommended example | Purpose |
|---|---|---|
Webhook queue |
| Acknowledge Telegram quickly and process handlers in Laravel queue workers. |
Webhook queue name |
| Keeps bot work separate from default application jobs. |
Idempotency guard |
| Skips repeated deliveries for the same bot and |
Idempotency TTL |
| Keeps duplicate keys long enough for Telegram retry windows. |
Conversation store |
| Enables cache-backed state for multi-step webhook flows. |
2. Create The Bot In BotFather
Open Telegram.
Search for
@BotFather.Open the verified BotFather chat.
Press
Start.Send
/newbot.Enter a display name, for example
Company Inbox.Enter a username. It must end with
bot, for exampleCompanyInboxBot.BotFather will send the bot token.
Copy the token into a password manager or secret store.
The bot token is the credential your Laravel app uses to call Telegram. Treat it like a password.
3. Save Or Regenerate The Bot Token
If you need the token later:
Open
@BotFather.Send
/mybots.Select the bot.
Open
API Token.Copy the token.
If the token was exposed in a commit, screenshot, ticket, log, or chat, revoke it in BotFather and generate a new token.
4. Get The Bot ID And Username
The bot username is the public handle, for example @CompanyInboxBot.
After the package is installed in Laravel, prefer the built-in command because it uses the configured bot and does not put the token in a browser URL:
The bot ID is the numeric identifier returned by Telegram getMe. If Laravel is not installed yet, the raw HTTP endpoint is a fallback; open this URL in a browser, replacing <BOT_TOKEN>:
Example response:
Use:
result.idas the bot ID;result.usernameas the bot username;the full token as
TELEGRAM_BOT_TOKEN.
This package usually does not need the bot ID in config, but it is useful for audits, access checks, and external operations.
5. Optional Bot Settings
In BotFather:
Send
/mybots.Select the bot.
Open
Edit Bot.Set the bot picture, description, about text, and commands if needed.
Useful commands for a simple notification bot:
For notification-only posting into a channel, group privacy settings usually do not matter. If the bot must read group messages, review BotFather privacy settings.
6. Create A Channel
Use a channel when the bot only needs to post notifications and people do not need threaded discussion.
Open Telegram.
Press the new message button.
Select
New Channel.Enter a channel name, for example
Company Inbox Alerts.Add an optional description.
Choose
Private Channelunless the channel must be public.Finish channel creation.
7. Add The Bot To The Channel
Open the channel.
Open the channel profile.
Open
Administrators.Press
Add Admin.Search for the bot username, for example
@CompanyInboxBot.Add the bot.
Give it the minimum permissions it needs.
For notification-only usage, the bot usually needs permission to post messages. Avoid broad admin permissions unless the bot actually needs them.
8. Create A Group Instead Of A Channel
Use a group when people need to reply, discuss, or work around the notification.
Open Telegram.
Press the new message button.
Select
New Group.Add at least one person or the bot.
Enter a group name, for example
Company Inbox.Open the group profile.
Add the bot if it was not added during creation.
Configure bot permissions.
If the group has forum topics enabled, each topic has its own message_thread_id.
9. Trigger A Telegram Update
Before looking for chat IDs:
Make sure the bot is in the channel or group.
Send a fresh test message in the exact destination.
If using a forum group, send the message inside the exact topic.
For channels, the bot normally needs to be an administrator to receive channel post updates and post messages.
10. Get The Channel Or Group ID With getUpdates
Open this URL in a browser:
Look for one of these objects:
message.chatfor group/private messages;channel_post.chatfor channel posts.
Example channel response:
Use the full chat.id value as TELEGRAM_INBOX_CHAT_ID, including the minus sign.
11. Get A Channel ID With getChat
If getUpdates is empty, use getChat.
For a public channel:
For a private channel:
Open channel settings.
Set a temporary public username, for example
company_inbox_alerts_temp.Open:
Copy
result.id.Remove the temporary public username if the channel should stay private.
Example response:
Use result.id as TELEGRAM_INBOX_CHAT_ID.
12. Optionally Get A Forum Topic ID
Skip this section for normal channels, normal groups, and supergroups without forum topics. Forum groups use message_thread_id to identify topics, and the package only needs that value when the destination is a specific forum topic.
Enable topics in the group if needed.
Open the exact topic.
Send a test message in that topic.
Open:
Find
message_thread_idin the message object.Use that value as
TELEGRAM_INBOX_MESSAGE_THREAD_IDonly for that forum topic destination.
Example:
If message_thread_id is absent, the message was not sent inside a forum topic.
The package can also fetch updates and print parsed identifiers for you:
See Console commands for parsed chat_id, message_thread_id, and webhook command examples.
13. Install The Laravel Package
Install the package in the host Laravel application:
Laravel 13 discovers the service provider and facade automatically.
Publish the package configuration:
This creates:
You can also run the package installer, which uses Laravel Prompts and prints copy-ready env/config snippets:
If package discovery is disabled, register the provider manually in bootstrap/providers.php:
14. Configure Environment Values
Add values like these to the Laravel application's .env. Leave topic-related values empty unless the destination is a forum topic or a direct messages topic:
For a forum topic destination, set:
For a direct messages topic destination, set:
Do not commit .env.
15. Configure config/telegram-bot.php
The published config already contains a default bot:
Add a channel mapping:
Each configured channel must have a non-empty chat_id. message_thread_id and direct_messages_topic_id are optional routing refinements; leave them empty unless the destination is a forum topic or a direct messages topic. The package validates channel mappings when channel('name') is resolved so a missing Laravel environment value fails with a configuration exception instead of a delayed Telegram API error.
For multiple bots:
16. Send A Test Message From Laravel
First verify that Laravel loads the expected bot token:
Run deploy diagnostics before registering webhooks or shipping the integration:
Then send an end-to-end delivery test through a configured channel:
For an explicit chat, optionally targeting a forum topic:
Use Laravel constructor injection in controllers, jobs, listeners, commands, or services:
You may also type-hint AlexItDev91\LaravelTelegramBot\Contracts\TelegramBotManager. Use the concrete AlexItDev91\LaravelTelegramBot\TelegramBot type when you want IDE autocomplete for every native Telegram helper method.
The facade remains available:
Or select a bot directly:
Use channel('inbox') when the destination is configured in config/telegram-bot.php. Use bot('support') when the code should provide chat_id directly.
For uploads, use InputFile::fromPath(). The package converts top-level files and nested media files to multipart form data:
If the host app needs custom transport, bind GuzzleHttp\ClientInterface before resolving the bot client. Keep http_errors disabled so Telegram API error payloads remain available to the SDK:
17. Receive Telegram Webhooks
The package registers POST /telegram-bot/webhook by default. Configure a secret token and pass the same value to Telegram:
The webhook secret must follow Telegram's allowed format: 1-256 characters using only letters, numbers, _, and -.
Incoming updates can be handled with AlexItDev91\LaravelTelegramBot\Contracts\TelegramWebhookHandler or by listening for AlexItDev91\LaravelTelegramBot\Laravel\Events\TelegramWebhookReceived.
See Webhooks for route configuration, handler examples, event usage, secret validation, and production safety notes.
18. Test With Tinker
Run:
Then:
If the message appears in Telegram, the bot, channel, identifiers, package config, and Laravel integration are connected correctly.
19. Troubleshooting
If getUpdates is empty:
Send a fresh message after adding the bot.
Remove and re-add the bot as an administrator.
Use
getChatwith a public or temporary public channel username.Check whether a webhook is consuming updates. If needed, inspect
getWebhookInfo.
If Laravel cannot send a message:
Check
TELEGRAM_BOT_TOKEN.Check that config cache was refreshed after changing
.env:
Check that
TELEGRAM_INBOX_CHAT_IDincludes the full negative value.Check that the bot is still a channel administrator or group member.
Check that the bot has permission to post messages.
Check
TELEGRAM_INBOX_MESSAGE_THREAD_IDonly when the destination is a forum topic.Check Laravel logs for Telegram API errors.
If Telegram returns chat not found, the bot usually cannot access that chat or the chat ID is wrong.
If Telegram returns Forbidden, the bot may have been removed, blocked, or denied permission to post.
If Telegram webhook delivery fails:
Check
getWebhookInfofor the last delivery error.Check that
TELEGRAM_WEBHOOK_SECRET_TOKENmatches thesecret_tokenpassed tosetWebhook.Check that the route URL is public HTTPS and points to
route('telegram-bot.webhook')or your configured route.Check that the handler returns quickly or dispatches slow work to a queue.
Check Laravel warning/error logs for rejected secrets, invalid payloads, invalid handler configuration, and handler failures.
20. Production Safety Checklist
Store bot tokens only in
.env, secret storage, or deployment platform secrets.Do not commit real bot tokens, private chat IDs, webhook secrets, logs, or screenshots.
Set a webhook secret token and pass it to Telegram with
setWebhook.Keep webhook secret enforcement enabled in production with
TELEGRAM_WEBHOOK_REQUIRE_SECRET=true.Keep safe operational logging enabled with
TELEGRAM_BOT_LOGGING_ENABLED=true.Give the bot only the permissions it needs.
Use a private channel or private group for operational notifications.
Rotate the token if it appears anywhere public.
Send a harmless test message before sending real customer, inbox, or operational content.
Keep a record of bot username, bot ID, destination chat ID, and optional topic IDs in a private operations document.