Nanobot introduction

An introduction to Nanobot, covering how to configure the agent and connect it to Telegram.

Nanobot Configuration

Nanobot is a versatile agent framework designed to automate tasks and interact with users across various platforms. This guide will walk you through the initial configuration of a Nanobot agent and demonstrate how to connect it to Telegram for seamless communication.

Step 1: Installation

To install Nanobot, follow the instructions from the official GitHub repository. This typically involves cloning the repository and installing necessary dependencies.

run the following command to initialize nanobot configuration and workspace.

1
nanobot onboard

Step 2: Configuring the Agent

Update the ~/.nanobot/config.json file. Set the provider and model you want to use. For example, if you want to use OpenAI’s GPT-5 Mini model, your configuration might look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"agents": {
"defaults": {
"model": "gpt-5"
}
},
"providers": {
"openai": {
"apiKey": "sk-proj-......",
"apiBase": "https://api.openai.com/v1",
"extraHeaders": null
}
}
}

Run the following command to test if nanobot can successfully connect to the provider and model you configured. You can directly interact with the model in the command line interface.

1
nanobot agent

Telegram Integration

You need to install Telegram first and then create a bot using BotFather to get the HTTP API Token.

Creating a Telegram Bot

  1. Open Telegram and search for @BotFather.
  2. Start a chat and send the command /newbot.
  3. Follow the prompts to choose a name and username for your bot.
  4. Once created, BotFather will provide you with an HTTP API Token. Keep this token secure.

Integrating the Token

  1. Open your Nanobot configuration file ~/.nanobot/config.json.
  2. Locate the section for Telegram integration.
  3. Paste the HTTP API Token you received from BotFather into the appropriate field.
  4. Save the configuration file.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    {
    "channels": {
    "telegram": {
    "enabled": true,
    "token": "......",
    "allowFrom": ["Your-Telegram-Username"],
    "proxy": null
    }
    }
    }

The Telegram username can be set in the Telegram settings. Click on the profile and set a unique username for your Telegram account. This is important for security reasons, as it restricts interactions with your bot to only those from your specified Telegram username.

Start the nanobot gateway.

1
nanobot gateway

You can now use Telegram to interact with your Nanobot agent. Send messages to your Telegram bot, and it will respond based on the configurations and capabilities you have set up in Nanobot.

Conclusion

With your Nanobot agent configured and connected to Telegram, you can now automate interactions and tasks directly through your Telegram bot. This setup allows you to leverage the capabilities of Nanobot while providing a convenient interface for users to interact with your agent.