Arduino Tutorials

How to create a Telegram bot

Einen Telegram-Bot erstellen

If you want to control your projects or receive current sensor data from your smartphone, a Telegram bot is a handy tool.

In this tutorial you will learn how to set up a Telegram bot in a few minutes and also how to find out your User ID, which you need for many projects.

1. Install Telegram

First the easiest exercise: In order to interact with your project via Telegram, you need to have Telegram on your smartphone. If this is not yet the case, open the Play Store or App Store and install the app. Now open Telegram and create an account.

Telegram in the App Store
Telegram in the App Store

If you don’t know Telegram yet: The app is free and does basically nothing else than WhatsApp. But you have the possibility to create so-called bots.

You will be able to interact with these bots – you can, for example, send data from your ESP8266 to your smartphone and also receive commands from there, for example to switch on the lights on your breadboard. Of course, you are not limited to an ESP8266.

2. Create a Telegram bot and save your token

In Telegram now select Chats. In the upper part of the screen you will find a search field – search for Botfather here.

Search for Botfather

Open the Botfather and tap Start. After his greeting you will receive instructions. You can read them now, or tap on /newbot. After that the Botfather asks you for a name for your bot and a username.

Telegram create new bot
Assign a name for the bot and a username

After you have assigned the names, you will receive a message with your token. You will need this later in your sketch to connect your ESP8266 to your Telegram bot.

Token in Telegram
Copy your Token

This was the first part of the preparations in Telegram. One information is still missing: the User ID.

3. Find out your User ID

Open the chats in Telegram again and search there for IDBot.

search IDBot
Search for IDBot

Now tap on IDBot and in the following chat window tap on /getid. You will immediately receive a message with your User ID:

Your UserID in Telegram
Copy your UserID

And that was it with the preparations in Telegram. Keep your Token and your User ID ready to enter them later in the respective sketch of the project. And above all, keep it secret so that no one else can use your bot.

You can create these projects with your Telegram bot:

A photo trap with the ESP32-CAM

A silent alarm with ESP8266

A Dash Button with the ESP8266

You may also like

Comments are closed.