Build, deploy & manage your Telegram PHP Bot.
Everything you need to create a Telegram bot with BotFather, upload your PHP code, and launch it on TeleBotHost. Webhook configuration is automatic when you deploy a bot from the dashboard.
Getting Started
Follow these steps for your first deployment.
Create your Telegram bot
Open @BotFather, run /newbot, choose a name and username, then copy the HTTP API token.
Open TeleBotHost
Sign in to your TeleBotHost account and open New Bot from the dashboard.
Enter the token
Enter the BotFather token. Username can be left blank because TeleBotHost verifies it automatically with Telegram.
Deploy
Press Deploy with One Click. TeleBotHost creates the bot folder, writes the starter PHP code and connects the webhook.
Create a Telegram Bot
Your BotFather token is the only required Telegram credential.
- Open Telegram and search for @BotFather.
- Send
/newbot. - Choose your bot display name.
- Choose a unique username ending with bot.
- Copy the API token.
- Never share the token publicly.
PHP Bot Code
Here is a simple webhook-based PHP 8+ example. TeleBotHost's generated starter bot follows the same API approach.
<?php
declare(strict_types=1);
$BOT_TOKEN = 'YOUR_BOT_TOKEN';
$API = "https://api.telegram.org/bot{$BOT_TOKEN}/";
function telegram(string $method, array $data = []): array {
global $API;
$ch = curl_init($API . $method);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_TIMEOUT => 15,
]);
$raw = curl_exec($ch);
curl_close($ch);
return json_decode($raw ?: '{}', true) ?: [];
}
$update = json_decode(file_get_contents('php://input'), true);
if (!is_array($update)) { http_response_code(200); exit; }
$message = $update['message'] ?? null;
if (!$message) { http_response_code(200); exit; }
$chatId = $message['chat']['id'];
$text = trim((string)($message['text'] ?? ''));
if ($text === '/start') {
telegram('sendMessage', [
'chat_id' => $chatId,
'text' => "๐ Welcome! Your PHP Telegram Bot is online."
]);
} elseif ($text === '/help') {
telegram('sendMessage', [
'chat_id' => $chatId,
'text' => "/start - Start bot\n/help - Show help"
]);
} else {
telegram('sendMessage', [
'chat_id' => $chatId,
'text' => "You said: {$text}"
]);
}
http_response_code(200);
setWebhook for a bot created from the dashboard. TeleBotHost does it automatically.AI Bot Prompt Builder
Describe the bot you want, then generate a ready-to-use prompt for an AI coding assistant.
Automatic Webhook
When you deploy a bot, TeleBotHost performs the webhook setup for you.
| Stage | What happens |
|---|---|
| 1. Verify | TeleBotHost calls Telegram getMe to validate the token and detect the real username. |
| 2. Prepare | A private bot folder and starter index.php are created. |
| 3. Secure | A unique webhook secret is generated for the bot. |
| 4. Connect | Telegram setWebhook is called with the bot URL and secret token. |
| 5. Online | The dashboard marks the bot Running when Telegram confirms the webhook. |
Manage Your Bot
Open My Bots to manage your deployed bot.
Start / Deploy
Reconnect the webhook and bring the bot online.
Stop
Remove the Telegram webhook and stop incoming updates.
Health
Check Telegram bot identity and API response.
Webhook
Inspect Telegram webhook URL, errors and pending updates.
Security Best Practices
- Never publish your BotFather token.
- Use HTTPS for webhook endpoints.
- Keep PHP and server software updated.
- Do not put private API keys in frontend JavaScript.
- Use the generated webhook secret and do not remove its validation from production bots.
- Review bot logs when debugging unexpected behavior.
