• Stars
    star
    991
  • Rank 46,212 (Top 1.0 %)
  • Language
    C++
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Telegram on your Arduino (ESP8266 or Wifi-101 boards)

Universal Telegram Bot Library

Travis CI status License Release stable

An Arduino IDE library for using Telegram Bot API. It's designed to be used with multiple Arduino architectures.

Join the Arduino Telegram Library Group Chat if you have any questions/feedback or would just like to be kept up to date with the library's progress.

Help support what I do!

I have created a lot of different Arduino libraries that I hope people can make use of. If you enjoy my work, please consider becoming a Github sponsor!

Introduction

This library provides an interface for Telegram Bot API.

Telegram is an instant messaging service that allows for the creation of bots. Bots can be configured to send and receive messages. This is useful for Arduino projects as you can receive updates from your project or issue it commands via your Telegram app from anywhere.

This is a library forked from one library and inspired by another

Each library only supported a single type of Arduino and had different features implemented. The only thing that needs to be different for each board is the actual sending of requests to Telegram so I thought a library that additional architectures or boards could be configured easily would be useful, although this springs to mind:

alt text

Installing

The downloaded code can be included as a new library into the IDE selecting the menu:

 Sketch / include Library / Add .Zip library

You also have to install the ArduinoJson library written by Benoît Blanchon. Search for it on the Arduino Library manager or get it from here.

Getting Started

To generate your new Bot, you need an Access Token. Talk to BotFather and follow a few simple steps described here.

Include UniversalTelegramBot in your project:

#include <UniversalTelegramBot.h>

and pass it a Bot token and a SSL Client (See the examples for more details)

// Telegram BOT Token (Get from Botfather)
#define BOT_TOKEN "XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
WiFiClientSecure secured_client;
UniversalTelegramBot bot(BOT_TOKEN, secured_client);

Features

Here is a list of features that this library covers. (Note: The examples link to the ESP8266 versions)

Feature Description Usage Example
Receiving Messages Your bot can read messages that are sent to it. This is useful for sending commands to your arduino such as toggle and LED int getUpdates(long offset)

Gets any pending messages from Telegram and stores them in bot.messages . Offset should be set to bot.last_message_received + 1. Returns the numbers new messages received.
FlashLED or any other example
Sending messages Your bot can send messages to any Telegram or group. This can be useful to get the arduino to notify you of an event e.g. Button pressed etc (Note: bots can only message you if you messaged them first) bool sendMessage(String chat_id, String text, String parse_mode = "")

Sends the message to the chat_id. Returns if the message sent or not.
EchoBot or any other example
Reply Keyboards Your bot can send reply keyboards that can be used as a type of menu. bool sendMessageWithReplyKeyboard(String chat_id, String text, String parse_mode, String keyboard, bool resize = false, bool oneTime = false, bool selective = false)

Send a keyboard to the specified chat_id. parse_mode can be left blank. Will return true if the message sends successfully.
ReplyKeyboard
Inline Keyboards Your bot can send inline keyboards.

Note: URLS & callbacks are supported currently
bool sendMessageWithInlineKeyboard(String chat_id, String text, String parse_mode, String keyboard)

Send a keyboard to the specified chat_id. parse_mode can be left blank. Will return true if the message sends successfully.
InlineKeyboard
Send Photos It is possible to send phtos from your bot. You can send images from the web or from the arduino directly (Only sending from an SD card has been tested, but it should be able to send from a camera module) Check the examples for more info From URL

Binary from SD

From File Id
Chat Actions Your bot can send chat actions, such as typing or sending photo to let the user know that the bot is doing something. bool sendChatAction(String chat_id, String chat_action)

Send a the chat action to the specified chat_id. There is a set list of chat actions that Telegram support, see the example for details. Will return true if the chat actions sends successfully.
Location Your bot can receive location data, either from a single location data point or live location data. Check the example. Location
Channel Post Reads posts from channels. Check the example. ChannelPost
Long Poll Set how long the bot will wait checking for a new message before returning now messages.

