[Telegram Bot Tutorial - Part 1] Preparation for creating a telegram bot
Preparation for creating a telegram bot
Click here if you didn't see my last tutorial (Part 1)
Now, you should installed Node.js and already have a Telegram account. Before the actual coding part of the bot, we will need to do some preparation before coding our bot.
Getting the Bot Token
- Click this to pm Bot Father or PM
@BotFather
in Telegram - Send
/newbot
to Bot Father
- Send the name of you bot to Bot Father, in this example, My Bot name is
Steem Tutorial
- Send the username of the bot to Bot Father, Remember the username must end with "bot", In this exmaple, the username of my bot is:
steemtutorialbot
- If you created the bot successfully, you will receive this message:
- Done !
Remember, do not tell others the Bot Token of you bot. Bot Token is just like your Wallet's private key, if you told others, they can access your wallet.(in this case, telegram bot). So Don't tell others the Token of your Bot!
Installing Editor and Node.js Module
After the boring part of getting the bot token, now we are going to do some preparation before coding our bot.
Editor
I prefer you install Visual Studio Code to edit your code, Visual Studio Code is a free and open source code editor built by Microsoft.
Other preferred Editor:
If you don't want to install any of them, you can still use the default editor on your operating system :)
After you have your editor ready, now we can now prepare our workspace !
(I will use Visual Studio Code for the following tutorial)
Prepare workspace
Open Visual Studio Code
Drag the folder you created to Visual Studio Code
Click this button to create a new file
Then type
index.js
as the file name, and double click the file to open it.Open the Console By following this screenshot:
You will now see a console pops up on the bottom of the Visual Studio Code, then Click the Terminal on the console:
Type
npm init
and just keep pressing enter until it ask you if this is OK, then typeyes
, and then press enter.
(This step is typing the information of your project, the name, version and description of your project. These information is useful if you are going to share your code on github, since we are just trying to create our first bot, we will just skip that.)
npm init
is a command to initialize our project in the current directoryNow we are almost ready to go, last thing is to install a Node.js module to interact with our Telegram bot. Type
npm install --save node-telegram-bot-api
on your console. Then you will see this message if you successfully installed it.
(There are different Node.js modules for you to interact with your telegram bot, node-telegram-bot-api is the one we will be using in this tutorial)Done !
We now finished the preparation of our bot :) We will start coding in next tutorial, stay tuned !
Good job elite
Congratulations @itdog! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
You published your First Post
You made your First Vote
You got a First Vote
Award for the number of upvotes received
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard: