[Telegram Bot Tutorial - Part 1] Preparation for creating a telegram bot

in #programming5 years ago

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

  1. Click this to pm Bot Father or PM @BotFather in Telegram
  2. Send /newbot to Bot Father
    1.png
  3. Send the name of you bot to Bot Father, in this example, My Bot name is Steem Tutorial
    Screenshot from 2018-10-07 23-32-32.png
  4. 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
    Screenshot from 2018-10-07 23-34-48.png
  5. If you created the bot successfully, you will receive this message:
    ed.png
  6. 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:

  1. Notepad++
  2. Sublime Text
  3. Atom

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

  1. Open Visual Studio Code

  2. Drag the folder you created to Visual Studio Code

  3. Click this button to create a new files.png

  4. Then type index.js as the file name, and double click the file to open it.

  5. Open the Console By following this screenshot:
    Screenshot from 2018-10-07 23-56-03.png

  6. You will now see a console pops up on the bottom of the Visual Studio Code, then Click the Terminal on the console:
    image.png

  7. Type npm init and just keep pressing enter until it ask you if this is OK, then type yes, and then press enter.
    image.png
    (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 directory

  8. Now 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.
    image.png
    (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)

  9. Done !

We now finished the preparation of our bot :) We will start coding in next tutorial, stay tuned !

Sort:  

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:

Presentamos el Ranking de SteemitBoard
Introducing SteemitBoard Ranking

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.35
TRX 0.12
JST 0.040
BTC 71539.00
ETH 3603.23
USDT 1.00
SBD 4.75