NodeJS Steemit Bot Tutorial

in javascript •  7 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!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

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

Yeah it didn't work unless set to 0.001. Also now it doesn't work at all. Has issues with the library.js file saying result undefined from the getfollowing command. It'd worked for awhile but doesn't work for me any longer. I'd be willing to donate some SBD or STEEM for some assistance. Feel free to connect on Discord ScottCBusiness#5242

I will check it out and try to update it soon.

Thanks big ups for this project! Will show my support

Just checking in, also let's connect on Discord ScottCBusiness#5242

Finally first one I make it work. Only thing it should be added endpoint since old don't work anymore.
Great job @money-dreamer and big thanks!

I'm in the last part with the sublime text editor.
I put my username and password, but how do I run it??

Follow through with the rest of the tutorial.

What an amazing piece, exhaustive, comprehensive and practical. This really made the whole process easy. I went through every step without a hitch. Thanks so much. Looking forward to your other blogs as I progress.
I upvoted with the bot. My username is @damzylance.

Nice! Build any custom bots yet?

Yes mate. I used the bot to upvote this post

Excellent! I hope to see some customization.

The @OriginalWorks bot has determined this post by @money-dreamer to be original material and upvoted(1.5%) it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!

Thanks!

Thanks bro, its very interesting... @money-dreamer can i get help from you?

Thank you so much for making this

Very good post

  ·  5 years ago (edited)

C:\GitHub\Steemit-NodeJS-Bot-Tutorial1>node start . js
{Fetch Error: request to https://api.steemit. com failed, reason: connect ETIMEDO
UT 69.171.228.20:443
at ClientRequest . < anon ymous> (C:\GitHub\Steemit-NodeJS-Bot-Tutorial1\node_mo
dules\node-fetch\index.js:133:11)
at ClientRequest.emit (events.js:198:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'FetchError',
message:
'request to https://api.steemit.com failed, reason: connect ETIMEDOUT 69.171.
228.20:443',
type:'system',
errno: 'ETIMEDOUT',
code:'ETIMEDOUT'}undefined


This is the problem I encountered, I don't know how to solve it.

This post has received a 29.77% upvote from @lovejuice thanks to @money-dreamer. They love you, so does Aggroed. Please be sure to vote for Witnesses at https://steemit.com/~witnesses.

It was great! Thanks!