📖Opening WrangleBot
Learn how to start the WrangleBot engine
To start the WrangleBot engine you must require or import WrangleBot, depending on your NodeJS dialect. Make sure NodeJS is installed on your development environment. Install the LTS or current version of NodeJS.
Installing
Create a folder at your desired working location. cd into it and run npm init and follow the instructions in the console. Now use this command to install wranglebot and it's dependencies.
npm install wranglebotImporting the Library
WrangleBot exposes it's application programming interface (API) on the modules default export. The general convention is to call the interface wranglebot or wbot when you import it to your script, but you can also call it pretty, I'm sure it won't mind some flattery.
CommonJS
const wranglebot = require("wranglebot");ES
import wranglebot from "wranglebot"Typescript
WrangleBot has d.ts files and exposes those for you convience. If you need to import the class to type you can use the named export.
import { WrangleBot } from "wranglebot"Connecting to a Cloud Sync Database
Create a new Javascript file called index.js and copy the code into your editor. You will need an API token that is connected to one of your databases. You must register an account at https://wranglebot.io/register or look up your existing tokens in your account page.
Opening WrangleBot Engine with >v7.2.0
wranglebot.open({
vault: {
token: "<CLOUD_SYNC_DATABASE_TOKEN>",
sync_url: "<CLOUD_SYNC_DATABASE_URL>",
ai_url: "<CLOUD_SYNC_MACHINE_LEARNING_URL>",
},
port: 3200,
secret: "<VAULT_JWT_SECRET>",
//optional
mail: {
host: "<SMTP_HOST>",
port: "<SMTP_PORT>",
auth: {
user: "<SMTP_USER>",
pass: "<SMTP_PASS>",
},
},
})Opening WrangleBot Engine with <v6.4.0
wranglebot.open({
client: {
database: {
cloud: {
token: "<YOUR_DATABASE_TOKEN>", //get at https://wranglebot.io/register
databaseURL: "https://db2.wranglebot.io", //set to official node
machineLearningURL: "https://ai.wranglebot.io", //set to official node
},
},
port: 3200 //hosts the server on this port, e.g. localhost:3200
}
})Loading an Offline Database
If you do not want to use the cloud features, you can provide the local settings object to start a offline database. Do the same as above an copy the script into your index.js.
Opening WrangleBot Offline Mode with >v7.2.0
Omit ai_url and sync_url in the vault parameter.
wranglebot.open({
vault: {
token: "<DATABASE_TOKEN>"
},
port: 3200,
secret: "<VAULT_JWT_SECRET>",
//optional
mail: {
host: "<SMTP_HOST>",
port: "<SMTP_PORT>",
auth: {
user: "<SMTP_USER>",
pass: "<SMTP_PASS>",
},
},Opening WrangleBot Offline Mode with <v6.4.0
wranglebot.open({
client: {
database: {
local: {
key: "<YOUR_DATABASE_NAME>" //can be any alphanumeric string
},
},
port: 3200 //hosts the server on this port, e.g. localhost:3200
}
})That's it! Start your script with node index.js You should now see the following your console:

Give WrangleBot a moment to boot up, if you are connecting to a fresh database, you will see a message similiar to WrangleBot listening on port 3200 and another which will say 0 libraries loaded. At this point WrangleBot is done loading and is ready to be used.
If you are starting from a active database you will need to wait until WrangleBot has rebuilt all MetaLibraries to memory. Monitor the console until you see the x libraries loaded message.

Last updated
Was this helpful?