Blog

Send a Website Form to Telegram: 3 Ways to Set It Up

Updated:

A form submission that lands in Telegram gets noticed faster than an email, and the whole team sees it at once. There are three ways to send a website form to Telegram: turn on an integration in your website platform, write a small server script with a bot, or plug in a ready-made service. Below is each option, with working code and the mistakes people usually make.

If your visitors would rather ask a quick question than fill in a form, a live chat next to the form helps — we compared the options in our article on JivoSite alternatives.

Which method to choose

MethodWho it suitsWhat you need
Platform settingsSites on a website builder or WordPressFind the integration in form settings, or a plugin
Your own script with a botYou have a developer and a server with PHP, Node.js or PythonA bot, a chat id, a server-side script
Ready-made serviceCustom-coded site, no wish to build a form backendAdd the service’s script and connect a bot

Required for every method: create a bot

Messages to Telegram are sent by a bot. Creating one takes a couple of minutes:

  1. Open @BotFather in Telegram and send the /newbot command.
  2. Pick a display name and a username — the username must end in bot, for example myshop_leads_bot.
  3. BotFather replies with a token — a string like 123456789:AA…. It is the key to your bot: don’t publish it and don’t put it in page code.
  4. Find your bot and tap “Start”. A Telegram bot cannot message a person first — skip this step and nothing will arrive.

Method 1. Website platform settings

Many website builders and CRMs offer a Telegram connection right in their form settings: you paste the bot token or authorize the platform’s official bot. For WordPress there are plugins that forward submissions from popular form plugins to Telegram. Look in your platform’s help center for a section on “form submissions” or “notifications”.

The upside — no coding at all. The downside — it only works inside that platform: if you move to another site, you set everything up again, and sometimes receiving submissions is a paid-plan feature.

Method 2. Your own script with a bot

If your site is custom-coded and you have a server, you can send the form to your Telegram bot through the Bot API — the sendMessage method. You need the bot token and the recipient’s chat id.

How to find the chat id

  1. Send the bot any message — or add the bot to a group and post there.
  2. Open https://api.telegram.org/bot<token>/getUpdates in your browser, with your token in place of <token>.
  3. In the response, find "chat":{"id":…}. For a private chat it is a positive number, for a group it is negative (large groups start with -100).

If you get an error about a webhook instead of a list of messages, the bot already has a webhook set, and getUpdates doesn’t work while it is active. Remove it with the deleteWebhook method or create a separate bot just for form submissions.

PHP handler

The script receives the form data, checks the honeypot field and sends the message. The token and chat id come from server environment variables rather than sitting in a file that could end up publicly accessible.

send.phpphp
<?php
// send.php — lives on your server next to the website
$token  = getenv('TG_BOT_TOKEN');   // token comes from server settings, never from page code
$chatId = getenv('TG_CHAT_ID');

// Hidden honeypot field: humans don't see it, bots fill it in
if (!empty($_POST['website'])) { exit; }

$name    = trim($_POST['name'] ?? '');
$phone   = trim($_POST['phone'] ?? '');
$message = trim($_POST['message'] ?? '');

if ($phone === '') {
    http_response_code(400);
    exit('Please enter your phone number');
}

// Plain text without parse_mode — no need to escape HTML
$text = "New website lead\nName: $name\nPhone: $phone\n\n" . mb_substr($message, 0, 3000);

$ch = curl_init("https://api.telegram.org/bot$token/sendMessage");
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => ['chat_id' => $chatId, 'text' => $text],
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 10,
]);
$ok = json_decode((string) curl_exec($ch), true)['ok'] ?? false;

http_response_code($ok ? 200 : 502);
echo $ok ? 'Thank you! We will get back to you soon' : 'Could not send your message — please call us';
Form on the pagehtml
<form action="/send.php" method="post">
  <input name="name" placeholder="Name">
  <input name="phone" type="tel" placeholder="Phone" required>
  <textarea name="message" placeholder="Message"></textarea>
  <!-- honeypot for bots: hidden from humans -->
  <input name="website" tabindex="-1" autocomplete="off" style="position:absolute;left:-9999px">
  <button>Send</button>
</form>

Common mistakes

  • Token in browser JavaScript. Any visitor will see it and can send messages as your bot. Send only from the server.
  • No spam protection. A form that forwards everything to Telegram will be delivering ads within a week. At a minimum, add a honeypot field and limit submissions per IP address.
  • Markup without escaping. With parse_mode=HTML, a < character in the visitor’s message breaks the request. Send plain text or escape the data.
  • Overlong messages. Telegram accepts up to 4096 characters per message — trim the submission text.
  • Telegram as the only copy. If sending fails, the lead is gone. Also save it to a database or send it by email.

Method 3. A ready-made service, no backend

If your site is custom-coded but you don’t want to write and maintain a handler, you can hand form processing to a service. That is how Sitecog forms work: a script on the page intercepts the submission of any form, saves the lead in the CRM and sends a notification to your bot.

All it takes is an attribute on your formhtml
<script src="https://widget.sitecog.com/widget.js" defer></script>

<form data-crm-lead="callback">
  <input name="name" placeholder="Name">
  <input name="phone" type="tel" placeholder="Phone">
  <textarea name="message" placeholder="Message"></textarea>
  <button>Send</button>
</form>

What the service handles for you:

  • name, phone, email and message are detected by field names; all other fields are saved with the lead;
  • spam protection without a CAPTCHA: a honeypot field and a one-time pass, suspicious submissions arrive flagged, and a double click doesn’t create a duplicate;
  • a Telegram notification within a minute: form name, contact details, the start of the message and a link to the lead in the CRM;
  • multiple recipients, private chats and groups, each with their own quiet hours — night-time submissions arrive in the morning;
  • no lost leads even if Telegram is down: the lead is already saved in the CRM, and with the visitor’s consent to analytics — with its channel and UTM tags;
  • works with plain HTML forms, WordPress themes, and React and Vue apps (window.crmLead()).

You don’t have to hunt for chat ids: each recipient sends /start to your bot, and you click “Refresh” in the lead settings. New recipients are added switched off — anyone can message your bot, so customer contact details are only seen by the people you enable yourself.

How to check that everything works

  1. Send a test submission from the site on both a phone and a desktop.
  2. Make sure the message reached every recipient and the group.
  3. Submit the form with an empty phone field — it should not go through.
  4. A week later, look through your submissions: any spam, any lost messages?

Frequently asked questions

How do I find my Telegram chat id?

Send your bot any message (or add the bot to a group and post there), then open https://api.telegram.org/bot<token>/getUpdates in your browser. In the response, look for "chat":{"id":…} — that number is the chat id. For groups it is negative.

Why is my bot not sending messages?

Most often the recipient has never messaged the bot: a Telegram bot cannot start a conversation with a person. Other causes are a wrong chat id, the bot being removed from the group, or the token being regenerated in @BotFather. If getUpdates returns an error about a webhook, the bot has a webhook set — remove it or use a different bot.

Can I send a form to Telegram straight from JavaScript in the browser?

Technically yes, but you should not: the bot token ends up in the page source, and any visitor can use it to read the bot’s messages and send spam on its behalf. The token must live on the server only.

How do I send form submissions to several people at once?

The simplest way is a Telegram group: add the bot and your teammates and send messages to the group. In your own script you can also loop over several chat ids. In Sitecog you pick recipients with checkboxes, and each one has their own quiet hours.

How much does it cost?

The Telegram Bot API is free. Your own script costs developer time plus hosting with PHP or another server-side language. In Sitecog, form submissions are included in both paid plans — Basic ($29 per 30 days) and Pro ($79), with no limit on the number of submissions.