Public
Telegram bot for selling game top-ups with Telebirr/CBE payment
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data โ€“ all from the browser, and deployed in milliseconds.

Abesha Pay โ€” Telegram Top-Up Bot (Val Town Edition)

A serverless Telegram bot for selling Free Fire Diamonds and PUBG Mobile UC to Ethiopian customers via Telebirr/CBE payment with manual admin approval.

Ported from Node.js + Telegraf โ†’ Deno + grammY + Val Town's serverless runtime

Quick Setup

1. Set your Telegram Bot Token

You already have TELEGRAM_API_TOKEN set. If not:

๐Ÿ‘‰ Add TELEGRAM_API_TOKEN here: https://www.val.town/x/abeniandela/abesha-pay-bot/environment-variables?key=TELEGRAM_API_TOKEN

Get it from @BotFather.

2. Set your Admin Telegram ID

Your numeric ID (get from @userinfobot):

๐Ÿ‘‰ Add ADMIN_TELEGRAM_ID here: https://www.val.town/x/abeniandela/abesha-pay-bot/environment-variables?key=ADMIN_TELEGRAM_ID

Replace 0 with your actual ID (e.g., 123456789).

3. Set Payment Details

Update these with your actual accounts:

๐Ÿ‘‰ Add TELEBIRR_NUMBER here: https://www.val.town/x/abeniandela/abesha-pay-bot/environment-variables?key=TELEBIRR_NUMBER

๐Ÿ‘‰ Add CBE_ACCOUNT_NUMBER here: https://www.val.town/x/abeniandela/abesha-pay-bot/environment-variables?key=CBE_ACCOUNT_NUMBER

๐Ÿ‘‰ Add ACCOUNT_HOLDER_NAME here: https://www.val.town/x/abeniandela/abesha-pay-bot/environment-variables?key=ACCOUNT_HOLDER_NAME

4. Optional: UID Verification APIs

To auto-verify Free Fire / PUBG UIDs (optional โ€” defaults to manual verification):

๐Ÿ‘‰ Add FREEFIRE_LOOKUP_URL here: https://www.val.town/x/abeniandela/abesha-pay-bot/environment-variables?key=FREEFIRE_LOOKUP_URL

๐Ÿ‘‰ Add PUBG_LOOKUP_URL here: https://www.val.town/x/abeniandela/abesha-pay-bot/environment-variables?key=PUBG_LOOKUP_URL

If you don't set these, the bot will flag UIDs as "โš ๏ธ unverified, please confirm manually" in the admin panel.

How It Works

Customer Flow

  1. Start โ†’ pick language (English ๐Ÿ‡ฌ๐Ÿ‡ง / Amharic ๐Ÿ‡ช๐Ÿ‡น)
  2. Category โ†’ Free Fire or PUBG
  3. Catalog โ†’ add up to 2 items to cart
  4. Checkout โ†’ enter UID for each game โ†’ auto-verified or flagged for manual check
  5. Payment info โ†’ payer name + phone
  6. Screenshot โ†’ upload payment receipt
  7. Order created โ†’ customer gets order #, can check status anytime with /status

Admin Flow

  • Receives every order as a photo with full details: items, UIDs, total, payer name, phone
  • Two buttons: โœ… Approve & Complete / โŒ Reject
  • Customer receives notification (in their language) when order is completed or rejected

Database

Val Town's SQLite (project-scoped) stores:

  • users โ€” Telegram ID, username, language preference
  • orders โ€” cart, UIDs, payment details, status
  • sessions โ€” checkout state (persists across serverless invocations)

No persistent in-memory state โ€” all checkout progress is saved to the database so restarts don't interrupt customers.

Differences from Node.js version

Node.js (original)Val Town (Deno)
TelegrafgrammY
better-sqlite3 (sync)std/sqlite (async)
Long polling (bot.launch())Webhook via HTTP handler
In-memory Map for sessionsSQLite sessions table
require()ES modules + https:// imports
.env fileDeno.env + Val Town UI

Files

  • index.ts โ€” main HTTP handler, all Telegram callbacks, webhook setup
  • catalog.ts โ€” Free Fire & PUBG items (prices in ETB)
  • i18n.ts โ€” English & Amharic strings, templating
  • lookupService.ts โ€” optional UID lookup (Free Fire / PUBG)
  • db.ts โ€” SQLite schema + query helpers

Webhook

On first request to the HTTP endpoint, the bot automatically sets the Telegram webhook to your val's URL. No manual setup needed โ€” just save your Telegram token and you're live.

Next Steps

  • Set ADMIN_TELEGRAM_ID to your numeric ID
  • Update TELEBIRR_NUMBER, CBE_ACCOUNT_NUMBER, ACCOUNT_HOLDER_NAME
  • (Optional) Add FREEFIRE_LOOKUP_URL and PUBG_LOOKUP_URL for auto-verification
  • Test: message your bot /start and go through the flow
  • Edit prices in catalog.ts anytime (live redeployment)

Docs