How to Build Your First Telegram Chatbot with Node.js

3D ad banner ad revenue ad revenues adobe XD Advanced agency Agile Agile Development Ajax AlexW analytics Angelap angular AngularJS Animation anime.js api apollo Appsflyer Async async components Avocode axios b2b b2c baas Banner banner ad Bannersnack bawmedia bem Blogs bootstrap browser testing build process bundler Business business success Canvas & SVG career Career Advancement charting chat app chatbots ChatKit chrome chrome extension chrome extensions ciphering CloudFlare cms code challenge ColinI components content context api cross browser testing cross platform development cross-browser CSS CSS Architecture css challenge css framework css frameworks css grid css modules cssbattle.dev D3.js data visualization databases decoupled cms deep linking Design Design & UX design career design handoff dev environment DevOps diagnostic analytics digital agency digitalocean E-commerce edge computing Entrepreneur Entrepreneurship es6 eslint Expo Express FaaS Feathers Feathers.js figma framework Frameworks freelancing functions gatsby generators gitCS github API GraphCMS graphing graphql Growth Grunt Gulp headless CMS hooks HTML HTML & CSS html preprocessor HTML5 https://www.sitepoint.com/windows-linux-subsystem-2-windows-terminal IAAS Illustration ionic jade jamesh JavaScript Jest joelf jQuery jquery4u lambdatest launch checklist Layout Learn-Node-JS learn-vue linux Managed marvel MBaaS mekanism mind map mind mapping mindmapping Mobile mobile attribution Mobile Design modernjs modernjs-hub modernjs-tools monday mongodb multi-threading nest nilsonj node node version manager node-hub Node-JS-Tools Node.js nodejs noops npm octobercms online publishing PaaS Package Management package manager Percy preprocessors prettier product design Profitability Programming Pug Pusher Quasar quote builders Raw JavaScript React React Hooks React native Recurring Payments redux Resources restful api Review SaaS sass self sencha serverless computing sharing state side project siteground sketch slashdata Software specifications sponsored state state management static module bundler StudioWorks Styled Components survey sympli Tailwind task runner telegram bots Template engine Testing Themes Tools & Libraries TypeScript Ubuntu UI Design Usability user experience user research UX ux issues visual testing vps vue Vue CLI vue dev environment vue-hub vue-tutorials vue.js vuetify vuex WatermelonDB Web Web Design web hosting Web Hosting & Domains Web standards web workers webpack website builders WebSockets windows Windows Subsystem for Linux Windows Terminal women women in tech WordPress wordpress themes work workers workflow WPEngine WSL WSL2 Zeplin

So, this morning you woke up with the idea to develop a way to store and label interesting articles you've read. After playing with the idea, you figure a Telegram chatbot is the most convenient solution for this problem.

In this guide, we'll walk you through everything you need to know to build your first Telegram chatbot using JavaScript and Node.js.

To get started, we have to register our new bot with the so-called Botfather to receive our API access token.

Bot Registration with @BotFather

The first step towards our very own Telegram bot is registering the bot with the BotFather. The BotFather is a bot itself that makes your life much easier. It helps you with registering bots, changing the bot description, adding commands, and providing you with the API token for your bot.

The API token is the most important step, as this allows you to run the code that can perform tasks for the bot.

1. Finding the BotFather

The BotFather can be found on Telegram by searching for 'BotFather'. Click on the official BotFather, indicated with the white checkmark icon in the blue circle.

2. Registering a New Bot

Now we've found BotFather, let’s talk to him! You can start the conversation by typing /newbot. BotFather will ask you to choose a name for your both. This name can be anything and doesn’t have to be unique. To keep things simple, I named my bot ArticleBot.

Next, you will be prompted to input a username for the bot. The username must be unique and end in bot. Therefore, I chose michiel_article_bot, as that username was not yet taken. This will also be the username you use for looking up the bot in Telegram's search field.

FatherBot will return a success message with your token to access the Telegram HTTP API. Make sure to store this token safely, and certainly don't share it with anyone else.

3. Modifying the Bot

We can further modify the bot by adding a description or setting the commands we wish the bot to know. You can message the bot with the text /setcommands. It will show you how to input the commands with the format command1 - Description.

The post How to Build Your First Telegram Chatbot with Node.js appeared first on SitePoint.

Original Article

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.