This will decrease the amount of requests and data used by the bot, but it will tie up the arduino while it waits for messages
bot.longPoll = 60;

Where 60 is the amount of seconds it should wait
LongPoll
Update Firmware and SPIFFS You can update firmware and spiffs area through send files as a normal file with a specific caption. update firmware
or
update spiffs
These are captions for example.
telegramOTA
Set bot's commands You can set bot commands programmatically from your code. The commands will be shown in a special place in the text input area bot.setMyCommands("[{\"command\":\"help\", \"description\":\"get help\"},{\"command\":\"start\",\"description\":\"start conversation\"}]");. See examples SetMyCommands

The full Telegram Bot API documentation can be read here. If there is a feature you would like added to the library please either raise a Github issue or please feel free to raise a Pull Request.

Other Examples

Some other examples are included you may find useful:

  • BulkMessages : sends messages to multiple subscribers (ESP8266 only).

  • UsingWifiManager : Same as FlashLedBot but also uses WiFiManager library to configure WiFi (ESP8266 only).

License

License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

More Repositories

1

WiFi-Tetris-Clock

A WiFi clock made of falling tetris blocks. For the ESP8266 or ESP32
C++
173
star
2

push-notifications-arduino-esp8266

Example of how to generate push notifications on your phone from your ESP8266 using the Arduino IDE.
Arduino
160
star
3

ESP32-Trinity

An Open Source ESP32 board for connecting to HUB75 Matrix Panels
HTML
159
star
4

arduino-youtube-api

A wrapper around the youtube api for arduino
C++
133
star
5

spotify-api-arduino

Arduino library for integrating with the Spotify Web-API (Does not play music)
C++
131
star
6

arduino-switcheroonie

A really simple macro keyboard project using an arduino
C++
128
star
7

ESP8266-IR-Remote-Example

Arduino
114
star
8

ESP8266-Led-Matrix-Web-Draw

Draw on your LED Matrix using a webinterface
C++
79
star
9

arduino-ifttt-maker

Arduino library for raising IFTTT maker service trigger
C++
75
star
10

LED-Matrix-Display-Examples

C++
74
star
11

ESP-Web-Tools-Tutorial

A guide for setting up flashing your ESP projects directly from your browser
C++
61
star
12

ts100-flex-c-friend

Info and documentation for the TS100 Flex-C-Friend, an external add-on for TS-100 for adding USB-C PD
60
star
13

simple-arduino-crypto-display

An Arduino Crypto currency display that uses CoinMarketCap API for data
C++
53
star
14

arduino-twitter-api

Library for using the twitter api directly on an esp8266 using the Arduino IDE
C++
48
star
15

arduino-google-maps-api

An Arduino library for communicating with the Google Maps Api
C++
45
star
16

ESP8266-4051-Multiplexer-Example

An example showing how to use a 4051 multiplexer with an esp8266 to connect up to 8 analog sensors.
Arduino
42
star
17

Falling-Sand-Matrix

A falling sand simulation using an ESP32, RGB Led Matrix and an accelerometer
C++
41
star
18

ESP32-WiFi-Manager-Examples

Some simple use cases of using WiFiManager for the ESP32
C++
41
star
19

arduino-instagram-stats

A library for fetching stats from Instagram on your arduino
C++
40
star
20

arduino-slack-api

An arduino library to wrap the Slack API
C++
36
star
21

ESP32-i2s-Matrix-Shield

Info, instructions and examples for the ESP32 i2s Matrix Shield available on Tindie
35
star
22

arduino-coinmarketcap-api

A wrapper around the coinmarketcap.com api for Arduino (supports ESP8266)
C++
33
star
23

simple-wifi-controlled-rc-car

A really simple project using a NodeMCU motor shield to convert a RC car to have WiFi controls
C++
29
star
24

