Creating your first bot
Getting started
This guide will walk you through how to create your first bot using Gears. This bot is very simple and does not require any advanced third party library to work.
We'll be using the official readline bindings so you can test the bot easily in your command-line.
Preparing
We'll assume that you know how Node.js and npm works, so create a package.json and run this command:
npm install @enitoni/gears @enitoni/gears-readline
Setting up the bot
Now that you've installed the necessary libraries, create an index.js file and put the following code in it:
const { Bot, Adapter } = require("@enitoni/gears-readline")
const adapter = new Adapter({})
// This adapter takes no options,
// but they are always required,
// so we pass an empty object.
const bot = new Bot({ adapter })
bot.start().then(() => {
console.log("Hello world!")
})
Now, if you run your code with:
node index.js
You should see "Hello world!" being logged to the console, and you should be able to input lines into the command-prompt. You've just successfully set up a working Gears bot!