"WhatsApp button for website" and "Telegram chat widget" actually cover three different things: a link that takes the visitor into the messenger; a chat service where the operator replies from Telegram; and a chat on the site itself with Telegram notifications. Here is each one, with working code and an honest list of what it cannot do.
Three ways
| Link button | Your own bot or a service that replies from Telegram | On-site chat + notifications | |
|---|---|---|---|
| Where the visitor writes | In their own WhatsApp or Telegram | In a window on the site | In a window on the site |
| Where you reply | In the messenger | In Telegram | In the chat service |
| Visitor needs the messenger | Yes | No | No |
| Cost | Free | A server and developer time, or a service plan | A service plan |
| Shows which page and ad they came from | No | If you pass it yourself | Usually yes |
WhatsApp button for your website
WhatsApp has an official click-to-chat address: https://wa.me/ followed by the number in international format — no plus sign, spaces, brackets or dashes, and no leading zero of the local number. A US number (555) 123-4567 becomes 15551234567; a UK mobile 07700 900123 becomes 447700900123. The ?text= parameter pre-fills a message the visitor sends with one tap.
<!-- "Chat on WhatsApp" and "Chat on Telegram" buttons -->
<div class="msg-buttons">
<a href="https://wa.me/15551234567?text=Hi%21%20I%20have%20a%20question"
target="_blank" rel="noopener" aria-label="Chat on WhatsApp" class="msg-btn msg-wa">WhatsApp</a>
<a href="https://t.me/your_username"
target="_blank" rel="noopener" aria-label="Chat on Telegram" class="msg-btn msg-tg">Telegram</a>
</div>
<style>
.msg-buttons { position: fixed; right: 16px; bottom: 16px; z-index: 9999;
display: flex; flex-direction: column; gap: 8px; }
.msg-btn { display: block; padding: 12px 18px; border-radius: 999px; color: #fff;
font: 600 15px/1 system-ui, sans-serif; text-decoration: none;
box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.msg-wa { background: #25d366; }
.msg-tg { background: #229ed9; }
</style>Paste the code before the closing </body> tag and replace the number and username with your own. The text in the link must be URL-encoded: a space becomes %20, an exclamation mark %21. If you build the link in code, use encodeURIComponent:
// Encode the message text, or spaces, "&", "#" and non-Latin letters will break the link
const phone = '447700900123'; // international format, no +, spaces or brackets
const text = 'Hi! A question about order ' + orderId;
const url = 'https://wa.me/' + phone + '?text=' + encodeURIComponent(text);Telegram on your website
Link to an account or a bot
The address https://t.me/name opens a chat with a user, channel or bot. You need a public username, which you set in Telegram settings. For a bot you can pass a tag: https://t.me/botname?start=catalog — the bot receives the command /start catalog and knows which page the visitor came from.
Reply from Telegram to a visitor on the site
This is what people want most often: a chat window on the site, and the operator replies in Telegram on their phone. The ready-made way is a live chat service that offers actual replies from Telegram — check the description carefully, because many only send a Telegram notification and expect you to reply in their own app.
The do-it-yourself way is a bot that relays messages in both directions. The first half — sending a message from the site to the operator — looks like this:
<?php
// A home-made Telegram chat: message from the site -> bot -> operator.
// This is only the first half: the bot receives the operator's reply via a webhook,
// and you still have to store it and show it to the visitor on the site.
$token = 'BOT_TOKEN'; // from @BotFather
$chatId = 'OPERATOR_CHAT_ID'; // who the bot writes to
$text = trim($_POST['message'] ?? '');
$visitor = preg_replace('/[^a-z0-9]/i', '', $_POST['visitor'] ?? '');
if ($text === '' || $visitor === '') { http_response_code(422); exit; }
$ch = curl_init("https://api.telegram.org/bot{$token}/sendMessage");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => [
'chat_id' => $chatId,
// the visitor id in the text tells the webhook who the reply is for
'text' => "#{$visitor}\n{$text}",
],
]);
curl_exec($ch);
curl_close($ch);The second half is harder, and people usually underestimate it:
- a webhook where Telegram sends the operator's reply, plus working out which visitor it is for;
- storing the conversation and delivering the reply to the site — the visitor waits for it in an open window, without reloading;
- what the visitor sees if nobody replies: an offline form, email;
- several operators who must not answer the same person at once;
- spam protection: bots will find an open
chat.phpendpoint.
If you only need form leads in Telegram, not a conversation, that is much simpler — see website leads to Telegram: 3 ways.
On-site chat with Telegram notifications: Sitecog
Sitecog live chat is the third way: the visitor writes in a window on the site without installing anything, and Telegram reminds a team member if a message stays unread for too long — with quiet hours for each person. Replies happen in the CRM in the browser, where you also see where the visitor came from, their UTM tags, landing page and country.
Chat comes with the Basic ($29 per 30 days, up to 5 people) and Pro ($79, up to 20) plans, together with form leads and the CMS. For a comparison with other services, see live chat for websites: 8 services and prices.
Frequently asked questions
How do I add a WhatsApp button to my website for free?
Link to https://wa.me/15551234567 — the number in international format, without the plus sign, spaces or brackets. A click opens a WhatsApp chat with that number. Add a pre-filled message with the ?text= parameter and URL-encoded text. No plugin or service is needed.
How do I add Telegram to a website?
The simplest way is a link to https://t.me/username or https://t.me/botname: a click opens that chat in Telegram. The account needs a public username for this. The conversation itself happens in Telegram, not on your site.
Can I reply to website visitors from Telegram?
Yes, but you need either a live chat service where the operator replies straight from Telegram (look for "reply from Telegram" in the description, not just "Telegram notifications"), or your own bot that relays messages both ways. Your own bot means a server, a webhook and storing the conversation.
Why is a messenger button worse than a chat on the site?
The button sends people away from your site into an app, and some of them never write: no WhatsApp on their computer, or they do not want to share their number. On the plus side, the conversation stays on your phone. A chat on the site needs nothing installed, but you reply inside the chat service.
Does a WhatsApp button need cookie consent?
A plain link to wa.me or t.me sets no cookies and tracks nothing until someone clicks it. Ready-made widgets from third-party services may load their own scripts — check those separately.
