Saltar a contenido

Connecting a Telegram bot

Connecting the bot to your server opens up the following possibilities for system users:

Integration with Telegram

For more details about the features that are available after integrating with Telegram , see related article.

Connecting

Creating a bot

The first thing you need to do is create your own bot in Telegram. To do this, go to bot builder @BotFather and click Start.

Next, run the command /newbot. Chat will ask you for a name and ID for your bot. Use your company name and postfix Getscreen.me.

After creating the chat will give you identifier and token for integration with the bot:

Bot configuration

Now you need to bind the domain name and configure webhooks for the bot.

Domain name

Follow the steps below:

  1. Send a chat command /mybots and select the bot you just created.
  2. Go to Bot Settings Domain Set Domain
  3. Specify the domain name of your server

Webhooks

To set the webhook you need to go in your browser (you can CURL or WGET) to the following link:

https://api.telegram.org/bot<bot-id>:<bot-token>/setWebhook?url=https://<your-domain>/webhook/telegram/<bot-id>:<bot-token>

Where:

  • <bot-id> is the ID of your bot
  • <bot-token> - your bot's token
  • <your-domain> - domain of your server

If done correctly, you will get this answer:

{"ok":true,"result":true,"description":"Webhook was set"}

Configuring the server

Now you need to specify the parameters of the bot in the configuration of the main server.

In the /opt/getscreen/server/config.json file, add the following section:

"integrate": {
  "telegram": {
    "name": "<bot-name>",
    "id": <bot-id>,
    "token": "<bot-id>:<bot-token>"
  }
}

where:

  • <bot-name> is the name of your bot
  • <bot-id> - identifier
  • <bot-token> - token
  • <your-domain> - domain of your server

Server restart

For the configuration changes to take effect, restart the server:

cd /opt/getscreen
docker-compose restart

Done! 👍

Check

A link to your bot should appear on the integration page in your personal account:


Last update: July 12th, 2024