Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

command.

As you start typing, BotFather will automatically suggest available commands. Click the "newbot" command. The BotFather will then ask you to provide some information for your new bot.
Once you're done giving your bot a username and a name (the username of the bot needs to end in "bot"), the BotFather will text you the unique token of your bot.
As mentioned in the introduction, this is the unique identifier of your bot, which you will need to send messages to your botit.
Copy or write down the token now, because we will need it later on when configuring Telegram for the NETx BMS Core Server.

Image AddedImage AddedImage Added


Great! You have created a custom bot.

Add the bot to your contacts and initiate a conversation

Now that you've added a custom bot, we need to add it to your contact list and initiate a conversation so that it's ready to receive messages from us.
Enter the name or username of your new bot in the search bar (both "NETxTutorialBot" in our case) and click it. The conversation opens.
Click the "Start" button to initiate the conversation and send an initial messages so that everything's set up correctly (for example "hello").


Perfect. You have initiated a conversation with your new bot. This means that it's almost ready to be used. The last step is to retrieve the chat ID, which is the unique identifier of the initiated conversation.

Retrieve the chat ID

This one is a bit tricky. As already mentioned, the chat ID represents the unique identifier of the initiated conversation between you and your bot. The reason that you also need a chat ID is,
that you could, for example, add your bot to a group conversation as well. Therefore, the bot token itself is not enough to identify where to push the message to. So in order to know where to publish messages to,
Telegram requires a combination of both the token (unique identifier of YOUR bot) plus the chat ID of a conversation (in this case, the 1:1 conversation with you and your bot).

Just to clarify: If your bot were member of a group conversation, which you'd like to publish your messages to, you would need the same token of your bot, but the corresponding chat ID of the group conversation.

To retrieve the chat ID, you need the previously noted token of your bot.

Open a web browser (for example Google Chrome), and enter the following url:

https://api.telegram.org/bot<bot token>/getUpdates

where you need to replace <bot_token> with your bot's unique token. In our example:

https://api.telegram.org/bot794823343:AAHYbhf59s0TZacUFpwrghqpUBQJOakacZ8/getUpdates

It may occur that this request won't return the desired results, which should look similar to this:

Image Added

If this happens, just send another message from your mobile phone to your bot and try it again.
If everything has been set up correctly, you should receive a JSON response containing the required chat ID, which should look similar to this:

Image Added

Write down the chat ID, in this case "569011464", because we'll need it in the next step.

(tick) Well done, you have now finished setting everything up. Now let's configure your telegram bot within the NETx BMS Core Server.

Configure your Telegram bot within the NETx BMS Core Server