Website Change Alerts to Telegram: Bot and Webhook Setup
Get AyeWatch website change alerts as Telegram messages. Create a bot with BotFather, then run a short relay that turns the signed webhook into a sendMessage call.
By AyeWatch Team4 min read
Short answer: To get website change alerts in Telegram, create a bot with BotFather, then point AyeWatch's signed webhook at a short relay that calls the Bot API's sendMessage method. AyeWatch has no Telegram button, and Telegram needs a text field its payload lacks, so the relay builds the message. Webhooks need a paid plan.
How the pieces fit
AyeWatch posts a JSON body to your webhook URL. Telegram's sendMessage method needs a chat_id and a text of 1 to 4096 characters. The AyeWatch payload has neither, so the relay sits between them: it checks the signature, builds the text from topic_name, headline and content, and calls https://api.telegram.org/bot followed by your token and /sendMessage.
Create the bot and find your chat ID
Message @BotFather in Telegram, send /newbot and follow the prompts until it gives you a token. Telegram's tutorial says to treat the token like a password.
The chat ID comes from the bot itself. For a private chat, Telegram requires that you have contacted the bot first, so open the bot and send it any message. Then request https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates in a browser and read message.chat.id from the result. For a group, add the bot to the group, send a message there and read the same field.
The relay
This Node.js version uses the signature check from AyeWatch's docs and Node 18 or newer for the built-in fetch. Set AYEWATCH_SECRET, TELEGRAM_TOKEN and TELEGRAM_CHAT_ID as environment variables.
const crypto = require("crypto");
const express = require("express");
const app = express();
const seen = new Set();
app.post("/ayewatch", express.raw({ type: "application/json" }), async (req, res) => {
const expected = "sha256=" + crypto
.createHmac("sha256", process.env.AYEWATCH_SECRET)
.update(req.body)
.digest("hex");
const got = req.headers["x-ayewatch-signature"] || "";
if (expected.length !== got.length) return res.status(401).end();
if (!crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(got))) {
return res.status(401).end();
}
const e = JSON.parse(req.body);
if (seen.has(e.update_id)) return res.status(200).end();
const text = [e.topic_name, e.headline, e.content].filter(Boolean).join("\n\n");
const r = await fetch(
"https://api.telegram.org/bot" + process.env.TELEGRAM_TOKEN + "/sendMessage",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chat_id: process.env.TELEGRAM_CHAT_ID,
text: text.slice(0, 4096),
}),
}
);
if (!r.ok) return res.status(502).end();
seen.add(e.update_id);
res.status(200).end();
});
app.listen(3000);
The route reads the raw body with express.raw because the signature covers the exact bytes AyeWatch sent. No parse_mode is set, so Telegram treats the text as plain text and a stray underscore in a headline cannot break the message.
What the message looks like
For this made-up alert the relay sends three short paragraphs. The fields come from the webhook payload.
https://tidewaterferries.example/timetable
Tidewater Ferries cancels the 17:40 Harbor Point sailing
The weekday 17:40 sailing is marked cancelled from 2 December. The 18:15 departure is unchanged.
Sample rule: Alert me when the Tidewater Ferries timetable page changes a departure time, cancels a sailing or adds a service notice. Ignore fare table edits.
Retries and duplicate messages
AyeWatch retries any non-2xx reply or timeout with exponential backoff, up to 10 attempts, and its docs warn that a delivery may arrive more than once. The relay answers 200 only after Telegram accepted the message, and it remembers update_id so a repeat does not send twice. The in-memory set empties when the process restarts, which is fine for a personal bot. For a team, store the IDs in a database.
Deliveries must finish within 10 seconds, so keep the relay free of slow lookups.
When Telegram is the wrong channel
- You want no code. Receive the webhook in n8n, which has its own Telegram step, and skip the relay.
- A team needs a record. A chat scrolls away. Log alerts to a sheet or a database as well.
- Fast reaction. Checks run on a schedule, hourly on Pro and faster in ASAP mode on Pro+.
- Pages behind a login. AyeWatch reads public pages and cannot sign in.
Cost and effort
AyeWatch Pro is $9/mo with 50 topics and hourly checks; Pro+ is $19/mo with 200 topics and ASAP mode. Every plan starts with a 7-day free trial. Most checks use 1 credit. The relay needs a small host with a public HTTPS address, so check that host's pricing page.
From bot to first alert
- Create the bot with @BotFather and save the token.
- Send the bot a message, then read your chat ID from getUpdates.
- Deploy the relay with its three variables, on a host with a public HTTPS URL.
- Create the monitor in AyeWatch and write the rule.
- Open Notification settings, Webhook, paste the relay URL and select Save Webhook. Copy the signing secret into
AYEWATCH_SECRET. - Wait for the next alert. The next real update is the test, so the first message may take a check cycle.
| AyeWatch field | Telegram sendMessage parameter | Note |
|---|---|---|
| topic_name | Part of text | The page URL for a web page monitor |
| headline | Part of text | Short summary of the change |
| content | Part of text | Cut at 4096 characters, Telegram's limit |
| Your own setting | chat_id | From getUpdates, set once as an environment variable |
| Not set | parse_mode | Left out so text stays plain |
Start a monitor in under a minute
Describe a topic or paste a URL. Cancel before the trial ends and you pay nothing.
Try it free for 7 daysThe bottom line
Create the bot, send it one message and fetch your chat ID before you write any relay code. Once getUpdates shows the ID, the rest is a copy of the script above.
FAQ
Can AyeWatch send alerts to Telegram directly?
There is no Telegram setting in AyeWatch. Use the signed webhook with a relay that calls the Bot API's sendMessage method.
How do I find my Telegram chat ID?
Message your bot, call getUpdates in a browser with your token, and read message.chat.id from the response.
What is the Telegram message length limit?
sendMessage accepts text of 1 to 4096 characters. The relay cuts longer updates to fit.
Why do I get the same message twice?
AyeWatch retries failed deliveries and a delivery may repeat. Store update_id and skip any you have already sent.