

In this tutorial, we'll use IntelliJ – there are several free, open source alternatives like Eclipse or NetBeans which work in the exact same way.

To program in Java you'll need an IDE – a special text editor that will let you write, compile and run your code. Make sure to save your token in a secure place, treat it like a password and don't share it with anyone. Your token will look something like this: 4839574812:AAFD39kkdpWt3ywyRZergyOLMaJhac60qc Each bot has a unique token which can also be revoked at any time via a token is as simple as contacting issuing the /newbot command and following the steps until you're given a new token. In this context, a token is a string that authenticates your bot (not your account) on the bot API. Getting Readyįirst, we will briefly cover how to create your first project, obtain your API token and download all necessary dependencies and libraries.įor the purposes of this guide, a copy of the bot you will be creating is also live at – feel free to check it out along the way to see how your own implementation should look after each step. If you pick another language, equivalent examples are available in C#, Python, Go and TypeScript. Since Java is fully cross-platform, each code example will work with any operating system. We will use Java throughout this guide as it's one of the most popular programming languages, however, you can follow along with any language as all the steps are fundamentally the same. If you know how to code, you'll fly right through each step in no time – and if you're just starting out, this guide will show you everything you need to learn. While this can work for simple requests like the example above, it's not practical for larger applications and doesn't scale well.įor that reason, this guide will show you how to use libraries and frameworks, along with some basic programming skills, to build a more robust and scalable project. In theory, you could interact with the API with basic requests like this, either via your browser or other tailor-made tools like cURL. After obtaining your token, try pasting this string into your browser: Since your browser is capable of sending HTTPS requests, you can use it to quickly try out the API. There are several types of requests you can make, as well as many different objects that you can use and receive as responses.

At its core, you can think of the Telegram Bot API as software that provides JSON-encoded responses to your queries.Ī bot, on the other hand, is essentially a routine, software or script that queries the API by means of an HTTPS request and waits for a response.
