Skip to content

feat(translation): add two-way AI translation to the Inbox - #1757

Merged
nguyenvantruc92 merged 1 commit into
mainfrom
feat/inbox-bidirectional-translation
Nov 21, 2026
Merged

nguyenvantruc92 merged 1 commit into
mainfrom
feat/inbox-bidirectional-translation

Conversation

@nguyenvantruc92

@nguyenvantruc92 nguyenvantruc92 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Agents can read customers' messages in their own language and reply in the customer's language. A workspace admin turns it on and picks the AI integration and model.
  • Incoming text is translated only when a member opens the conversation or scrolls back to older messages (or an AI agent asks through the API), never in the background.
  • Outgoing text waits at most 10 seconds for its translation, and the bubble shows "Translating…" under it meanwhile. If the translation fails or times out, nothing is sent: the bubble shows "Translation failed" (no toast, no Resend), the composer stays open, and the agent sends the text again as a new message. A translation that arrives late is ignored.
  • If the AI provider's API fails, translation is turned off for that conversation in every open inbox and the agent sees "Translation unavailable. Translation has been turned off for this conversation." Messages still queued to be translated are marked failed, so none goes out untranslated. A timeout, a rate limit or an unusable answer leaves translation on.
  • The customer's language is set once per conversation: detected from their messages or chosen by the agent. Short plain words like "ok" or "thanks" never decide it.
  • A translated message keeps the same height; a small icon opens the original, and "Show original text" in the conversation menu opens all of them.
  • The composer has a "Translation settings" popover: on/off for the conversation, customer language, show original text, and preview before sending (Enter translates, the next Enter sends).
  • Nothing is translated while the bot handles the conversation: when "Bot is active" shows, or when an agent has taken over from the bot for a while (the bot resumes later). Taking the bot over does not turn translation on; the agent turns it on, and that choice is saved for the conversation until the bot takes it back. A conversation whose bot is off for good is translated.
  • Agents limited to assigned conversations cannot send translated messages, request translations, or see stored translations outside those conversations: a translated send there is refused before any model call, and message reads return translation: null. Plain sends and message reads keep their previous behavior (the Inbox itself is not yet scoped to assigned conversations; that is out of scope here).
  • If the customer edits or unsends a message while it is being translated, neither the translation nor a failure of the old text is stored, so the edited message is translated again. Deleting a message also deletes its stored translation (for an agent's message, the sentence they typed); if that cleanup fails it is logged and never fails the delete.
  • An empty answer from the translator is stored as failed (it can be retried), never as an empty translation.
  • The public API, CLI and MCP get settings, test, conversation state, request and preview operations; messages.create can translate and messages.list can include translations. A translated send that fails returns translationNotSent (422) with data.reason and data.conversationTranslation, instead of sending the original text. translation.updateConversationState accepts enabledOverride: true to turn translation on.
  • Translations in all 21 languages of the UI, and a new guide in docs/inbox-translation.md.
  • New tables for translation settings and message translations (migration 20261120131306_add_inbox_translation included).

Test plan

  • Unit tests for the language rule, translation service, request guard, translator, worker job, Inbox UI, composer and the public API
  • Unit tests for a translation that fails or times out (not sent, "Translation failed", no composer lock), the AI provider failing (translation turned off, queued messages failed), and the bot rule
  • Unit tests for a message edited while the provider fails, a job that lost its claim to a newer request, and deleting or hard-deleting a message
  • Unit tests for the member scope on translated sends and on translations in private messages.list/messages.get and the Inbox seed, a failed translation cleanup on delete, and an empty translator answer
  • Database tests for the translation repositories (inbox-translation-repository.test.ts, run against a local database inside rolled-back transactions)
  • Type checks for builder, worker, @chatbotx.io/business, @chatbotx.io/database, @chatbotx.io/ai and @chatbotx.io/redis; turbo run lint, ultracite check and check:invariants
  • Checked in the browser: settings card, opening a conversation, sending with and without preview, "Translating…" and "Translation failed", "Bot is active", taking over from the bot and handing it back, agent limited to assigned conversations
  • Review and apply the migration before deploying

🤖 Generated with Claude Code

@github-actions github-actions Bot added the feature New feature or request label Nov 20, 2026
@nguyenvantruc92
nguyenvantruc92 force-pushed the feat/inbox-bidirectional-translation branch 8 times, most recently from 7e48917 to 7e56b5a Compare November 21, 2026 03:31
@nguyenvantruc92
nguyenvantruc92 force-pushed the feat/inbox-bidirectional-translation branch from 7e56b5a to 5dfcaf7 Compare November 21, 2026 04:04
@nguyenvantruc92
nguyenvantruc92 merged commit 47ac50e into main Nov 21, 2026
14 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant