Prompt
Build a shared inbox for customer support that email and chat can both feed into
Latest observation
Absolutely — here’s a practical blueprint for a shared customer support inbox that can ingest both email and chat into one unified workspace.
Goal
Create a single system where:
- Support agents see all customer conversations in one place
- Email and chat messages become the same “ticket/thread”
- Agents can reply from the same interface
- Conversation history, assignment, and status are shared across channels
Core concept
Treat every inbound message as part of a conversation object.
Main entities
- Customer
- Conversation / Thread
- Message
- Channel (email, chat, etc.)
- Agent
- Assignment
- Status (open, pending, closed)
- Tags / priority / SLA metadata
A customer can have multiple conversations, but each conversation can include messages from multiple channels if they belong to the same support case.
High-level architecture
1. Channel connectors
Create separate ingestion adapters:
Email connector
- Connect to a support mailbox via:
- IMAP, or
- Gmail API / Microsoft Graph, or
- inbound email webhook provider
- Parse incoming emails
- Detect thread IDs / message IDs / reply chains
- Map sender email to customer profile
Chat connector
- Embed chat widget on website/app
- Chat server receives realtime messages
- Chat messages are stored as support messages in the same system
- Use a visitor/session ID plus optional authenticated user ID
2. Unified conversation service
All inbound messages from any channel are normalized into one schema and stored in a shared inbox database.
3. Agent inbox UI
A single UI for:
- conversation list
- filters by channel/status/assignee
- message history
- reply composer with channel-aware sending
4. Routing/automation service
Rules for:
- assignment
- priority
- escalation
- auto-replies
- business hours
- chatbot handoff
Suggested data model
customers
idnameemailphoneexternal_ids(JSON for CRM/chat IDs)created_at
conversations
idcustomer_idstatus(open,pending,closed)priorityassigned_agent_idsource_channel(email,chat,mixed)subjectlast_message_atcreated_atupdated_at
messages
idconversation_idchannel(email,chat)direction(inbound,outbound)sender_type(customer,agent,system)sender_namesender_emailbody_textbody_htmlattachmentsexternal_message_idparent_message_idcreated_at
agents
idnameemailroleonline_status
conversation_events (optional)
- assignment changes
- status changes
- tag changes
- internal notes
How to unify email and chat
Option A: Same conversation if identity matches
If the email sender matches the known customer, and chat session is tied to that same customer, attach both channels to the same conversation.
Option B: Separate threads, same customer
If identity is uncertain or separate issues are likely, create separate conversations but link them to the same customer profile.
Option C: Merge manually
Allow agents to merge:
- two email threads
- chat + email
- multiple conversations from the same user
Message flow
Email inbound
- Email arrives at support mailbox
- Connector parses it
- Lookup customer by email address
- Find matching open conversation by:
- email thread ID
- recent active conversation
- subject similarity
- Create or append message
- Notify/route to agents
Chat inbound
- User starts chat on site
- Widget opens session
- Messages stream into backend
- Lookup authenticated user or session-based customer
- Create or append to conversation
- Assign agent or queue
Agent reply
- Agent responds in shared inbox
- System checks channel of conversation
- Send back through original or preferred channel:
- email reply via SMTP/API
- chat reply via websocket/chat service
- Store outbound message in same thread
Important behaviors
Threading
- Use email
Message-ID,In-Reply-To,References - Use chat session IDs / conversation IDs
- Maintain a unified internal conversation ID
Deduplication
Prevent duplicates from webhook retries or repeated email sync:
- store
external_message_id - enforce uniqueness per channel
Status sync
- If agent closes conversation, close across all related messages
- Reopening from either channel can reopen thread
Attachments
Support:
- email attachments
- chat file uploads
- virus scanning / size limits
Internal notes
Agents need private notes not visible to customers.
UI features for support agents
- Unified inbox list
- Filter by channel, assignee, status, priority
- Customer profile sidebar
- Conversation timeline
- “Reply” + “Add internal note”
- Merge conversations
- Assign/reassign
- Canned responses
- Macros
- SLA timers
Recommended tech stack
Backend
- Node.js / TypeScript, Python, or Go
- REST or GraphQL API
- Webhooks for email/chat events
- Background worker queue for processing inbound messages
Database
- PostgreSQL for core data
- Redis for queues/session state
- Object storage for attachments
Frontend
- React / Next.js
- WebSocket or SSE for live updates
Infrastructure
- Queue: BullMQ, RabbitMQ, SQS
- Email: SendGrid Inbound Parse, Mailgun Routes, AWS SES inbound, Gmail API
- Chat: custom WebSocket service or provider SDK
Minimal MVP scope
If you want to ship fast:
MVP features
- Email ingestion
- Chat widget
- Shared conversation list
- Agent assignment
- Reply from inbox
- Basic statuses
- Customer lookup by email
- Chat session linkage
- Internal notes
Skip initially
- Advanced automation
- SLA enforcement
- AI suggestions
- Multi-department routing
- Omnichannel messaging beyond email/chat
Example workflow
- Customer emails support
- Ticket is created in shared inbox
- Agent replies by email
- Later the same customer opens live chat
- System identifies customer from login/email
- Chat message is appended to same conversation or linked thread
- Agent sees full history and continues contextually
Key design decision to make early
Decide whether you want:
A. Channel-first conversations
Each channel has its own thread, with links between them
or
B. Customer-first conversations
One support case can span multiple channels
For customer support, customer-first is usually better.
If you want, I can also provide any of these next:
- A database schema in SQL
- An API design for the inbox
- A React UI structure
- A system architecture diagram
- A step-by-step MVP build plan
If you want, I can draft the full MVP architecture + schema + endpoints next.