open20/open20-telegram

There is no license information available for the latest version (1.0.0) of this package.

Open20 Telegram

1.0.0 2021-10-04 08:51 UTC

README

Plugin description

Installation

Add module to your main config in backend:

<?php
'modules' => [
    'telegrambot' => [
        'class' => '\open20\telegram\Module',
        'botToken' => 'YOUR_BOT_TOKEN'
],
Setup Your Bot’s Telegram Profile

The first step in creating a Telegram bot is setting up the profile that the bot will ultimately stand behind.
This is also how you get a token for the Telegram API.
To set up a new bot profile, log in to your Telegram account and start a conversation with the BotFather (@BotFather), 
an official account that allows you to create and manage bots. In that conversation, enter the /newbot command.

The BotFather will ask you to choose a display name and username for your bot. The username has to end in “bot” and must be unique.

Create a Webhook for Your Bot

The next step in creating a Telegram bot is setting up the webhook that will communicate with your bot. 
Webhooks are how APIs tell you that something has happened, which stops you from having to query the API every 
few minutes (or seconds) to find out whether, for example, a new message has been sent.

Telegram uses just one type of webhook, which sends you an update object whenever anything happens.

Setting up the webhook is incredibly easy. There are just two things you need to know: your API token 
(you should have this from step one) and the URL where you’ll be hosting your bot. The URL will be something 
like https://yourdomain.com/yourbot.php. Make sure that you include the https at the start of the URL; otherwise, Telegram won’t send the webhook.

Now, in a regular web browser, navigate to https://api.telegram.org/bot<yourtoken>/setwebhook?url=https://yourdomain.com/yourbot.php. 
Voila, your webhook is now up and running!