# Nextcloud Talk Assistant Bridge

Safe v1 prototype for chatting with the assistant from Nextcloud Talk.

## Status

Prototype scaffold. It can:

- poll one Talk conversation
- respond only to allowed senders
- create one pending JSON draft per conversation
- support `approve`, `edit: ...`, and `discard`
- keep state in JSON
- queue approved `pi ...` / `ask pi ...` work requests to a Nextcloud file

It intentionally does **not** execute shell/admin commands or autonomously modify infrastructure.

## Commands

```text
capture <idea/note>
remind <what/when>
project note <project/details>
ticket <summary/details>
pi <request for Pi/the assistant>
ask pi <request>
move forward with <task/project>
help
status
```

Any durable command creates a draft. Reply:

```text
approve
edit: <replacement text>
discard
```

## Files on VM

Recommended layout on the Nextcloud VM:

```text
/opt/nextcloud-talk-assistant/nextcloud_talk_assistant.py
/etc/nextcloud-talk-assistant/config.json
/etc/nextcloud-talk-assistant/env
/var/lib/nextcloud-talk-assistant/state.json
/var/log/nextcloud-talk-assistant/bridge.log
```

`/etc/nextcloud-talk-assistant/env` should contain secrets and must not be committed:

```sh
NEXTCLOUD_APP_PASSWORD='...'
```

## Config

Copy `config.example.json` to `/etc/nextcloud-talk-assistant/config.json` and edit:

```json
{
  "nextcloud_base_url": "https://nc.example.test",
  "username": "assistant-bot",
  "conversation_token": "PUT_TALK_ROOM_TOKEN_HERE",
  "allowed_senders": ["deeso"],
  "poll_seconds": 5,
  "state_path": "/var/lib/nextcloud-talk-assistant/state.json",
  "log_path": "/var/log/nextcloud-talk-assistant/bridge.log",
  "dry_run_apply": true,
  "capture_file_path": "Assistant/capture.md",
  "pi_request_file_path": "Assistant/pi-requests.md"
}
```

## Local self-test

```sh
python3 nextcloud_talk_assistant.py --config config.example.json --self-test
```

## One-shot poll test

```sh
export NEXTCLOUD_APP_PASSWORD='app-password-here'
python3 nextcloud_talk_assistant.py --config /etc/nextcloud-talk-assistant/config.json --once
```

## Notes

- The Talk chat endpoint may need adjustment after inspecting the installed Talk version.
- Voice note/Whisper support is not implemented yet; first discovery step is confirming whether Talk exposes voice-message attachments via API.
