Connecting Nanobot to Matrix

I started digging into Nanobot code to check why it cannot connect to Matrix server despite the config being correct and nanobot gateway being executed. Just in case I messed up something I did recreate entire nanobot workspace by doing nanobot onboard after removing entire directory. Did not work.

Closer inspection of the code shed some light on the problem: the config was not being used because channel was never instantiated. That part of the code was gone for some reason despite the Readme stating it is possible to integrate nanobot with Matrix.

I started to change some code to make it work. It did not seemed to complex to fix. I got it almost working but I am not great with Python, so I had some problems with tests not being green on my branch. Seemed a bit strange that I broke tests not connected to my own changes but I was unfamiliar to the repository and last time I was working with Python was around 2022 so… Who knows? Maybe I did broke it.

But then I thought ‘Hmm this seems like an obvious problem and easy fix! Maybe someone already did that!’. And it actually was true. There was PR open for this.

I was happy to run this branch so I setup virtual environment with uv that I still have somewhere around after I was playing with vllm setup. I downloaded this branch, built nanobot and rerun the gateway. Now it was able to connect to Matrix server though it still was having some issues with sending encrypted messages and had to play a bit with Matrix API to get access token for the bot.

Also I think it is a bit annoying that it reponds to all the messages in the channel. I.e. it would make sense to create root for bigger audience and to share some ideas or discuss something and having a not responding to everything would be very annoying and disruptive. It would make more sense if message would be only considered to be a propmpt when it would be mention @nanobot.

But for now I am happy with ability to chat with my new bot in my own Matrix channel and ask him to do some stuff for me.

Adding the bot to Matrix server

I have my own matrix server for my own use. Usually it is used by me a bit by my family and most of it by my own services to sent me some notifications.

Lately I started playing with nanobot. It is personal AI assistant like OpenClaw. I wanted to be able to chat with it in my own Matrix via my own phone. To do that I needed to create new user dedicated

I find it a bit confusing that there is no central web UI that allow you to do that. Ok, since privacy and security is their utmost concern maybe there did it like that so that you have to have direct control of the server that is running it. OK that is one way to do it securely but also it is a bit obscure. You have to remember where it is, how docker container is named (there are several) and remember exact command you have for run, with exact name of parameters. Since it is very rare occurrence having a need to do that (it is not like I am constantly changing users), I have a hard time to remember that.

I created snippet of bash script that need to be run in order to do that. I have matrix running on docker compose with separate directory for all the data.

# navigate to directory
cd /opt/matrix
sudo docker compose exec matrix-synapse /bin/bash
register_new_matrix_user -u newusername -p very-secure-password1 -c /data/homeserver.yaml

This creates the user. In order to connect to server as new user you still need to login. In theory it should be possible to do that via web client and extract device id and access token from the client itself. It is possible and might actually work. But it is also possible to do that via API and it is much better since you can easily regenrate that data. And you will probably need that since token that is in use will be active but if user will not be active via that token for some time it will be invalidated. And then using client will be much more inconvenient then just API call via curl for example.

Here is another bash script that retrieves access token via API:

curl -XPOST -d '{"type":"m.login.password", "user":"newusername", "password":"very-secure-password1"}' "https://matrix.domain/_matrix/client/r0/login"

Of course user name and its password need to be the same as in previous script.

This will return JSON similar to:

{
    "access_token": "QGV4YW1wbGU6bG9jYWxob3N0.vRDLTgxefmKWQEtgGd",
    "home_server": "localhost",
    "user_id": "@matrix.domain:newusername"
}

That is all. Though I am not sure how device id need to be retrieved/regenerated without some client. Or even if it need to be communicated to the server at all prior to login. Anyway one time login via client and retrieving device id from the client it is enough. I won’t change and access token can be changed via running a script again fairly easily.

Running my own AI assistant.

I recently started experimenting with my own AI asisstant. I decided to skip on OpenClaw for being massive slop of 400k LOC of vibe coded monstrosity. Looking trough web I found that there is also NanoClaw which seems much better but looks like it is tied to Anthropic service and I like owning my own data and I self host what I can.

That left me with Nanobot being my only option from bigger open source projects that are (relatively) known, are under active development and have big user base.

First I did setup do some research about possible integration of locally hosted model. Nanobot have configuration options for custom, OpenAPI compatible provider that should be fine with llama.cpp server. Also it have dedicated provider for vllm which is also compatible with OpenAI API.

I did some research to which model would be suitable to run in agentic mode and Qwen 3.5 have very good opinions. Unfortunately it is fairly new and is not integrated with all the tools yet – at the time of writing this I could not make it work with llama.cpp. This is not terrible since vllm server seems to be better choice for running a server – it is more performant and have dedicated Docker images. Also Amd have page for vllm on docker with their rocm libraries so it seemed like better choice for tests on my PC with Radeon RX 7900 XTX with 24GB of VRAM.

