Bots are autonomous agents, built with code, that perform individual tasks for users. They can be simple or complex, and can be built to perform a wide variety of tasks.

There are several key concepts that explain how bots operate:

  • Bot Inputs: these are inputs provided by the user every time they run the bot. The lil’bots platform provides multiple input types that can be used to pass information - read more about them in the Bot Inputs document.
  • Bot Parameters: these are parameters that are set when the bot is installed, and are used to configure the bot. They are set by the user when they install the bot, and can be used to customize the bot’s behavior. They support all the same types as inputs, but unlike inputs are not meant to be customzied on every run.
  • Bot Outputs: these are the results of the bot’s work, and are displayed to the user. The lil’bots platform supports a wide variety of output types that can be used to display information to the user - read more about them in the Bot Outputs document.
  • Accounts: these are external accounts that the bot can use to access external services. They are set by the user when they install the bot, and can be used to access external services like APIs, databases, and more. You can read more about them in the User Accounts document.

Each bot on the lil’bots platform is defined using two main components:

  • Botspec File: The botspec file is a JSON file that defines the bot’s inputs, outputs, and runtime environment. It is used to configure the bot and provide the necessary information for the lil’bots platform to run the bot.
  • Bot Script: The bot script is the code that defines the bot’s behavior. It is written in JavaScript or TypeScript and contains the logic that the bot uses to perform its task.

The Botspec File

Here is an example of a botspec file:

{
	"runtime": "deno",
	"main" : "script.mjs",
	"inputs": {
		"name": { "name": "Your Name", "description": "The name of the name to greet", "type": "string" }	
	},
	"params": {
		"greeting": {"name":"Greeting", "type":"string", "enum": ["Hello", "Hi", "Hey", "Hola", "Yo"], "description": "Your Greeting", "errorMessage": { "minLength": "greeting is required" }}
	},
	"accounts": [
		{
			"provider": "google.com"
		}
	]
}

Let’s break down the different parts of the botspec file:

Runtime

This specifies the runtime environment that the bot will run in. The lil’bots platform supports the following runtimes:

Main

This specifies the main script file that the bot will run. This file contains the bot’s logic and defines how the bot will behave. It must expose a main function that takes inputs, parameters, and accounts as arguments.

In the Deno runtime, that function may return a promise (async function).

Inputs

This specifies the inputs that the bot expects from the user. Each input is defined by a key-value pair, where the key is the name of the input and the value is an object that defines the input’s properties.

You can see a list of supported input types in the Bot Inputs document.

Params

This specifies the parameters that the bot expects when it is installed. Each parameter is defined by a key-value pair, where the key is the name of the parameter and the value is an object that defines the parameter’s properties.

Accounts

This specifies the external accounts that the bot can access. Each account is defined by a key-value pair, where the key is the provider of the account and the value is an object that defines the account’s properties.