Using Telegram Bot to Share Information to Telegram Channel

Telegram channel is another popular platform to connect with audiences which posts are controlled by channel owners. The Channel owner is the one responsible for providing knowledge, articles, and vital information for their subscribers. The subscriber needs to subscribe to the channel to receive that information. Normally, channel owners will write or copy/paste their content to the telegram channel for sharing, but in this post, I going to introduce you to another way of sharing information using the telegram channel.

Using Telegram Bot as a robot or messager between your Content Management System (CMS) and your owned telegram channel will provide you some benefits such as time save for posting/sharing and one-click sharing from your CMS platform.

Step 1: Create Telegram Bot

  • Let start by talking to BotFather. You can chat to @BotFather in the telegram app by sending command /start
  • To create a new bot send command /newbot then it will be asked for a new bot’s name
  • Enter a username of your bot which needed to have prefix bot
  • Finally, we will get an access token for your newly created bot

Step 2: Add this newly created bot as administrator on your telegram channel

Step 3: Installing Telegram Bot SDK to work with Laravel 7

  • Add the following code snippet into providers array in config/app.php
  • Add the following code snippet into alias array in config/app.php
  • Publish configuration of the Telegram Bot SDK to get telegram.php file in config folder
  • Configure credential getting from BotFather to env file

Step 4: Getting Channel CHAT_ID by coding since we can’t get it from the telegram app. this CHAT_ID will be used in the further processes

  • Create a controller TelegramBotController
  • Create a route to point to the controller
  • Getting CHAT_ID

Then, add this CHAT_ID to the env file too

Step 5: Sending your messages to Telegram Channel as needed with the following code

Here is the result example of Channel NestCode, you can join by click here https://t.me/nestcode168

Originally published at https://nestcode.co.

I am passionate in IT, Technology, and Coding

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store