ScrollingLEDMatrixTelegram

Send messages to a LED Matrix display through Telegram. Inspired by a tweet from Smarter Every Day
C++
26
star
25

HTTPS-directly-from-ESP8266

Arduino
22
star
26

arduino_twitch_api

A wrapper for the Twitch API for Arduino
C++
22
star
27

TweESP32

And Twitter API library for the ESP32 that can tweet
C++
20
star
28

arduino-traffic-notifier

Get notified of busy traffic using Google maps api and an ESP8266
Arduino
20
star
29

LED-Matrix-YouTube-Sub-Display

Displaying live YouTube subscriber count using an LED Matrix and and ESP8266 (Arduino)
C++
19
star
30

Nunchuck-Arduino

18
star
31

arduino-alarm-clock

C
18
star
32

ESP8266-WOL-From-Telegram

A device for triggering the WOL magic packet from Telegram
C++
18
star
33

arduino-sample-api-request

C++
16
star
34

youtube-livestream-arduino

C++
16
star
35

ESP32-Cheap-Yellow-Display

Building a community around a cheap ESP32 Display with a touch screen
C
15
star
36

Spotify-Diy-Thing

Something similar to the Spotify Car Thing, built with a cheap ESP32 Screen
C
13
star
37

arduino-way-home-meter

A project for displaying the live travel time home considering traffic. Built with an ESP32
C++
12
star
38

Esp8266-Kitchen-Counter-Lights

C++
12
star
39

Simple-Home-Automation-With-Telegram

C++
10
star
40

Brian-Lough-Hardware

A general keep all for some info and files related to the hardware side of what I do
10
star
41

ArduinoDiySocialCounter

An Arduino Device that fetches and displays social media stats from several different sources
Arduino
9
star
42

arduino-facebook-api

A wrapper around the facebook api for arduino
C++
9
star
43

C920-Arduino-Control

Controlling a Logitech C920 (focus) using an Arduino
JavaScript
8
star
44

Dual-Core-ESP32-Examples

C++
8
star
45

Spotify-NFC-Matrix-Display

C++
8
star
46

arduino-hackadayio-api

C++
7
star
47

Temperature-Night-Light

C++
7
star
48

Talking-Unicorn-Bluetooth-Speaker

Converting a Christmas decoration into a bluetooth speaker using an ESP32
C++
6
star
49

simple-esp8266-software-serial-sketch

A sketch the passes inputs and outputs from the hardware Serial connection to a software serial connection and vice versa
Arduino
6
star
50

Immersion-Bot

A Telegram bot running on an ESP8266 based arduino that turns on and off my Immersion (water heater)
Arduino
6
star
51

SubscriberCounterFarewell

Farewell Subscriber Counters
C
6
star
52

Morals-Are-Optional

Cards Against Humanity clone created using LibGDX and More Controllers Please
Java
5
star
53

D1-Mini-TFT-Shield

A shield for the ESP8266 D1 Mini board with a ST7789 Colour TFT screen
C
5
star
54

F1-Arduino-Notifications

C
5
star
55

file-fetcher-arduino

A library for getting files or images on arduino based boards (ESP mainly, maybe others)
C++
5
star
56

arduino-external-web-interface-examples

Example sketches demoing using external web interfaces for communicating with your Arduino
Arduino
5
star
57

PCB3

A Christmas Tree Shaped PCB using an attiny13 with Arduino
C++
4
star
58

WiFiControlledRCCar

Adding WiFi controls to a cheap toy car
Arduino
4
star
59

SmarterEveryDayMatrix

C
4
star
60

ArduinoCryptoCoinDisplay

Arduino project for displaying crypto currency values
Arduino
4
star
61

CheckArgos.com

PHP based website for checking stock in every Argos store in Ireland at once
PHP
4
star
62

WiFi-WFH-Indicator

