Skip to content

feat(ai-bot): make bot account email configurable via env var#1

Open
dnplkndll wants to merge 1 commit into
developfrom
feat/configurable-aibot-email
Open

feat(ai-bot): make bot account email configurable via env var#1
dnplkndll wants to merge 1 commit into
developfrom
feat/configurable-aibot-email

Conversation

@dnplkndll
Copy link
Copy Markdown

@dnplkndll dnplkndll commented Mar 22, 2026

Summary

Makes the AI bot account email configurable via AI_BOT_EMAIL env var instead of hardcoded to huly.ai.bot@hc.engineering.

Resolves hcengineering/huly-selfhost#239

Motivation

Self-hosted deployments send email notifications to the hardcoded huly.ai.bot@hc.engineering when the bot is mentioned offline — an unreachable address for self-hosters.

Design

  • setAiBotAccountEmail() / getAiBotAccountEmail() on the shared @hcengineering/ai-bot plugin — mutable at startup, defaults to original email
  • getAiBotEmailSocialKey() — derives social key from the configured email at call time
  • Original aiBotAccountEmail and aiBotEmailSocialKey constants kept (used by client-side code that doesn't have env vars)
  • Client plugin unchanged — queries by the default constant, which still works because the bot retains its original social identity after re-registration

Env vars

Service Var Default Required
ai-bot AI_BOT_EMAIL huly.ai.bot@hc.engineering No
transactor AI_BOT_EMAIL huly.ai.bot@hc.engineering No

Both services must use the same value if set.

Changes (12 files)

File Change
plugins/ai-bot/src/index.ts Add get/setAiBotAccountEmail(), getAiBotEmailSocialKey()
services/ai-bot/pod-ai-bot/src/config.ts Add Email from AI_BOT_EMAIL env (imports default from plugin)
services/ai-bot/pod-ai-bot/src/start.ts Call setAiBotAccountEmail(config.Email) on startup
services/ai-bot/pod-ai-bot/src/utils/account.ts Use getter functions
services/ai-bot/pod-ai-bot/src/utils/platform.ts Use getter functions
pods/server/src/__start.ts Read AI_BOT_EMAIL, call setAiBotAccountEmail()
foundations/server/packages/middleware/src/identity.ts Import from @hcengineering/ai-bot (was duplicate hardcoded string)
foundations/server/packages/middleware/src/pluginConfig.ts Use getter function
server-plugins/ai-bot-resources/src/index.ts Use getter function
**/package.json + pnpm-lock.yaml Add @hcengineering/ai-bot dependency

Not changed: plugins/ai-bot-resources/src/utils.ts (client-side, correctly uses constant), models/contact/src/migration.ts and dev/tool/src/db.ts (hardcoded strings reference historical data).

Testing

Deployed to Hetzner K8s cluster with AI_BOT_EMAIL=aibot@ledoweb.com:

  • ai-bot: 0 restarts, registers email:aibot@ledoweb.com as new social identity
  • Original email:huly.ai.bot@hc.engineering identity preserved (backwards compat)
  • DM with Huly AI bot works — bot receives and responds to messages
  • Default behavior (no env var) unchanged

🤖 Generated with Claude Code

@dnplkndll dnplkndll force-pushed the feat/configurable-aibot-email branch 5 times, most recently from 802aaed to dc2dcbd Compare March 25, 2026 12:30
…v var

The AI bot email was hardcoded to huly.ai.bot@hc.engineering, causing
self-hosted deployments to send notifications to an unreachable address.

Add AI_BOT_EMAIL env var to the ai-bot service and transactor:
- ai-bot service: reads AI_BOT_EMAIL, calls setAiBotAccountEmail() on
  startup, uses it for signUp/assignWorkspace/identity lookups
- transactor: reads AI_BOT_EMAIL, calls setAiBotAccountEmail() so
  middleware recognizes the bot as a service account
- server plugin triggers: use getAiBotEmailSocialKey() for DB queries
- middleware: import from @hcengineering/ai-bot instead of duplicating
  the hardcoded string
- client plugin unchanged: queries by the default constant, which still
  works because the bot retains its original social identity

Defaults to huly.ai.bot@hc.engineering when unset (no behavior change).

Tested on self-hosted K8s: bot registers new social identity, DMs work,
0 restarts on both services.

Resolves hcengineering/huly-selfhost#239

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Don Kendall <kendall@donkendall.com>
@dnplkndll dnplkndll force-pushed the feat/configurable-aibot-email branch from dc2dcbd to f24b6fe Compare April 18, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow aibot email to be changed

1 participant