Skip to content

hexamh/seo

Repository files navigation

🤖 Deep AI SEO Audit Telegram Bot

A highly optimized, serverless Telegram bot built on Cloudflare Workers. It utilizes Cloudflare's Browser Rendering API (Puppeteer) to perform deep technical SEO audits and Workers AI (Llama 3.1) to generate actionable optimization insights.

Built with TypeScript, Hono, and native Cloudflare Workers APIs.

✨ Features

  • Deep DOM Evaluation: Uses headless Chrome via @cloudflare/puppeteer to execute JavaScript, measure performance (TTFB, DOM Ready, Total Load), and extract real structural data.
  • AI-Powered Insights: Automatically analyzes extracted metrics with @cf/meta/llama-3.1-8b-instruct to provide 3 prioritized, human-readable recommendations.
  • Edge Caching: Caches expensive audit results in Cloudflare KV for 1 hour to ensure lightning-fast subsequent requests and save compute resources.
  • Spam Protection: Implements Cloudflare Rate Limiting to strictly limit users (e.g., 3 requests per minute per Chat ID).
  • Asynchronous Execution: Uses ctx.waitUntil() to process background scraping tasks without keeping the Telegram webhook connection hanging.
  • Rich Telegram Formatting: Outputs robust HTML-formatted Telegram messages that beautifully organize Data, Security Headers, Links, and Media.

🚀 Tech Stack

🛠 Prerequisites

  1. A Cloudflare Account.
  2. Node.js installed.
  3. A Telegram Bot Token from @BotFather.

📦 Setup & Installation

1. Clone & Install

Clone the repository and install dependencies:

npm install

2. Configure Cloudflare Bindings

Create the necessary KV Namespace and update your wrangler.jsonc file with your specific IDs.

# Create a KV Namespace for caching
npx wrangler kv:namespace create KV

Update the kv_namespaces id in wrangler.jsonc with the returned ID.

3. Add Telegram Bot Token

Securely add your Telegram bot token as an encrypted secret to your Worker environment:

npx wrangler secret put TELEGRAM_BOT_TOKEN

(Paste your BotFather token when prompted)

4. Deploy to Cloudflare Edge

Deploy the worker:

npm run deploy

5. Set Telegram Webhook

Register your deployed Cloudflare Worker URL with Telegram so it can receive messages. Run this in your browser or terminal (replace YOUR_BOT_TOKEN and YOUR_WORKER_URL):

curl "https://api.telegram.org/botYOUR_BOT_TOKEN/setWebhook?url=https://YOUR_WORKER_URL/webhook"

🚦 Usage

  1. Open your bot in Telegram.
  2. Send /start to see the welcome message.
  3. Send any valid URL (e.g., example.com or https://cloudflare.com).
  4. Wait 10-25 seconds. The bot will launch a headless browser, evaluate the target page, run the AI model, and return a comprehensive report.

📝 Configuration (wrangler.jsonc)

  • Rate Limiting: Modify the ratelimits array to adjust spam protection (currently set to 3 requests per 60 seconds).
  • Browser Binding: Ensure browser: { binding: "BROWSER" } remains active to utilize Cloudflare's hosted Chrome instances.
  • AI: Requires the ai: { binding: "AI" } configuration.

🧪 Local Development & Testing

Due to the use of Edge native features like Browser Rendering and AI, it is recommended to use wrangler dev --remote or test against your deployed staging worker.

npm run dev

To run Vitest unit tests:

npm run test

About

SEO Audit Telegram Bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors