Initialize your bot
masterThere are two primary ways to initialize a Bot instance depending on your use case:
- Background Bot (Recommended for long-running processes): Initialize with a specific username and paper key. This runs an independent instance of Keybase that does not interfere with the local Keybase GUI or other logged-in users.
- Acting as the local user: Use
initFromRunningService()to connect to the existing Keybase service running on the machine. The bot will act as the user currently logged into the Keybase app. No credentials are required for this method, but the Keybase app must be logged in first.
const Bot = require('keybase-bot')
// Method 1: Background Bot
async function mainBackground() {
const bot = new Bot()
await bot.init('usernameX', 'some paper key...')
/* ... */
await bot.deinit()
}
// Method 2: Act as local user
async function mainLocal() {
const bot = new Bot()
await bot.initFromRunningService()
/* ... */
await bot.deinit()
}