Qwen 3.5 did not run with vllm on its official docker images. It failed with ‘uknown’ architecture of model. I did not wanted to setup my own local environment of vllm with the latest versions of libraries because it also requires to serum AMD Radeon drivers and ROCm libraries installed – which for now is terrible experience on Debian. AMD officially supports only Ubuntu and Fedora.

Because of that I decided to run another model from Qwen family. I did some tests and:

  • Qwen 3 0.6B – was very fast but also felt a bit dumb.
  • Qwen 3 1.7B and Qwen 3 4B felt much smarter but they are still pretty small and I wanted to try bigger models.
  • Qwen 3 Next – I could not fit it into GPU.
  • Qwen 3 Coder 30B – it was running with very small context.
  • Qwen3-VL-30B ThinkingQwen3-VL-30B Instruct running image capability seemed a bit wasteful since I did not had an use case for that. Also thinking version is fun to read through the response to learn how those models operate but it is slow (because of number of generated tokens) and would be very annoying for agentic use.
  • Qwen3-30B-A3B-Instruct-2507 – felt like about right to test few things. Quntized version of it: cyankiwi/Qwen3-30B-A3B-Instruct-2507-AWQ-4bit ran pretty fast, felt capable in responses and could fit with smaller context in my 24GB of VRAM.

Unfortunatelly right now Nanobot have some problems with running on Matrix which is a bit sad since I am running my own server so it would be perfect integration. But I can always chat with it and I also setup separate email account as an alternative way of communication – I can always send an email from anywhere!

Right now I was able just to make few tests but it feels great to have my own personal assistant, virtual entity living in my own hardware, waiting for me to ask it for help!

Moving /boot partition

For a while I had a problem with my boot partition being too small. It was fine for one kernel image but not for two. So whenever kernel was updated it was failing because of lack of space. Five years ago 500MB was enough but not nowadays.

Today I decided to finally fix that.

First, I did created new LVM volume for /boot:

sudo lvcreate -L 1G -n boot root-vg

Then I mounted it and copied contents of old /boot into it

sudo mount /dev/mapper/root--vg-boot /mnt/boot
sudo rsync -avp /boot /mnt/boot

After that I edited /etc/fstab and changed old boot partition to new boot partition and then rebooted the machine.

Then I did update Grub:

sudo update-grub

Everything went well so I removed old partition as no longer necessary.

And this time PC failed to start.

Being in Grub emergency shell I managed to boot my machine by doing:

set root=(lvm,root--vg-boot)
linux /vmlinuz-6.18.9+deb14-amd64 root=/dev/mapper/root--vg-root
initrd initrd.img-6.18.9+deb14-amd64
boot

Which meant that system was fine, but Grub was misconfigured.

I tried to fix that by reinstalling grub (which according to quick web search should fix the issue) but I was unable to find an example that would work on my setup. I kept getting:

grub-install: error: cannot find EFI directory.

Finally after inspecting manpage for grub-install I did use additional switch:

sudo grub-install --efi-directory=/boot/efi /dev/nvme0n1

This did work and I was finally able to see GRUB welcome page and booted my PC just fine.

Purging smtp services from Debian

Lately I purchased mew dedicated server with intention to use it as my new running mail email server – mailcow, my blog, and some other services. When I was migrating mailcow suite everything was fine except postfix image failed to start.

I had problem like that already on Debian and usually I was dealing with that by disabling exim:

sudo systemctl disable exim.service

This was fine till major Debian update that was reinstalling exim and causing it to steal port 25 again. So this time I decided to uinstall it completely.

sudo apt remove exim4-daemon-light

This removed exim but mailcow again failed to start! To my surprise inspecting open ports shown that port 25 is being used again. This time it was service called couriertcpd. I decided to get rid of this one too, though I had to first search for the name of the package.

sudo apt remove courier-mta

And after that I did again discover that port 25 is busy again! This time exim was back!

Well I had only myself to blame since I was accepting what apt was proposing to do without actually reading the proposition of changes. Every remove of one smtp package was coming up with yet another alternative to deliver emails.

I understand that it is baked into the system that it needs local mail server for some administration purposes, but installing packages during removal is for me a bit too much.

I started to do

sudo apt purge exim4-* courier-*

and it kept with yet another and another alternative:

  • dma
  • estmp
  • mstmp
  • nullmailer
  • opensmtpd
  • postfix
  • sendmail-cf
  • ssmtp

So doing:

sudo apt purge exim4-* courier-* dma esmtp msmtp nullmailer opensmtpd postfix sendmail-cf ssmtp

finally removed all SMTP services that could steal port 25 from mailcow.

After doing small cleanup

sudo apt autoremove

that removed all unnecessary dependencies that were installed with purged mail services, I finally had free 25 port and mailcow was able to start.