telebot 1.0.3
telebot: ^1.0.3 copied to clipboard

Telegram Bot client for dart.

telebot #


telebot is a Telegram Bot API implementation for Dart, you can use this library to execute Telegram Bot API by easy ways, see Telegram Bot API in Telegram Bot Document.

Dart Version Pub

Install #

  telebot: ^1.0.0

Imports #

import 'package:telebot/telebot.dart';

How to Create A Bot ? #

See here or follow steps below

Step 1. Add BotFather as Contact #

All Telegram Bot's action is by talking with BotFather to complete, so you need to browse to add BotFather as contact

Step 2. Talk with BotFather and Execute Command #

Open Telegram and find BotFather, then send any message to him, he will tell you all what can he do

Step 3. Create A New Bot #

Send /newbot to him and follow the steps, final you will create a bot

Step 4. Get API Token of Bot #

Send /mybots to him then choose your bot, then choose option API Token, final you will get token

How to Use telebot ? #

Create Bot #

var bot = TelegramBot.init("BOT_TOKEN");

Send Message #

var bot = TelegramBot.init("BOT_TOKEN");
bot.sendMessage(chateId: "CHAT_ID", text: "Hello World").then((Message messageResult){
  // got result  
  // handle error

or use async/await

var bot = TelegramBot("BOT_TOKEN");
Message messageResult = await bot.sendMessage(chateId: "CHAT_ID", text: "Hello World");

Other APIs #

All Telegram Bot API was implemented in telebot, see Telegram Bot Document.

Objects Field #

var bot = TelegramBot("BOT_TOKEN");
await bot.sendMessage(
  chatId: "CHAT_ID",
  text: "Choose One!",
  replyMarkup: InlineKeyboardMarkup(
    inlineKeyboard: [
        InlineKeyboardButton(text: "Apple", callbackData: "1000"),
        InlineKeyboardButton(text: "Banana", callbackData: "1001"),

InputFile or String Field #

Now telebot only support String url.

Run with Webhook #

Step 1. Initialize TelegramBot

var bot = TelegramBot.init(BOT_TOKEN);

Step 2. Listen Events

  if(message.from.isBot) return;
  message.reply("Hello! I'm a bot.");
  // do something

TelegramBot supported events


Step 3. Start Bot Server

bot.startServer(host: "YOUR SERVER HOST", port: SERVER_PORT);

Run Example #

  1. Clone this project
     git clone
  2. Edit example/env.dart and input BOT_TOKEN, SERVER_PORT and WEBHOOK_URL
  3. Run example/update_webhook.dart to set bot's webhook url
     dart ./example/update_webhook.dart
  4. Run example/start_bot_server.dart to start listening
     dart ./example/start_bot_server.dart
  5. Now talk to your bot in Telegram, then it will reply you same message!