The Goal is to Add a new task on the ToDoApp and the bot reply it to all telegram users, We try to benefite from the telegram API to use it in biggest Projects
So how it works here,
- a telegram bot is created.
- the bot api is lunched (it means this bot.js script).
- some users start using the bot (when typing '/start').
- whenever a new task be added in the principale APP, the app send a POST request to the endpoint api of the bot and from it our bot send this task to all the users.
1) create you're own bot and get the token from the botFather
Go to your telegram and type on the serch : BotFather
-
Click on start
-
Type the command '/newbot'
-
Type the name of your bot e.g : HappyBot
-
Then type a unique username of you're bot like : my_happy_bot (it must ended with the word 'bot')
-
After the bot father will provide you a token for you're bot like this : 68********:AAH#####################Gw keep the key private
NOW your bot is ready to test it let's go to the implementation side :
Implementation : 2) set up you're envirenment and pull the bot.js code and the todo app and install : express, body-parser, cors, node-telegram-bot-api
Create a new folder e.g "myApp" for the app
Open the folder on VScode and run on the terminal
git initClone the bot repository
git clone https://github.com/Abdessamed2002/ToDoAppBotGet into the repo
cd ToDoAppBotThen clone the todo app repo
git clone https://github.com/Abdessamed2002/ToDoAppInstall node modules
npm install express body-parser cors node-telegram-bot-apiNow In the bot.js code replace the botToken with your key provided from botFather "68********:AAH#####################Gw"
3) run the bot on you're terminal : node bot.js
node bot.jsThis should be the result :
Tracked Users: []
Server listening on port 30004) you should have XAMPP or another local web server envirenment to lunch

5) lunch you're app on you're local bowser
localhost/php/testBot/ToDoAppBot/ToDoApp/index.phpThe App should be lunched now, then go to you're telegram account and send to the bot start command '/start'
search for you're bot by the username :

type /start and it will send you welcome!
now go to the app and make some tasks like this :

Thank's for you're time :) whish you all the best
While this app's current purpose is limited to sending tasks from the app to users, its true potential lies in larger projects. Imagine a bot seamlessly interacting with hundreds or thousands of Telegram users, saving you countless hours and resources. Forget about manually crafting chat functionalities – this bot automates it all. Focus on your core development, and let the bot handle user notifications across individual users, moderators, and even group channels. It's truly automation at its finest!