C++
4
star
63

universal-arduino-telegram-demo

Arduino
3
star
64

pinocchio-arduino-telegram-library

A Telegram library for Arduino that got no Strings to hold it down
C++
3
star
65

ArduinoCommuteChecker

An Arduino device that fetches live traffic data from google maps an lights up the fastest route
Arduino
3
star
66

Arduino-Printing-Animation

A library for creating a 3D printer style animation on Adafruit GFX displays
C++
3
star
67

Playscape

Entry for Derry Gamecraft 2013
Java
3
star
68

D1-Mini-Testing-Jig

A test jig for D1 mini shields
3
star
69

Power-BLough-R-Tester

Automated tester project for the Power BLoughR devices
C++
3
star
70

tindie-puppeteer

Puppeteer automation of Tindie.com - For automatically marking things as shipped.
JavaScript
3
star
71

Bridge-Traffic-Display

Arduino
2
star
72

arduino-instructables-api

An Arduino library for using the unofficial Instructables API
C++
2
star
73

arduino-tindie-telegram-notify

An Arduino sketch that checks tindie for new orders and sends a message to Telegram when a new one arrives
C++
2
star
74

Hackaday-Unconference-ESP32-Demo

How many APIs can you squeeze on one ESP32 (probably too many)
C++
2
star
75

D1-Mini-Screen-Breakout-Examples

Some example sketches for the D1 Mini Screen Breakout I sell on Tindie
C++
2
star
76

Random-Work-In-Progress

Somewhere to dump stuff that im not sure where it belongs
C++
2
star
77

crowdsupply-tp-scraper

A scrapper for getting details on a crowd supply campaign
JavaScript
2
star
78

esp32-gamepad

C++
2
star
79

Arduino-Ikea-Kitchen-Mod

C++
2
star
80

MoreControllersPlease

A tool to allow devices to connect to your game via a web browser
Java
2
star
81

Tetris-Twitch-Follower-Display

Displaying Twitch followers on a RGB led matrix using falling Tetris blocks. Uses an ESP32
C++
2
star
82

Universal-Telegram-Learn-Guide

Adafruit Learn Guide for the Universal Arduino Telegram Library
Arduino
2
star
83

ESP32-Trintiy-Web-Flash

A collection of projects that can be flashed directly to your Trinity directly from the web browser.
HTML
2
star
84

arduino-kickstarter-stats

An arduino library for fetching stats on Kickstarter projects
C++
2
star
85

an-post-pupeteer

A Pupeteer script interacting with An Post's website to automate orders.
JavaScript
2
star
86

pushsafer-arduino-library

C++
1
star
87

Brews-Clues

Coffee Buddy
Java
1
star
88

tindie-api-arduino

An Arduino library that wraps the Tindie.com API
C++
1
star
89

arduino-web-speech-api-example

Examples of using the WebSpeechApi Javascript library with an ESP8266
1
star
90

D1-Mini-HID-Shield

Info & examples for the D1 Mini HID Shield
1
star
91

Bluetooth-Arduino-Camera-Trigger

Arduino
1
star
92

Arduino-Snake-Nunchuck-Matrix

Snake running on an RGB LED matrix using a ESP32 and a Wii Nunchuck
C++
1
star
93

Better-Chris

Piano teaching Aid
1
star
94

external-web-interfaces-arduino

HTML
1
star
95

ClappyBird

You know
Java
1
star
96

ArduinoQuizSystem-FrontEnd

TypeScript
1
star
97

BoundinBacon

Pig racing game written in LibGDX
Java
1
star
98

arduino-coinlib-api

Get Crypto currency prices directly on your arduino (ESP8266, ESP32 etc)
C++
1
star
99

arduino-reddit-api

Wrapper for the Reddit API for Arduino
C++
1
star
100

blough-arduino-esp8266-starter-kit

A really cheap arduino starter kit using an ESP8266
1
star