Guide to Creating Your Own Bots from Scratch

🧩 So, What Changed?

In the last post, I talked about this cool bot I found — a Telegram bot that handed out disposable emails and pinged you when you got mail. Super handy. But using that tool sparked something deeper:

"Why not build my own bot?"

Spoiler alert: I did.


⚙️ What I Wanted To Build

I wanted a bot that wasn’t just a gimmick — something that:

  • 🤝 Responds to commands like /start, /help, and /about

  • 🧠 Remembers user sessions and states

  • 📨 Lets users send a fake email from Telegram to an actual inbox

  • 🚀 Maybe, just maybe, automate future workflows with buttons, menus, and replies

Basically, I wanted it to feel less like a bot and more like a cyber sidekick.


🔧 Tools & Stack

  • Language: Python 3

  • Bot Framework: python-telegram-bot

  • Hosting: Railway (yes, I’m cheap and lazy)

  • Email Relay: Integrated with SMTP for outbound fake emails

  • Extras: Markdown formatting, async functions, and custom keyboards for replies


🛠️ The Build Process (With Dumb Mistakes I Made)

Step 1: Setting Up the Bot Token 🔑

Grabbed the token from @BotFather (yes, still feels like talking to mafia). Put it in a .env file — lesson learned from hardcoding it once and almost pushing to GitHub. 😅

Step 2: Basic Command Handling 🚦

Wired up /start, /help, and /reset. Pretty straightforward.

@bot.message_handler(commands=['start'])
def send_welcome(message):
    bot.reply_to(message, "Hey, I'm your cyber mailman. Type /help to see what I do.")

Step 3: Sending Emails via Telegram 📤

Hooked up the backend with SMTP. Had the user enter subject ➝ recipient ➝ body — in that order.

Also added some basic validation because people type like goblins.

Step 4: Buttons & Flow ✨

Instead of plain text, I used Telegram inline buttons. So now, it’s tap-and-go instead of sending a wall of text.

InlineKeyboardButton("Send New Email", callback_data='send_email')

🧠 What I Learned

  • How to use inline queries and callback handlers

  • That bot UX is way harder than expected

  • Sending emails from bots is easy, validating human input is not

  • Hosting bots that don't go offline is a full-time job


🚀 Future Plans

  • Add a dashboard for viewing sent emails

  • Schedule emails using cron

  • Integrate with GPT for auto-generating email replies 🤯

  • Maybe… maybe even turn it into a public utility?


TL;DR

I used a Telegram bot. I liked it. I built my own bot. It sends fake emails and talks like me.

Moral of the story? Curiosity + caffeine = shipping cool shit.


Built with 💻, ☕, and a hint of "I wonder if this breaks..."

Link? Have it: https://t.me/mailer3000bot?start=_tgr_nrqbUw5iYWRl

0
Subscribe to my newsletter

Read articles from PanicAtTheKernel directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

PanicAtTheKernel
PanicAtTheKernel

Breaking things in the name of cybersecurity. I'm a cybersecurity enthusiast who enjoys exploring vulnerabilities, ethical hacking, and everything in between. Whether it's dissecting kernel panics, experimenting with security tools, or writing about the latest exploits, I'm always on the lookout for the next challenge. I document security mishaps, hacking insights, and tech quirks—sometimes for fun, sometimes to prevent disasters (mostly both). If it crashes, breaks, or gets exploited, there’s a good chance I’m writing about it.