How to send Telegram messages in Node JS for FREE! - Telegram Bot

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone my name is mike in this video i'm gonna show you how you can build your own telegram board in node.js before this video starts i'll really appreciate if you subscribe it helps me reach down 1000 subscribers mark so i can start monetizing my videos and invest back on this channel so without further ado let's get right in the video you want to go ahead and click that url down in the description and use will be redirected on a page like this one right here so let's see how the documentation works so you have to bring a module of course then it requires you to have a telegram bot token which i'll show you how you can get one it's really simple don't worry and then we create a new telegram bot without talking and here's two simple functions and this simple usage so one of them is a pattern so whenever you want to do a command for example you want to do slash say and something else or check something else or slash whatever you want to do and that's how that works right here so well after visiting this page you can copy this pattern right here all the whole code and if you want to do something else besides echo just remove echo and type something else that's really simple so what that does is returns us a message in a match so whenever a user matches this pattern so whenever a user do slasico and whatever this function will get triggered and as i said it will return message and match so messages the received message from telegram and much is the result of executing this pattern above on the text content of the message so when we want to respond to that user all we have to do is bot dot send message and then message right here is an object and we want to do message the chat and from the chat uh the user sends us that message we want to get that id so a chat id and then we want to do respond so right here this one responds whatever we said after slasico so it responds this year that's what much and then array1 means but we can do whatever we want here we can do like a string like down here so it's really simple again this second function what that does is whenever we send a message whatever kind of message he doesn't have to match this pattern this function gets triggered and again we have a message object and again we respond to the user by doing bot dot send message pass the chat id and then the string of the message so let's see how that works on code so go ahead and create a new folder i named my intel gum but you can name it whatever you want and we want to open command line inside our folder so after we do that our first step is to create the package the json for our node app so how we do that is doing npm init and then i'll do dash y to order and complete all those steps and we successfully did it it it really takes one to two seconds and then our next step is to mpmi in our module so i'll just copy this here but you can do it also manually so we we are doing mpmi and the name of the module right here click enter and that's it now we want to do code dot you open it on visual studio code but if you are using any other editor just open the folder to your editor now of course we want to create our javascript power node up so i'll do a new file i'll create a new file now i'll do index dot js be careful don't name it whatever you want here you have to name it exactly the same as your pocket to do json otherwise you might have some errors now of course what i'll do is copy this code right here and paste it inside my code but as you see it requires you to have a telegram broad token so let me show you how you can create one so open telegram and you want to go to search right here and search for hot bot follower and just click the one that is verified don't click all those fake ones of course so you want to see though that star with a check mark on it so click that and then you want to go ahead and start a new conversation and what we will do is slash new bot to create a new bot as you see here all right and you bought how are we gonna call it you can call it whatever you want but be careful don't use a name that is already used it will let you know though so i'll do telegram and then we can do tutorial good okay so no one got that okay that's good good now let's use our username for your boy he must send inbot okay i'll just copy this and do underscore bot sorry the username is invalid i think i just i'm not able to use that i think i have to do something like that and then i get a capital letter and again it's invalid [Music] um let's try whatever i don't really care and then botch okay we got it now as you see here it gave us it gave us a token just copy this and paste on your code and now you successfully created your own boat now what we will do is run this spot by doing node index.js in our command line and as you see we successfully run our telegram part now we will go back to telegram i'm going to search for my body as you see it tells us you'll find in ads just click that and it automatically redirects us to our bot i'll do start as you see it automatically responded to me by saying receive the message because i did slash start and as you see here in any kind of message it responds with received your message but if i do slash echo and a message it will also give us the message we type right here okay hello so yeah that's it i hope you enjoyed this video let me know down in the comments what you would like to see next
Info
Channel: Michael Kitas
Views: 11,160
Rating: undefined out of 5
Keywords: telegram bot, telegram api, telegram chat, telegram, node js, nodejs telegram, telegram nodejs, nodejs bot, coding telegram bot, telegram bot api, telegram chatbot, telegram bot node, telegram nodejs send message, nodejs telegram bot tutorial, telegram bot nodejs tutorial, telegram nodejs bot, telegram nodejs api, nodejs create telegram bot, build telegram bot nodejs, telegram chat bot nodejs, telegram bot tutorial, telegram bot access token, telegram bot token, whatsapp
Id: -utFcV1JNww
Channel Id: undefined
Length: 8min 31sec (511 seconds)
Published: Sat Jan 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.