NodeJS Steemit Bot Tutorial

in #javascript7 years ago (edited)

This tutorial will get you started with building bots for Steemit using JavaScript/Node.JS/NPM/GitHub/Command Prompt/Sublime in Windows 10. The user should be a novice or intermediate web/software developer. It does not require any prior knowledge working with JavaScript/Node.JS/GitHub or Steem. However, you will need to create GitHub and Steemit accounts. This tutorial will be exhaustive covering in detail each step along the way. If you already have Node.JS and GitHub installed on your Windows 10 machine, then you may want to skip Step 1 and 2. You may want to start with my easier introduction at https://steemit.com/steemit/@money-dreamer/creating-first-steemit-bot if this exceeds your abilities.

##Step 1: Install & Set-up GitHub

Download the GitHub software for Windows by visiting https://desktop.github.com/ and clicking “Download for Windows”. Most PC's are 64bit these days.

Launch the MSI installer from the bottom of the browser after it finishes downloading. You will see this window while it is being installed:

If you do not already have a GitHub account, now is the time to create one. GitHub has a very elegant and pleasant GUI.

Otherwise, continue with signing in to your GitHub account:

Enter your GitHub username and password:

Enter in your 2FA (2-Factor Authentication) here:

You will now need to clone the demo repository from https://github.com/AdamCox9/Steemit-NodeJS-Bot-Tutorial by clicking the “Clone a repository” button from within the desktop app:

Select “Clone a Repository”, then select the “URL” tab. Next, visit the URL https://github.com/AdamCox9/Steemit-NodeJS-Bot-Tutorial.git and click the Fork button. This will create a forked version of the demo so you can start making your own customization:

Once you fork the repository to your own GitHub account, copy the URL from the GitHub web page by clicking the green “Clone or download” button. Make sure your username is showing instead of 'AdamCox9' and click the copy button on the right of the URL:

Paste that URL into the field and click the big blue “Clone” button. You can change the Local Path if you desire but it is not required. Take a note of it so you don't lose it later on.

FYI, GitHub will be installed to C:\Users\8d8ap\AppData\Local\GitHubDesktop replacing 8d8ap with your Windows username.

##Step 2: Install & Set-up Node.JS/NPM (Node Package Manager)

Download the stable version of Node.JS installer from: https://nodejs.org/en/ As of writing this article it is version 8.9.3 LTS:

Click the MSI installer from the bottom of your browser after it downloads. Click Next to follow the Node.JS Setup Wizard.

Agree to the terms and click Next:

Install NodeJS to the default Destination Folder:

Leave all values at their default by clicking Next:

Finally, click the Install button:

Wait for the setup to finish:

NodeJS installation should complete:

To test that it has been installed search for cmd in the Start Menu to open the Command Prompt. Type the Node command with -v option to get the version node -v. It should look like:

Change directory in the Command Prompt to the GitHub folder containing the Steemit-NodeJS-Bot-Tutorial repository with the cd (change directory) command:

Let's get the latest steem package from NPM (details: https://www.npmjs.com/package/steem ) by typing the command npm install steem --save It might look something like. Ignore the warnings.

Now that you have the GitHub repository cloned and NodeJS setup on your computer, lets get started with building the bot.

##Step 5: Install Sublime Text Editor. This is only recommended since you can use any browser that you choose. It can be downloaded from https://www.sublimetext.com/


Open the EXE file and follow the steps presented:

Install to default location:

Check the “Add to explorer context menu” so that you can right click a file and open it with Sublime directly:

Click the Install button:

Click “Finish” to exit the Setup Wizard:

Here is a sample program that casts a vote for my prior post “Creating First Steemit Bot” https://steemit.com/steemit/@money-dreamer/creating-first-steemit-bot

var steem = require('steem');
var username = 'ENTER_USERNAME_HERE';
var password = 'ENTER_PASSWORD_HERE'; 

var wif = steem.auth.toWif(username, password, 'posting');
steem.broadcast.vote(wif, username, 'money-dreamer', 'creating-first-steemit-bot', 10000, function(err, result) {
    console.log(err, result);
});

Open the directory containing the Steemit-NodeJS-Bot-Tutorial folder containing the 'start.js' file. Use Sublime Text Editor to edit the 'start.js' file by right clicking it and selecting 'Open with Sublime Text':

Add your username and password where it says 'ENTER_USERNAME_HERE' and 'ENTER_PASSWORD_HERE', respectively:

Do not share your password with anybody and do not commit it to GitHub as that will publish it. You can verify that your vote went through by visiting https://steemd.com/@money-dreamer Your response should look like the following image:

Step 6: Upvote, Resteem, Follow and Wait For My Next Tutorial

Feel free to ask any questions or give any advice in the comment section below!

Sort:  

O wow, it is really helpful. Lately I was looking for something like this and thinking If I could do that on my own and look I found it.
Thank you so much for your contirbution. Definitely I am gonna give it a try.

Did you get it working?

Here is a list of my more recent posts:

https://steemit.com/steem/@money-dreamer/summary-of-technical-articles

I add links there in comments when I release new content.

hey @money-dreamer , thanks again for all these tutorials, I am slowly working through each one of these (already completed the easiest one) ... however i am stuck at the " npm install steem --save" command .. it always says "The command npm is either written falsely or could not be found" ...

Strange. What OS are you using? Try uninstalling NodeJS and then installing it again. I am not sure how to troubleshoot if this does not work. I have never seen that before.

On a Windows 10 64 bit ... I might have done some mistakes before? Is there a way I could check each step to ensure that I did everything correct?

Did you change to the directory where the files from GitHub were checked out to in the command line?

Try these commands:

dir
pwd
cd path/to/folder/file

I hope this helps.

Thanks a lot for this detailed post, I want to ask how can we make our bot run 24/7 without keeping my pc 24/7 on? I have made a droplet on digitalocean.

If it is Linux, you will want to set-up a Cron job to execute a script every time period. There are some good articles about it on Google.

I am getting error in my node.js bot deployment, can you help me? plz give me your discrod link.

What is the error? I don't use discord that often.

Thanks a lot for replying me brother. Thank God, the bot is now running but I don't know how to make API bids url so I can add it to steembottracker website, I have a registered domain, I will be thankful if you can help me ♥

I don't think my bot does what you are trying.

Hi! Thank you for great work. I am wondering if you know what is the command (function, method) for reestim a post. How to take user's post and reestim it automatically. Thanks!

All of the methods are listed here: https://github.com/steemit/steem-js/tree/master/doc

I don't see nothing about re-steeming there. This is a very good question.

Really cool, well done @money-dreamer, I will definitively try it ~

Спасибо!

Great post,thanks for the information,very useful indeed.Thanks For sharing.

I'm glad you found it useful. I will be making some more practical examples soon.

Hey I'd really love to chat with you on discord or something I keep seeing this error saying ";" is expected
ERROR 800A03EC
Whenever I try to run any of the scripts

I don't see it missing the semicolon is missing. Did you enter your username and password?

No I just didn't understand that to run it you used "node (command)" at first
I really appreciate what you do! I did have an issue with the memo send, where for some reason I can only send 0.001 and anything else doesn't work in your follow bot setup

Update the config file for the amount you want. That is for the https://github.com/AdamCox9/Steemit-Follow-Bot

Coin Marketplace

STEEM 0.22
TRX 0.25
JST 0.039
BTC 95428.83
ETH 3314.03
USDT 1.00
SBD 3.16