CAKE20

AI Web PaaS

Telegram Alarm

Incidents that occur on the website will be notified via the site administrator's Telegram.

Admin Telegram Connection

  • Open the Telegram Alerts tab in your site's settings.
  • Create an alarm-only bot by sending /newbot to @BotFather on Telegram.
  • Enter the Bot Token issued by BotFather into the API Key.
  • Open the conversation of the bot you created, send /start, and then click Find connection information.
  • Select Enable Telegram Alerts, save the settings and try the website again. Here we go.
  • The chat ID associated with the API Key is stored as an encrypted Secret and can be restored after saving. Doesn't display.

Bot Token is a secret value that allows you to control the entire bot. Source, chat, Don't write to browser code or public repositories. Find connection information I recommend an alarm-only bot since I recently used /start in private chat.

Send Alert

  • telegram is only used in server code such as API, Route, Middleware, Task and Job. I use it.
  • telegram.active has the settings enabled and both the API Key and incoming chats are True when connected.
  • telegram.send(text) sends 1 to 4,096 characters of plain text to a fixed site administrator. Send it via chat.
  • telegram.send(text, { silent: true }) sends a silent alarm.
  • You can check the message number received by Telegram using the messageId in the result.
  • The chatId or to argument that specifies the recipient is not provided. To site members It is not an interface for sending messages.
// server/api/comment.post.ts
export default async () => {
  // Notify site administrator after saving comment
  if (telegram.active) {
    await telegram.send("💬 A new comment has been posted.");
  }
  return { ok: true };
};

Select alarm conditions

Cake20 does not prefix the alarm type. Site administrator comments, Decide on necessary events such as login, order, inquiry, error or reservation completion and send it to AI. Requests that telegram.send be called immediately after that processing.

When you run an API, Task, or Job in the editor and call telegram.send, the actual A Telegram alert will be sent. Notify site administrator before repeat testing.

Official Inquiry Alert Template

  • The official Telegram admin alert template (telegram-alert) is a customer inquiry form. This is an example of forwarding to the site owner's static private chat.
  • Inquirers do not need a Telegram account or login. Site owner only Connects the BotFather bot with the incoming chat once.
  • The template uses an empty website field as a honeypot. Service before public operation Review CAPTCHA, authentication, or additional request restrictions as appropriate.
  • The ownerAlert utility manages the message format, and the API includes chatId, to, or Do not add Bot Token.
// server/api/alert.post.ts
export default async (data: Input<typeof config.filter>) => {
  if (!telegram.active) {
    throw new Error("Please connect Telegram alarm first.");
  }
  return telegram.send(ownerAlert(data.name, data.email, data.message));
};