You can create bots in Python using the lil’bots Python runtime. When creating a new bot, select the Python runtime in the multiple selectio menu to create a Python Bot.

The script.py file & the main function

The entrypoint to your bot is the script.py file, as specified under the “main” property in the botspec.json file. When your bot is executed it will look for an exported main function in that file and call it.

The main function can be asyncrounous (to let you use await inside) and recieves the three following arguments:

  • inputs (object) - the inputs passed to your bot by the user.
  • params (object) - the parameters configured by the the user for your bot.
  • accounts (array) - an array containing all the requested account credentials for your bot to use.

A basic main function will look like this:

def main(inputs, params, accounts):
    # Your code here...
    return {
        "message": "Hello World!"
    }

Installing dependencies and packages

You may use external packages in your bot. To do so, simply import any package you need in your script.py file. When your bot is executed, the runtime will automatically install all the packages you imported using pip and make them available to your bot.

Lil’bots uses pipreqs to automatically detect the packages you use and install them.