Logo di Telegram Bot Cloudflare

Telegram Bot Cloudflare

Community
mrhlaingbwardev
telegram-bot-cloudflare

Deploy Telegram bots to Cloudflare Workers with proper secret configuration. Use ONLY when user asks to create/deploy/fix Telegram bot on Cloudflare Workers.

Panoramica

Autoremrhlaingbwardev
Repositoryagentic-hacking-skills
Nome della skilltelegram-bot-cloudflare
Stelle
350
Fork
57
File inclusi
Solo istruzioni
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da mrhlaingbwardev su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Telegram Bot Cloudflare in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/mrhlaingbwardev/agentic-hacking-skills/tree/main/skills/telegram-bot-cloudflare
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mrhlaingbwardev/agentic-hacking-skills.git /tmp/agentic-hacking-skills
mkdir -p .claude/skills
cp -r /tmp/agentic-hacking-skills/skills/telegram-bot-cloudflare .claude/skills/telegram-bot-cloudflare
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Telegram Bot Cloudflare in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Telegram Bot Cloudflare non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Telegram Bot Cloudflare non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Telegram Bot on Cloudflare Workers

Deploy Telegram bots to Cloudflare Workers serverless platform.

Prerequisites

  • Telegram Bot Token from @BotFather
  • Cloudflare account with Workers enabled
  • Workers.dev subdomain configured

Step-by-Step Deployment

1. Get Bot Token

User gets token from @BotFather:

/newbot
Bot name: My Bot
Username: mybot_bot
Token: 123456789:ABCdefGHI...

2. Configure Workers.dev Subdomain

CRITICAL: Must configure subdomain BEFORE deploying worker.

javascript
// Check if subdomain exists
GET /accounts/{account_id}/workers/subdomain

// If 404, create subdomain
PUT /accounts/{account_id}/workers/subdomain
Body: {"subdomain": "your-subdomain"}

Example subdomain: yatal, mybots, etc.

3. Deploy Worker Script

