Add bot user type for API integrations#2779
Open
adriantaut wants to merge 1 commit intobasecamp:mainfrom
Open
Conversation
Introduce a `bot` role that mirrors the existing `system` role pattern, enabling programmatic API access via dedicated service accounts rather than repurposing human user seats. Bot users: - Authenticate using Personal Access Tokens (same as human users) - Skip notifications, push notifications, event tracking, and email bundling - Appear in the `active` scope and can be assigned to cards - Are visually distinguished in the UI with a "Bot" badge - Get synthetic identities (bot+hex@fizzy.internal) so PAT auth works unchanged Admin UI allows creating bots, managing multiple access tokens per bot (with description + read/write permission), renaming, and removing bots. JSON API endpoints support programmatic bot provisioning: - POST /account/bots — create bot (returns user + initial token) - PATCH /account/bots/:id — rename bot - DELETE /account/bots/:id — deactivate bot Closes basecamp#2617
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for bot/service account users in Fizzy's API integrations. It implements a new bot user role that allows creating dedicated service accounts for programmatic API access, solving the previous issue where bots had to be created as regular human users and consume a seat.
Changes:
- Added
botuser role enum with corresponding database scopes and access controls - Bot users skip settings creation, email bundling, and event tracking (similar to system users)
- Created two new admin-only controllers for bot CRUD operations and access token management
- Added bot management UI with separate
_bot_user.html.erbpartial and new bot creation endpoints - Implemented JSON API for programmatic bot provisioning (
POST /account/bots,PATCH,DELETE) - Bot actions (comments, events) are visually distinguished with
comment-by-botCSS class
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/models/user/role.rb | Added bot to role enum and scopes, including new bot scope |
| app/models/user/configurable.rb | Skip settings creation for bots (mirroring system user behavior) |
| app/models/user/settings.rb | Skip email bundling for bots |
| app/models/user.rb | Bot users always considered "setup" |
| app/models/notifier.rb | Skip notifications for bot-created actions |
| app/models/notification/pushable.rb | Skip push notifications for bot actions |
| app/models/comment/eventable.rb | Skip event tracking for bot-created comments |
| app/controllers/account/bots_controller.rb | New CRUD controller with admin-only access for bot management |
| app/controllers/account/bot_access_tokens_controller.rb | New controller for bot access token management |
| app/views/account/settings/_bot_user.html.erb | New partial for rendering bot users in settings list |
| app/views/account/settings/_users.html.erb | Modified to conditionally render bot vs. regular user partials |
| app/views/cards/comments/_comment.html.erb | Added comment-by-bot CSS class for styling bot comments |
| app/views/account/bots/new.html.erb, show.html.erb | New views for bot creation and management UI |
| app/views/account/bot_access_tokens/new.html.erb | New view for generating bot access tokens |
| test/models/user/bot_test.rb | New tests for bot model behavior |
| test/controllers/account/bots_controller_test.rb | New tests for bot controller actions |
| test/controllers/account/bot_access_tokens_controller_test.rb | New tests for token management |
| config/routes.rb | Added nested routes for bot and bot_access_tokens resources |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a
botrole to the User model, following the existingsystemrole pattern, to support programmatic API access via dedicated service accounts.Motivation
Currently, integrating external tools with Fizzy's API requires creating a regular human user to hold a Personal Access Token. This works, but the "user" consumes a seat, appears alongside real humans in user lists, and there's no way to distinguish bot actions from human actions in the UI.
Basecamp 3 had chatbot support — this brings a similar concept to Fizzy.
We've been running this in production on our fork for AI agent integrations and it's been working well.
What this does
Model layer —
botrole enum, guards mirroringsystem?checks:User::Role— addsbotto the enum,botscope, bots included inactivescopeUser::Configurable— skip settings creation for botsUser::Settings— skip email bundling for botsUser— bots are always considered "setup"Notifier,Comment::Eventable,Notification::Pushable— skip notifications, event tracking, and push for bot-created actionsControllers (2 new, admin-only):
Account::BotsController— CRUD for bot users (create with transactional identity + token provisioning, rename, deactivate)Account::BotAccessTokensController— token management per bot (mirrorsMy::AccessTokensController)Views:
_bot_user.html.erbpartial to keep_user.html.erbcleancomment-by-botCSS class on commentsJSON API for programmatic provisioning:
POST /account/bots— returns{ user: { id, name, role }, token: "..." }PATCH /account/bots/:id— rename botDELETE /account/bots/:id— deactivate botTest plan
Closes #2617