- Go 99.1%
- Dockerfile 0.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Published as github.com/surdeus/nextcloud-kanso-bot. Code lives on the Forgejo instance and go.mojosa.su
answers discovery for it, so the module path follows the code:
github.com/surdeus/nextcloud-kanso-bot -> go.mojosa.su/service/nextcloud-kanso-bot
That is what the vanity path is for: the next time this repository moves,
nothing changes for anyone importing it.
Changed: the module line and every internal import. No behaviour change.
|
||
| cmd/kanso-bot | ||
| internal | ||
| architecture.md | ||
| docker-compose.kanso-bot.yml | ||
| Dockerfile | ||
| go.mod | ||
| readme.md | ||
Kanso ⇄ Talk bot
Bridges Kanso cards into Nextcloud Talk conversations.
/kanso <card link>in a chat posts a short card summary as a bot message.- Every reply to that message becomes a comment on the card.
- ✅/❌ land on your message so you can see the bot noticed it.
Only public cards are bridged. The bot acts as one Nextcloud account, so comments appear under that account with the human's name in the text.
Design and rationale: ARCHITECTURE.md.
Requirements
- Nextcloud 31–35 with Talk ≥ 25 (
spreed) and Kanso (kanso) 0.41.x - A Nextcloud user for the bot with an app password
- READ + EDIT on every board you want to bridge
- Go 1.24+ to build, or Docker
Setup
-
Create the bot account and an app password.
docker compose exec -u www-data app php occ user:add --password-from-env kanso-bot # Settings → Security → Devices & sessions → create an app passwordShare the target boards with
kanso-botand give it edit rights. Without EDIT the bot refuses the board up front rather than failing at the first reply. -
Generate the shared secret Talk will use to sign webhooks (40–128 chars):
openssl rand -hex 32 > secrets/talk_bot_secret.txt -
Configure and start.
cp docker-compose.kanso-bot.yml docker-compose.yml # or merge into yours # edit NC_PUBLIC_URL and the network name docker compose up -d kanso-bot curl -fsS localhost:8080/healthz # from inside the network -
Register the bot with Talk. Bot installation is command-line only:
docker compose exec -u www-data app php occ talk:bot:install \ "Kanso" "$(cat secrets/talk_bot_secret.txt)" \ "http://kanso-bot:8080/webhook/talk" \ "Kanso card bridge" -f webhook -f responsewebhookreceives chat messages,responsesends messages and reactions.reactionis not needed — it only subscribes to reaction webhooks, which this bot does not use. -
Enable it in a conversation, as a moderator:
docker compose exec -u www-data app php occ talk:bot:list docker compose exec -u www-data app php occ talk:bot:setup <bot-id> <conversation-token> -
Try it. Post in that conversation:
/kanso https://cloud.example.com/apps/kanso/card/42
Configuration
- NC_API_URL — internal base URL for API calls. Default
http://nextcloud. - NC_PUBLIC_URL — public base URL used to build links inside messages. Required. Must be the host humans use, or every posted card link will point somewhere unreachable.
- KANSO_USER — the bot's Nextcloud account. Default
kanso-bot. - KANSO_APP_PASSWORD / KANSO_APP_PASSWORD_FILE — app password. Required.
- TALK_BOT_SECRET / TALK_BOT_SECRET_FILE — the secret given to
occ talk:bot:install. Required. - JOURNAL_PATH — journal location. Default
/data/journal.jsonl. - ADDR — listen address. Default
:8080. - WORKERS — concurrent jobs. Default
4. - HTTP_TIMEOUT — per-request timeout. Default
20s. - NC_TLS_SKIP_VERIFY — disable certificate checks for API calls. Default
false.
trusted_domains
Nextcloud validates the Host header against trusted_domains. If
NC_API_URL is http://nextcloud, either add nextcloud to
trusted_domains in config.php, or use the public URL for NC_API_URL and
let the request hairpin through your proxy. The readiness probe tells you which
one is wrong — it fails with a trusted-domain error and a 503.
Check it:
docker compose exec kanso-bot wget -qO- http://127.0.0.1:8080/readyz
Behaviour
Card message. Board, column, priority and a one-line description excerpt,
plus the card link. The link is load-bearing: it is how a reply is traced back
to its card, so the format must not change without also changing
kanso.CardIDFromURL.
Comments. Rendered as **Ada Lovelace**: <your text> followed by a link
back to the message in Talk. Kanso has no impersonation, so attribution is
textual.
Failures. ❌ on your message plus one threaded line saying why. If you deleted your message too fast for the explanation to attach to it, the line is posted unthreaded instead.
Durability. Every event is appended to a JSONL journal and fsynced before the webhook returns, so a restart resumes in-flight work. Replay is safe: a comment is only re-posted if it is not already on the card, matched exactly (its body embeds the source message's permalink).
A crash between a successful card-message POST and the journal write can post the card message twice. Talk's bot API returns no message id and has no idempotency key, so this cannot be closed from the outside. The window is milliseconds and the duplicate is harmless — same link, both accepting replies.
Development
go build ./...
go vet ./...
go test ./...
The end-to-end tests stand up a fake Nextcloud (Kanso API + Talk bot API) and drive signed webhooks through a real journal and pipeline, including a simulated crash between "comment posted" and "job done".
Not covered by tests, because it needs a live instance:
- Whether Talk renders markdown in bot-authored messages. The bot sends markdown; if it renders as plain text the message still works, it is just not pretty. Talk stores bot messages as raw text and takes no format flag.
- The exact shape of
inReplyTo.object.contenton your instance. The resolver parses the card URL out of it, so this is the first thing to confirm on a real deployment.
Known limitations
- Public cards only. Talk membership is the access decision.
- No attachments: chat file uploads are access-controlled per participant, and the bot is not a participant. An attachment-only reply becomes a comment that says so and links back to the message.
- The card message is a snapshot. Talk has no bot message-edit endpoint, so a card's title in chat goes stale after a rename.
- Kanso publishes no API contract and ships frequently. Pin the app version.
Licence
AGPL-3.0-or-later, matching Kanso and Talk.