A Telegram bot that receives GitHub webhook notifications and forwards them to configured Telegram chats. Built with Grammy (Telegram bot framework), Hono (web framework), and TypeORM (database ORM).
- π Receive GitHub webhook events (push, pull requests, issues, etc.)
- π€ Telegram bot interface for management
- πΎ SQLite database for storing projects and events
- π§ Configurable for multiple GitHub projects
- π± Clean command-based interface
-
Install dependencies:
bun install
-
Create Telegram Bot:
- Message @BotFather on Telegram
- Create a new bot and get the token
-
Configure environment:
- Copy
.env.exampleto.env - Add your Telegram bot token:
TELEGRAM_BOT_TOKEN=your_token_here
- Copy
-
Run the application:
bun run dev
src/
βββ bot.ts # Telegram bot setup
βββ server.ts # Hono webhook server
βββ database.ts # TypeORM configuration
βββ commands/ # Bot commands
β βββ start.ts
β βββ help.ts
β βββ ...
βββ entities/ # Database entities
β βββ GitHubProject.ts
β βββ WebhookEvent.ts
βββ types/ # TypeScript types
βββ command.ts
Each command is implemented in src/commands/ with the following pattern:
import { Context } from "grammy";
import { Command } from "../types/command.js";
export const commandName: Command = {
command: "commandname",
description: "Command description",
handler: async (ctx: Context) => {
// Command logic here
},
};Available commands:
/start- Start the bot/help- Show help information
A Telegram bot that receives GitHub webhook notifications and forwards them to configured Telegram chats. Built with Grammy (Telegram bot framework), Hono (web framework), and TypeORM (database ORM). Deployed on Vercel Functions for serverless operation.
- π Receive GitHub webhook events (push, pull requests, issues, etc.)
- π€ Telegram bot interface for management
- πΎ SQLite database for storing projects and events
- π§ Configurable for multiple GitHub projects
- βοΈ Serverless deployment on Vercel
- π Webhook-based bot operation (no long polling)
- Bot Framework: Grammy
- Web Framework: Hono
- Database: TypeORM with SQLite
- Deployment: Vercel Functions
- Runtime: Bun
-
Install dependencies:
bun install
-
Create Telegram Bot:
- Message @BotFather on Telegram
- Create a new bot and get the token
-
Configure environment:
- Copy
.env.exampleto.env - Add your Telegram bot token:
TELEGRAM_BOT_TOKEN=your_token_here - Set
BOT_WEBHOOK_SECRETfor webhook security
- Copy
-
Run locally:
bun run dev
npm install -g vercel
# or
bun add -g vercelvercelFollow the prompts to:
- Link your Vercel account
- Set up the project
- Configure environment variables
In your Vercel dashboard or via CLI:
vercel env add TELEGRAM_BOT_TOKEN
vercel env add BOT_WEBHOOK_SECRETTelegram Bot Webhook:
- After deployment, visit:
https://your-app.vercel.app/api/bot - This sets up the Telegram webhook automatically
GitHub Webhooks:
- Webhook URL format:
https://your-app.vercel.app/api/github/{projectId} - Replace
{projectId}with the actual project ID from the bot
api/
βββ bot/
β βββ route.ts # Telegram bot webhook handler
βββ github/
βββ [projectId]/
βββ route.ts # GitHub webhook handler
src/
βββ bot.ts # Bot setup and commands
βββ database.ts # TypeORM configuration
βββ commands/ # Bot commands (modular design)
β βββ start.ts
β βββ help.ts
β βββ projects.ts
β βββ addproject.ts
β βββ events.ts
βββ entities/ # Database entities
β βββ GitHubProject.ts
β βββ WebhookEvent.ts
βββ types/
βββ command.ts # Command interface definition
Each command is implemented in src/commands/ with the following pattern:
import type { Context } from "grammy";
import type { Command } from "../types/command";
export const commandName: Command = {
command: "commandname",
description: "Command description",
handler: async (ctx: Context) => {
// Command logic here
},
};Available commands:
/start- Start the bot/help- Show help information/projects- List configured projects/addproject <owner> <repo> [description]- Add new project/events- Show recent webhook events
The application uses SQLite with the following entities:
- GitHubProject: Project configuration
- WebhookEvent: Event storage with relations
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
BOT_WEBHOOK_SECRET=your_webhook_secret
DATABASE_URL=github_webhooks.db-
Add a project: Send
/addproject owner repositoryto the bot -
Configure GitHub webhook:
- Go to your repository settings
- Add webhook URL:
https://your-app.vercel.app/api/github/{projectId} - Set content type to
application/json
-
Receive notifications: The bot will automatically forward GitHub events to your configured chat
# Local development
bun run dev
# Deploy to production
bun run deployMIT
The application uses SQLite with the following entities:
- GitHubProject: Stores GitHub repository configurations
- WebhookEvent: Stores received webhook events
# Development mode with hot reload
bun run dev
# Build for production
bun run build
# Start production server
bun run startMIT