Skip to main content

Quickstart

Build and run your first Telegram bot in minutes.

Core Concepts

Understand the Bot, Context, handlers, and middleware.

Guides

Step-by-step guides for commands, keyboards, files, and more.

API Reference

Full reference for every type, method, and event constant.

What is Telebot?

Telebot is a bot framework for the Telegram Bot API written in Go. Rather than providing a thin 1:1 wrapper over the API, Telebot focuses on developer ergonomics and performance — giving you a clean routing system, composable middleware, and transparent file handling out of the box.
go.mod
module gopkg.in/telebot.v4
go get -u gopkg.in/telebot.v4

Minimal example

main.go
package main

import (
	"log"
	"os"
	"time"

	tele "gopkg.in/telebot.v4"
)

func main() {
	pref := tele.Settings{
		Token:  os.Getenv("TOKEN"),
		Poller: &tele.LongPoller{Timeout: 10 * time.Second},
	}

	b, err := tele.NewBot(pref)
	if err != nil {
		log.Fatal(err)
	}

	b.Handle("/hello", func(c tele.Context) error {
		return c.Send("Hello!")
	})

	b.Start()
}

Key features

Command routing

Route /commands, text patterns, and all Telegram update types through a single Handle() API.

Middleware

Chain middleware globally, per-group, or per-handler. Includes Logger, AutoRespond, Whitelist, and Recover out of the box.

Transparent File API

Send files from disk or URL. Telebot automatically uploads on first send and reuses the Telegram FileID on subsequent sends.

Keyboards

Build reply and inline keyboards with a fluent markup builder. Buttons act as routing endpoints.

Inline mode

Handle inline queries and respond with typed result objects for photos, articles, GIFs, and more.

Layout system

Define bot configuration, keyboards, and locales in YAML. Switch user locale at runtime.

Installation

go get -u gopkg.in/telebot.v4
Telebot requires Go 1.16 or later.

Build docs developers (and LLMs) love