DEV Community

nopekun
nopekun

Posted on • Edited on

Simple Telegram bot with nodejs express. Code with Termux

Hi, this my first post so yeah let's get started.

install termux
Enter fullscreen mode Exit fullscreen mode

If you already had Termux let's go to the next step.

Install node js with command

pkg install nodejs
Enter fullscreen mode Exit fullscreen mode

Then, make a new directory

mkdir bot && cd bot
Enter fullscreen mode Exit fullscreen mode

Initialize project

npm init
Enter fullscreen mode Exit fullscreen mode

Install express

npm i express --save
Enter fullscreen mode Exit fullscreen mode

Make a new index.js

nano index.js
Enter fullscreen mode Exit fullscreen mode

And this is the code

const Telegraf = require('telegraf');
const bot = new Telegraf(token);

bot.start(ctx=>ctx.reply('Samlekom Mamank'));
bot.launch();

console.log('Bot started')
Enter fullscreen mode Exit fullscreen mode

Save the code and run it with command

node index.js
Enter fullscreen mode Exit fullscreen mode

Good luck:v

Top comments (2)

Collapse
 
masalexf profile image
masalexf

Gg bang

Collapse
 
mdmarufsarker profile image
Md. Maruf Sarker

npm i express --save
This cmd is not working
Showing me a lot of error
Permission Denied, maybe need root user access.
And what happened after run node index js?