Skip to content

Matrix bot

Matrix is a decentralyze messaging app. It can be used to control the bark monitor. The bot is bot is based on nio-bot

Follow the get started tutorial of nio-bot and do not forget to install libolm and libmagic. To work the matrix bot needs your homeserver, user name, and password. Sadly, it doesn't seem to work with the access token.

An example of the Matrix bot section in the parameters would look like this:

"matrix_parameters": {
    "py/object": "bark_monitor.cli.get_param.MatrixParameters",
    "homeserver": "https://homeserver.org",
    "user_id": "user_id", // Without the @ and the homeserver after
    "password": "PASSWORD"
},

The matrix bot and the bark monitor can be started with python bark_monitor/cli/matrix/yamnet_record.py --config-file path_to_config_file.json or by typing the command with the arguments.

Then by starting a conversation with the user_id (don't forget to accept the request on user_id's side), you can get use the matrix bot.

The bot above runs on your Pi and needs its own Matrix account. With the hosted cloud, one operator-owned bot serves every user instead: you DM the bot with your existing Matrix account, and notifications and control flow through the cloud you are already paired with. No bot account, credentials, or bot process on the device.

On the device, record with:

bark-monitor-cloud-record --config-file path_to_config_file.json

(which needs a paired cloud, same as bark-monitor-cloud-pair).

To link your account to the bot, open a DM with the bot and send:

!register <pairing code>

The pairing code comes from the dashboard: open the Notifications tab and click Generate a pairing code (or Devices → New pairing code). The code is not consumed by the registration — the device can still pair with it (if it has not already).

The DM then accepts:

  • !stop, !start, !pause, !unpause — control the recorder (optionally with a device name when you have several). Commands apply within a round-trip; if the device is offline they are queued and expire after BARK_CLOUD_COMMAND_TTL_SECONDS (default 600s).
  • !status — device online/offline, last event, barking per day (computed from the verified cloud mirror).
  • Bark notifications — one coalesced summary at most every BARK_CLOUD_MATRIX_NOTIFY_MIN_INTERVAL_SECONDS (default 300s), so a barking dog does not spam your room.

Running the bot (server operator, once):

BARK_CLOUD_MATRIX_HOMESERVER=https://your-homeserver.tld \
BARK_CLOUD_MATRIX_USER_ID=@bark:your-homeserver.tld \
BARK_CLOUD_MATRIX_PASSWORD=... \
python -m bark_monitor_cloud.scripts.matrix_bot

Install the extra first: pip install bark-monitor-cloud[matrix] (or add niobot to the environment). Any Matrix homeserver works; a self-hosted Tuwunel instance is the lowest-latency option when it runs next to the cloud. The bot is a separate process sharing the cloud's database — run it on the same host as the API server.