feat(ai-bot): make bot account email configurable via AI_BOT_EMAIL env var#10672
feat(ai-bot): make bot account email configurable via AI_BOT_EMAIL env var#10672dnplkndll wants to merge 2 commits intohcengineering:developfrom
Conversation
…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>
|
Connected to Huly®: UBERF-16033 |
|
Alternative approach: Since no actual email is ever sent to or from this address (it's purely an account identity key), a simpler fix would be to just change the hardcoded default from The reason I went with the configurable approach is backwards compatibility: existing deployments already have the bot registered with If a migration is acceptable, the simpler rename would be a ~5-line change. Happy to pivot to that approach if preferred. |
| setMetadata(serverNotification.metadata.MailAuthToken, config.mailAuthToken) | ||
| setMetadata(serverNotification.metadata.WebPushUrl, config.webPushUrl) | ||
| setMetadata(serverAiBot.metadata.EndpointURL, process.env.AI_BOT_URL) | ||
| if (process.env.AI_BOT_EMAIL !== undefined) { |
There was a problem hiding this comment.
It is idiomaic to use metadata for such kind of configuration, i.e. something like:
setMetadata(serverAiBot.metadata.Email, process.env.AI_BOT_EMAIL)
and in the ai-bot plugin:
export function getAiBotEmailSocialKey (): string {
return buildSocialIdString({
type: SocialIdType.EMAIL,
value:getMetadata(...) ?? aiBotAccountEmail
})
}
There was a problem hiding this comment.
Honestly, I don't think it has to be a email, ideally that should be a separate SocialIdType, but this is something that requires larger refactoring.
- Flutter mobile app with auth (OTP, password, OAuth), issue tracking - Huly design system tokens and shared widgets (HulyButton, HulyChip, PriorityIcon) - OAuth via ASWebAuthenticationSession (flutter_web_auth_2) with huly:// custom scheme - Server-side mobileRedirect support in authProviders for custom scheme redirect - TestFlight ExportOptions.plist, version 0.2.0+2 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Don Kendall <kendall@donkendall.com>
Summary
Makes the AI bot account email configurable via
AI_BOT_EMAILenv var instead of hardcoded tohuly.ai.bot@hc.engineering.Resolves hcengineering/huly-selfhost#239
Motivation
The bot email
huly.ai.bot@hc.engineeringis an@hc.engineeringaddress embedded in every self-hosted deployment's account system. Self-hosters have no control over this domain, and it can cause bounce-back noise if an external SMTP notification service attempts to email all workspace members.Design
setAiBotAccountEmail()/getAiBotAccountEmail()on@hcengineering/ai-bot— mutable at startup, defaults to original emailgetAiBotEmailSocialKey()— derives social key from configured email at call timeaiBotAccountEmailandaiBotEmailSocialKeyconstants kept for client-side codeEnv vars
AI_BOT_EMAILhuly.ai.bot@hc.engineeringAI_BOT_EMAILhuly.ai.bot@hc.engineeringBoth must use the same value if set.
Changes (12 files)
plugins/ai-bot/src/index.tsget/setAiBotAccountEmail(),getAiBotEmailSocialKey()services/ai-bot/pod-ai-bot/src/config.tsEmailfromAI_BOT_EMAIL(imports default from plugin)services/ai-bot/pod-ai-bot/src/start.tssetAiBotAccountEmail(config.Email)on startupservices/ai-bot/pod-ai-bot/src/utils/account.tsservices/ai-bot/pod-ai-bot/src/utils/platform.tspods/server/src/__start.tsAI_BOT_EMAIL, callsetAiBotAccountEmail()foundations/server/packages/middleware/src/identity.ts@hcengineering/ai-bot(was duplicate hardcoded string)foundations/server/packages/middleware/src/pluginConfig.tsserver-plugins/ai-bot-resources/src/index.ts**/package.json+pnpm-lock.yaml@hcengineering/ai-botdependencyNot changed:
plugins/ai-bot-resources/src/utils.ts(client-side, correctly uses constant),models/contact/src/migration.tsanddev/tool/src/db.ts(hardcoded strings reference historical data).Testing
Deployed to self-hosted K8s cluster with
AI_BOT_EMAIL=aibot@ledoweb.com:🤖 Generated with Claude Code