nixcfg/systems/x86_64-linux/mx/nextcloud-claude-bot
Harald Hoyer f25aab2441 feat(bot): improve prompt-building and help command handling
- Added a default system prompt and adjusted the structure to use XML for clarity.
- Improved help command handling by simplifying triggers and updating responses.
- Enhanced NixOS configuration with support for optional custom instructions.
2026-02-03 17:39:31 +01:00
..
bot.py feat(bot): improve prompt-building and help command handling 2026-02-03 17:39:31 +01:00
default.nix feat(bot): improve prompt-building and help command handling 2026-02-03 17:39:31 +01:00
example-config.nix feat(nix): add Nextcloud Claude Bot integration 2026-02-03 15:42:56 +01:00
module.nix feat(bot): replace maxTokens with contextMessages option 2026-02-03 17:00:50 +01:00
README.md feat(nix): add Nextcloud Claude Bot integration 2026-02-03 15:42:56 +01:00

Nextcloud Claude Bot Setup

Voraussetzungen

  • NixOS Server mit Nextcloud (Talk App aktiviert)
  • Claude Code CLI installiert und authentifiziert
  • Nextcloud Talk Version 17+ (Nextcloud 26+)

1. Bot Secret generieren

openssl rand -hex 32 > /var/secrets/nextcloud-claude-bot
chmod 600 /var/secrets/nextcloud-claude-bot

2. NixOS Konfiguration

Kopiere die Dateien nach /etc/nixos/nextcloud-claude-bot/ oder in dein Flake:

/etc/nixos/
├── configuration.nix
└── nextcloud-claude-bot/
    ├── module.nix
    └── bot.py

Füge das Modul zu deiner configuration.nix hinzu (siehe example-config.nix).

3. System rebuilden

nixos-rebuild switch

4. Bot bei Nextcloud registrieren

# Als root oder mit sudo
cd /var/www/nextcloud  # oder wo dein Nextcloud liegt

# Bot secret auslesen
BOT_SECRET=$(cat /var/secrets/nextcloud-claude-bot)

# Bot installieren
sudo -u nextcloud php occ talk:bot:install \
  "Claude" \
  "Claude AI Assistant" \
  "http://127.0.0.1:8085/webhook" \
  "$BOT_SECRET"

Falls der Bot extern erreichbar sein muss:

sudo -u nextcloud php occ talk:bot:install \
  "Claude" \
  "Claude AI Assistant" \
  "https://cloud.example.com/_claude-bot/webhook" \
  "$BOT_SECRET"

5. Bot aktivieren

Nach der Installation musst du den Bot für Konversationen aktivieren:

# Liste alle Bots
sudo -u nextcloud php occ talk:bot:list

# Bot für alle User verfügbar machen (optional)
sudo -u nextcloud php occ talk:bot:state <bot-id> 1

6. Testen

  1. Öffne Nextcloud Talk
  2. Starte einen neuen Chat mit dem Bot (suche nach "Claude")
  3. Schreibe eine Nachricht

Health Check

curl http://127.0.0.1:8085/health

Logs prüfen

journalctl -u nextcloud-claude-bot -f

Troubleshooting

Bot antwortet nicht

  1. Prüfe ob der Service läuft:

    systemctl status nextcloud-claude-bot
    
  2. Prüfe die Logs:

    journalctl -u nextcloud-claude-bot -n 50
    
  3. Teste den Webhook manuell:

    curl -X POST http://127.0.0.1:8085/webhook \
      -H "Content-Type: application/json" \
      -d '{"actor":{"type":"users","id":"harald"},"message":{"message":"test","id":1},"conversation":{"token":"abc123","type":1}}'
    

Claude CLI Fehler

Stelle sicher, dass Claude CLI als der Service-User funktioniert:

# Teste als der User
sudo -u nextcloud-claude-bot claude --print "Hello"

Die Claude CLI Config liegt in /var/lib/nextcloud-claude-bot/.config/claude/.

Signature Fehler

Prüfe ob das Bot Secret in Nextcloud und im Service übereinstimmt:

# Secret im Service
cat /var/secrets/nextcloud-claude-bot

# Secret in Nextcloud (verschlüsselt gespeichert)
sudo -u nextcloud php occ talk:bot:list

Befehle im Chat

  • /help oder /hilfe Hilfe anzeigen
  • /clear oder /reset Konversation zurücksetzen

Sicherheitshinweise

  • Der Bot läuft nur auf localhost und ist nicht direkt erreichbar
  • Nur in allowedUsers gelistete Nutzer können den Bot verwenden
  • Webhook-Signaturen werden verifiziert
  • DynamicUser isoliert den Service