Use vanilla JavaScript (no external imports - Cloudflare Workers doesn't support ESM imports from URLs).

javascript
export default {
  async fetch(request, env) {
    if (request.method === 'GET') {
      return new Response('Bot is running!')
    }

    const update = await request.json()
    const BOT_TOKEN = env.BOT_TOKEN
    
    async function sendMessage(chatId, text, options = {}) {
      const body = { chat_id: chatId, text, parse_mode: 'Markdown', ...options }
      await fetch(`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(body)
      })
    }

    // Handle /start
    if (update.message?.text === '/start') {
      await sendMessage(update.message.chat.id, 'Hello!')
    }

    return new Response('OK', { status: 200 })
  }
}

Deploy via Cloudflare MCP:

javascript
cloudflare.request({
  method: 'PUT',
  path: `/accounts/${accountId}/workers/scripts/bot-name`,
  body: multipart_form_data_with_script,
  contentType: 'multipart/form-data; boundary=...',
  rawBody: true
})

Metadata must include:

json
{
  "main_module": "worker.js",
  "compatibility_date": "2024-01-01"
}

4. Set Environment Variables (CRITICAL!)

WRONG WAY (will encrypt values):

javascript
// This creates encrypted secrets that worker can't read!
cloudflare.request({
  method: 'PUT',
  path: `/accounts/${accountId}/workers/scripts/bot-name/secrets`,
  body: { name: 'BOT_TOKEN', text: 'xxx', type: 'secret_text' }
})

CORRECT WAY:

javascript
// Method 1: Use secrets endpoint correctly
cloudflare.request({
  method: 'PUT',
  path: `/accounts/${accountId}/workers/scripts/bot-name/secrets`,
  body: { name: 'BOT_TOKEN', text: 'token-value', type: 'secret_text' }
})

// If this creates "Value encrypted" issue, DELETE and re-add:
// DELETE /accounts/{account_id}/workers/scripts/{script}/secrets/{secret_name}
// Then PUT again

Verification: Check in dashboard that variables show actual values (or "Secret" for secret_text type), NOT "Value encrypted".

5. Set Webhook

Worker URL format: https://{script-name}.{subdomain}.workers.dev

Example: https://my-bot.yatal.workers.dev

bash
curl "https://api.telegram.org/bot{TOKEN}/setWebhook?url=https://my-bot.yatal.workers.dev"

6. Test & Debug

Check webhook status:

bash
curl "https://api.telegram.org/bot{TOKEN}/getWebhookInfo"

Common errors:

ErrorCauseFix
404 Not FoundSubdomain not configuredCreate subdomain first
SSL handshake failureNew subdomain (cert pending)Wait 5 min or use custom domain
Value encryptedWrong secret API usageDelete secret, re-add correctly
Bot not respondingenv.BOT_TOKEN undefinedCheck secrets in dashboard

Test worker directly:

bash
# Should return "Bot is running!"
curl https://my-bot.yatal.workers.dev

Check if bot received updates:

bash
curl "https://api.telegram.org/bot{TOKEN}/getUpdates"

Common Patterns

Inline Keyboard Buttons

javascript
const keyboard = {
  inline_keyboard: [
    [
      { text: 'Button 1', callback_data: 'btn1' },
      { text: 'Button 2', callback_data: 'btn2' }
    ]
  ]
}

await sendMessage(chatId, 'Choose:', { reply_markup: keyboard })

Handle Button Callbacks

javascript
if (update.callback_query) {
  const data = update.callback_query.data
  const chatId = update.callback_query.message.chat.id
  
  // Answer callback (removes loading state)
  await fetch(`https://api.telegram.org/bot${BOT_TOKEN}/answerCallbackQuery`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ callback_query_id: update.callback_query.id })
  })
  
  // Send response
  await sendMessage(chatId, `You clicked: ${data}`)
}

Forward to Admin

javascript
bot.on('message:text', async (ctx) => {
  if (ctx.message.text.length > 30) {
    await sendMessage(
      env.ADMIN_CHAT_ID,
      `New message from ${ctx.from.first_name}:\n${ctx.message.text}`
    )
  }
})

Full Deployment Checklist

  • Get bot token from @BotFather
  • Check/create workers.dev subdomain
  • Deploy worker script with correct metadata
  • Set BOT_TOKEN secret (verify not "Value encrypted")
  • Set ADMIN_CHAT_ID if needed
  • Set webhook URL
  • Test: Send /start to bot
  • Check webhook info for errors
  • If SSL error: wait or use custom domain

Troubleshooting Commands

javascript
// List all workers
cloudflare.request({ method: 'GET', path: `/accounts/${accountId}/workers/scripts` })

// Get worker details
cloudflare.request({ method: 'GET', path: `/accounts/${accountId}/workers/scripts/bot-name` })

// Check subdomain
cloudflare.request({ method: 'GET', path: `/accounts/${accountId}/workers/subdomain` })

// Delete worker (start over)
cloudflare.request({ method: 'DELETE', path: `/accounts/${accountId}/workers/scripts/bot-name` })

Security Notes

  • Never commit bot tokens to git
  • Use secret_text type for sensitive values
  • Validate admin_chat_id before forwarding
  • Add rate limiting for production bots

Alternative: Custom Domain (Recommended for Production)

If SSL issues persist with workers.dev:

  1. Add domain to Cloudflare
  2. Create DNS record: bot.example.com → Worker route
  3. Use https://bot.example.com as webhook URL
  4. SSL works immediately (no waiting)

Remember: The most common mistake is incorrect secret configuration. Always verify in dashboard that secrets are accessible to the worker, not showing "Value encrypted" error.

Domande frequenti

Cosa fa la skill IA Telegram Bot Cloudflare?

Deploy Telegram bots to Cloudflare Workers with proper secret configuration. Use ONLY when user asks to create/deploy/fix Telegram bot on Cloudflare Workers.

Perché usare Telegram Bot Cloudflare su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Telegram Bot Cloudflare è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Telegram Bot Cloudflare in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/mrhlaingbwardev/agentic-hacking-skills/tree/main/skills/telegram-bot-cloudflare. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Telegram Bot Cloudflare?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Telegram Bot Cloudflare?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Telegram Bot Cloudflare: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Telegram Bot Cloudflare è gratuita?

È pubblicata su GitHub da mrhlaingbwardev. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