Skip to content

Latest commit

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Create your Telegram bot in Nodejs with botimize bot-analytics service

Here is our 10 min guide to create an echo-bot on telegram with botimizebot analytic service.

Installation

$npminit$npminstalltelegraf--save$npminstallbotimize

Create a telegram bot and get its token with the aid of botfather

Find botfather by ... Botfather Talk to him like this way and record your telegram token. teleToken

Create a botimize account and a key for the project

Go to botimize and create an account.

Create a new project by clicking new project.

New_project

See your YOUR_BOTIMIZE_TOKEN by clicking Project Setting

Project Setting

Create a Nodejs bot

Create a Nodejs script (e.g. echoBot.js) and copy this into it. Notice you have to replace YOUR_BOT_TOKEN, something like 123456789:AbCdfGhIJKlmNoQQRsTUVwxyZ. And also, you have to replace YOUR_BOTIMIZE_TOKEN.

constTelegraf=require('telegraf')constapp=newTelegraf(YOUR_BOT_TOKEN)constbotimize=require('botimize')(YOUR_BOTIMIZE_TOKEN,"telegram")app.command('start',(ctx)=>{ctx.reply('Welcome!')})app.on('text',(ctx)=>{// botimize incomingletincomingLog=ctx.update;botimize.logIncoming(incomingLog);// reply to userctx.reply(ctx.update.message.text);// botimize outgoingletoutgoingLog={chat_id: ctx.update.message.chat_id,text: ctx.update.message.text,token: YOUR_BOT_TOKEN};botimize.logOutgoing(outgoingLog,{parse: 'pure'});})app.startPolling()

Talk to your bot

Run on the terminal

node echoBot.js

Now you can talk to your bot! I name the bot as okokdodo you can find your bot with the bot name. okokdodo

About

telegram echo bot written in node.js, Botimize integrated!

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages