Skip to content

feat(channel): add native email support channel with multi-provider delivery and inbound parsing - #32

Open
JOY wants to merge 68 commits into
huabeitech:mainfrom
DOS:feat/email-channel-support
Open

JOY wants to merge 68 commits into
huabeitech:mainfrom
DOS:feat/email-channel-support

Conversation

@JOY

@JOY JOY commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds native Email Channel support to AgentDesk, enabling customer support teams to receive and reply to customer emails directly within the omnichannel inbox and AI Agent workflow.

Key Capabilities

  1. Multi-Provider Outbound Delivery:

    • SMTP: Standard TLS/STARTTLS SMTP protocol (compatible with AWS SES, Brevo, SendGrid, Postmark, and custom mail servers).
    • ESP REST APIs: Native API integrations for Brevo (Sendinblue), SendGrid, Resend, Postmark, and Mailgun.
    • Automatic Queue & Retry: Outbound emails are queued in _channel_message_outbox with exponential backoff retry.
  2. Multi-Format Inbound Ingestion:

    • Webhook ingress at /api/third/email/webhook and /api/third/email/webhook/:channel_id.
    • Supports Generic / Cloudflare Email Routing / AWS SES webhook JSON format.
    • Supports Brevo Inbound webhook JSON format.
    • Supports Postmark Inbound webhook format.
    • Supports SendGrid Inbound Parse & Mailgun Multipart / Form-Data webhooks.
  3. Conversation Threading & Ticket Lifecycle:

    • Automatically maps incoming emails to customer records using their email address.
    • Extracts Ticket / Conversation ID from email Subject (e.g. Re: [#123] ...) and matching In-Reply-To / References message headers to attach messages to existing threads.
    • Seamlessly triggers the AI Agent response loop (Knowledge Base RAG & Ticket dispatching).
  4. Dashboard Configuration & Localization:

    • Full configuration form under Support Setup > Channels with custom delivery providers and webhook tokens.
    • Fully localized across en-US, �i-VN, and zh-CN.

Verification & Tests

  • Added comprehensive unit tests in internal/email/client_test.go and internal/handlers/third/email_handler_test.go.
  • Verified end-to-end inbound email parsing and threaded reply generation.
  • Verified TypeScript compilation and frontend dashboard channel edit forms.

JOY and others added 30 commits August 23, 2026 01:11
…les and dynamic branding

- Add AIConfig environment variable bindings (OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_LLM_MODEL, OPENAI_EMBEDDING_MODEL, etc.)

- Auto-bootstrap and sync LLM and Embedding models to database on startup

- Support dynamic COMPANY_NAME and COMPANY_LOGO_URL in legal document page and support center header

- Add unit tests for AI config initialization and env parsing

Co-authored-by: Cursor <cursoragent@cursor.com>
….example

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
… path lookup

Co-authored-by: Cursor <cursoragent@cursor.com>
…n permissions to existing roles

Co-authored-by: Cursor <cursoragent@cursor.com>
…x global font inheritance

Co-authored-by: Cursor <cursoragent@cursor.com>
…, and translate AI Agent config workbench

Co-authored-by: Cursor <cursoragent@cursor.com>
…roper Inter font-family

Co-authored-by: Cursor <cursoragent@cursor.com>
… AI agent loop tests

Co-authored-by: Cursor <cursoragent@cursor.com>
…Me organization webhook specs with i18n

Co-authored-by: Cursor <cursoragent@cursor.com>
JOY added 14 commits August 28, 2026 18:03
…nd replace all remaining Chinese strings with i18n

- Change Promise.all to Promise.allSettled in AI Agent workbench so MCP errors do not block loading AI configs and teams
- Gracefully handle MCP server connection errors in ToolCatalogService
- Auto-select first available AI config when creating a new AI Agent
- Localize all hardcoded Chinese toasts, node graphs, and UI warnings across AI Agents and AI Workflows
- Update vi-VN and en-US localization keys for complete multilingual support
…d pipeline

- Add .github/workflows/sync-upstream.yml with cron schedule and manual trigger
- Auto-detect new releases from upstream huabeitech/agent-desk and merge into dev
- Create synced GitHub release and tags on repository
- Build & push Docker images for :beta, :<version>, and :latest
- Keep production deployment isolated while generating deployable release artifacts
…ntegration

- Support inbound email webhook ingestion (/api/third/email/webhook) for Brevo and generic JSON
- Support outbound reply dispatching via Brevo API and standard SMTP with automatic retry
- Map email senders into customer identity (help@crove.com) and trigger AI agent conversation loop
- Add Email Channel configuration UI in Dashboard with full bilingual localization
…rt with threading

- Support multiple outbound email delivery providers: SMTP, Brevo, SendGrid, Resend, Postmark, Mailgun
- Support multiple inbound email ingestion formats: Cloudflare Email Routing / Generic Webhook, Brevo, Postmark, SendGrid Inbound Parse, Mailgun
- Add email conversation threading resolution via Subject ticket ID (#123) and In-Reply-To / References message headers
- Add full EmailConfig to server config and bind environment variable aliases
- Enhance Dashboard Channel configuration UI with email delivery providers and bilingual translations
@JOY
JOY marked this pull request as draft September 1, 2026 15:54
JOY added 11 commits September 2, 2026 08:07
- Define Crove OS & Crove Desk as a commercial multi-tenant B2B SaaS platform
- Specify tenant isolation and dynamic inbound/outbound routing patterns
- Add mandatory implementation checklist for SaaS multi-tenancy
…g>.crove.io and UI copy helper

- Add intelligent tenant slug resolution in GetEnabledEmailChannelByAddress for <slug>.crove.io, <slug>.on.crove.email, and plus addressing
- Add forwardingAddress field to EmailChannelConfig
- Add copyable dedicated forwarding address preview in channel edit UI
- Add comprehensive multi-tenant email channel unit tests across EN, VI, ZH locales
…e and distinct styling

- Add IMSenderTypeNote and IMMessageTypeNote enums
- Add mode switcher in SharedMessageEditor for Public Reply vs Internal Note
- Style internal notes with amber tint and 🔒 Internal Note badge
- Prevent internal notes from counting against customer unread count and external channels
- Add full i18n support across EN, VI, and ZH locales
- Upgrade github.com/cloudwego/eino to v0.9.19 with latest eino-ext components
- Upgrade TypeScript to v7.0.2 across web, cloudflare-email-worker, and flowgram-editor
- Upgrade @types/node to v22 and update Go dependencies (golang.org/x/crypto, net, tools)
JOY added a commit to DOS/Crove-Desk that referenced this pull request Sep 10, 2026
- Mark the 18 resolved IDs Done and the 3 unreproducible ones Retracted
  directly in the register, so the table itself carries current status
  instead of relying on the round callouts
- Downgrade SEC-05 from Critical to High. The mechanism is real but the
  old wording claimed an unauthenticated stranger could exploit it. The
  guest id is guest_<uuid> from crypto.randomUUID(), 122 bits of entropy
  held in the desk origin's localStorage, so it cannot be guessed. The
  real defect is that the identifier doubles as the credential, and it is
  disclosed in four verified places: the dashboard shows externalId to
  any staff member, t_customer_identity stores it in plaintext, a
  host-supplied externalId travels in the iframe URL query string, and
  the backend never enforces entropy on what an integrator picks
- Record the owner decisions: keep the widget contract and close the
  first three disclosure paths; merge dev into main and tag a release
  once the i18n batch and SEC-05 land
- Add the upstream defect the SEC-01 tests exposed: mime.ExtensionsByType
  reads the Windows registry, so text/html resolved to .ehtml and storage
  keys were platform dependent
- Add the CI gap: ci.yml only triggers on pull_request, so a push to dev
  ships a beta image without running a single test
- Note that PR huabeitech#32 is still open
- Bump the document to version 4 and extend the verification log
@JOY
JOY marked this pull request as ready for review September 22, 2026 03:52
JOY added 2 commits September 22, 2026 11:31
…support

Resolve against upstream main through huabeitech#49:

- union the per-channel additions (email + discord) in dto/enums/outbox/
  channel/message services, routes, and the channel edit dialog
- keep upstream's ServerConfig security fields (trustedProxies,
  trustedPlatform, rateLimit) alongside this branch's PublicURL/favicon
  and Email config; email defaults and env aliases appended
- go.mod/go.sum taken from upstream and tidied
- renumber this branch's permission-sync migration 10 -> 11 (upstream
  took 10 meanwhile)
- keep the branch's ai/env alias expectations out of the dotenv test
  (upstream never bound those aliases)
- net.JoinHostPort for the SMTP dial address (IPv6-safe, satisfies vet)
- add the six discord channel keys to vi-VN so the locale satisfies the
  shared message type
The merge left the lockfile's overrides snapshot inconsistent with
package.json under pnpm 10 (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH in CI's
frozen install). Regenerate with the same pnpm 10.30.2 CI uses.
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.

1 participant