DEV Community

Cover image for πŸ€– From Using Bots to Building One
PanicAtTheKernel
PanicAtTheKernel

Posted on

πŸ€– From Using Bots to Building One

🧩 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.")
Enter fullscreen mode Exit fullscreen mode

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')
Enter fullscreen mode Exit fullscreen mode

🧠 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

Top comments (0)