Cover image for Twitter Bot In javascript and Nodejs

Twitter Bot In javascript and Nodejs

hj profile image OccludeJS Updated on ・3 min read

Bot sounds awesome when spoken from a Developers's mouth, believe me, you can easily make it for yourself, and begin to Deb on Twitter

This will be a very simple bot to make and here are some previews of the bot performing. βš™οΈβš™οΈ

Do check out this roadmap to become Full statck developer in my GitHub and follow me out thereπŸ¦„;
Alt Text

Link to the roadmap

GitHub logo 8bithemant / Mindmap-Full-Stack

This is A roadmap or you can spell it mindmap for Developer's , this is for frontend and Full stack developer , all the people who belive in them and want to grow faster can work with this mindmap.

Mind Map For Full Stack/ Front End Developers In 2020

##Front End MindMap




##Full Stack MindMap


##Full Stack Mind Map.

Back End -Full Stack(image)

Dedicated Front End Mind Map.

  1. Junior Frontend Developer Junior Frontend Developer (image)

  2. Middle Frontend Developer Middle Frontend Developer (image)

  3. Senior Frontend Developer Senior Frontend Developer (image)

This content is distributed under CCA v3 license: https://creativecommons.org/licenses/by/3.0/deed.en (added a note to the original repo).

Frontend From: https://github.com/ivan-kleshnin/frontend-mindmaps

And BAckend from: https://github.com/kamranahmedse/developer-roadmap

Alt Text

Here is the preview of the Twitter bot promoting my github,😼

If you loved the way I promote, do follow me on Github;

Alt Text

Here is the preview of the Twitter Bot retweeting the Tweets with tag.


Complete Code Will Be Available 
on Github do Check out.πŸ™…πŸ”§

About Me

Hey, Devs,
Hemant on the other side 😼, I am an 18 year old Developer and I love System designing, Frontend Development, and Backend as well.β€οΈπŸš€πŸš€πŸš€

πŸ”§Begin With BotπŸ”§

Here is the complete code below of the twitter bot, in case you need help contact me.

GitHub logo 8bithemant / Twitter-Bot

This is a powerful twitter bot which can retweet, send direct message and puerly built in JavaScript, This bot can reply with motivation. Built with NodeJs, ❀️ and πŸ¦„

Sorry this bot is Very Unstable....................................... Constantly updating the bot

Make sure to follow me on github and star your favourite repo on github (🌟) πŸ™…πŸ’β€β™‚οΈ.

Pre required Knowledge πŸ’β€β™‚οΈ

  • Javascript 🌟
  • NodeJS 🌟
  • API's ✨
  • Twitter Policy πŸ’«

We Are HopeFully Good To Go And Build Our Twitter BotπŸ’₯

Step 1 β€” Getting our OAuth and API keyπŸ’¬πŸ’¬

Log-In to Twitter with your account you want to turn into a bot, remember don't try with your main account into twitter.

Now visit Twitter Developer console, here is the link in case to help you: Click Here.

1. Simply create an account there, remember to click on making a bot.
2. Click on create a application.
3. Make a new application.

Remember to set Permissions to 'Read and Write'

4. Get the following from the Keys section.


Step 1 is successfully completed.

Step 2 β€” Creating Our Bot

1. Create Node Application

Simply type following commands in your folder logged in terminal

npm init

Next, create an index.js .env file and an src folder in the same.

then create 2 files in the src folder, this will be the order.




After that add the following keys in the .env file.

Now setup config.js file with following code.


module.exports = {
  twitterKeys: {
    consumer_key: process.env.TWITTER_CONSUMER_KEY,
    consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
    access_token: process.env.TWITTER_ACCESS_TOKEN,
    access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
  twitterConfig: {
    queryString: process.env.QUERY_STRING,
    username: process.env.TWITTER_USERNAME,
    blacklist: process.env.USERNAME_BLACKLIST,
    tweetTimeOutMin: process.env.TWEET_TIME_OUT_MIN,
    tweetTimeOutMax: process.env.TWEET_TIME_OUT_MAX,
    tweetQueueTime: 1000 * 60 * process.env.TWEET_QUEUE_TIME

This is the setup of the keys which are lifted from the .env file

Now setting up the main file ie. bot.js

We will need to add the following modules


To install the following modules simply run the code below
npm i --save twit node-schedule dotenv

Add the following code to you bot.js fileβš™οΈπŸ€–

Alt Text
Alt Text
Alt Text

In this step, we simply made our bot by importing the keys from the config.js file

We made a configuration of a twit and in line 19 we added to q ie query and I set it up to #100DaysofCode you can set It to your favorite one.
In next step we send a get and post request by npm twit module, which tries a search of tweets with the query and then, it retweets
Now we made a Github tweet and setup of node scheduler to retweet the message in 11:59 and it will get updated twice a day.

Final StepπŸš€πŸš€πŸš€

Add following code to your index.js file


Step 3β€” Running the bot live on server

Simply hit the following command

node index.js

Boom Check the Terminal updating in every 30 sc with the message of the retweet.

Hope you all enjoyed the project ideas❀️,

Please like the post and react with ( ❀️ 🧧 πŸ¦„ )

Do remember to follow me on github I share stuff related to javascript and react there

My github: https://github.com/8bithemant

Thank you for reaching the post!

Posted on by:


markdown guide