1 unstable release

0.8.2 Jan 1, 2020

#30 in #bot

Used in 2 crates (via cxmr-telegram)

MIT license

4.5K SLoC

Ruby 3.5K SLoC // 0.0% comments Rust 803 SLoC // 0.0% comments

Rust Telegram Bot Library

Build Status License Crates.io

Documentation: Latest crates.io version

A library for writing your own Telegram bots. More information here. Official API here.


Here is a simple example (see example/simple.rs):

extern crate futures;
extern crate telegram_bot_async;
extern crate tokio;

use std::env;

use futures::{Stream, future::lazy};

use telegram_bot_async::*;

fn main() {
    tokio::runtime::current_thread::Runtime::new().unwrap().block_on(lazy(|| {
        let token = env::var("TELEGRAM_BOT_TOKEN").unwrap();
        let api = Api::new_default(token).unwrap();

        // Convert stream to the stream with errors in result
        let stream = api.stream().then(|mb_update| {
            let res: Result<Result<Update, Error>, ()> = Ok(mb_update);

        // Print update or error for each update.
        stream.for_each(move |update| {
            match update {
                Ok(update) => {
                    // If the received update contains a new message...
                    if let UpdateKind::Message(message) = update.kind {
                        if let MessageKind::Text { ref data, .. } = message.kind {
                            // Print received text message to stdout.
                            println!("<{}>: {}", &message.from.first_name, data);

                            // Answer message with "Hi".
                                "Hi, {}! You just wrote '{}'",
                                &message.from.first_name, data
                Err(_) => {}


You can find a bigger examples in the examples.


This library is available via crates.io. In order to use it, just add this to your Cargo.toml:

telegram-bot-async = "0.7"


Yes please! Every type of contribution is welcome: Create issues, hack some code or make suggestions. Don't know where to start? Good first issues are tagged with up for grab.


~111K SLoC