Conversations
Conversations is the heart of EmberX. When a guest scans a QR code, a conversation is created and routed to the appropriate Division. Staff can then reply in real time, place orders, and close the chat when done.
How a Conversation Is Created
- A guest scans a QR Code (physically placed at a table, room, or reception).
- The guest is taken to
/chat/{token}— a public chat page. - The system creates a
Conversationrecord linked to:- The QR Code token
- The Division the QR code belongs to
- The Location (room, table, etc.)
- The conversation appears in the staff dashboard under Conversations → Open.
Conversation List View (/conversations)
Filters
| Tab | What it shows |
|---|---|
| Open | Active conversations needing attention (default) |
| All | Every conversation regardless of status |
| Closed | Resolved / ended conversations |
The list auto-refreshes every 10 seconds via polling, and also updates immediately when a new Socket.IO message arrives.
Each Card Shows
- Location name + Division badge
- Unread badge (red) — number of unread messages from the guest
- Latest message preview — guest messages are shown in their translated form (auto-detected language → staff’s language)
- Guest language (flag + language name)
- Time — relative (“2 min ago”, “3 hours ago”) or absolute date
Conversation Detail View (/conversations/{id})
Clicking a conversation opens the full chat interface:
Chat Header
Shows the Location, Division, Guest Language, and current Status badge (Open / Closed).
Message Area
- Messages from Agents appear on the right (blue).
- Messages from Customers appear on the left (gray).
- Auto-scroll to the latest message.
- When the agent sends a message, an optimistic update immediately shows it — then confirms (or reverts) once the server responds.
Sending Messages
Type in the input bar and press Enter or click Send. Your message is:
- Saved to the database.
- Broadcast via Socket.IO to all staff watching this conversation.
- Auto-translated to the guest’s detected language before delivery.
Real-Time Updates (Socket.IO)
EmberX uses Socket.IO for instant message delivery:
- Staff join a room named by the conversation ID on page load.
- Duplicate messages are deduplicated client-side by
message.id. - On unmount, the socket is disconnected cleanly.
Auto-Translation
EmberX detects the guest’s language from their first message (primaryLanguage field on the Conversation). All subsequent guest messages are:
- Stored in the original language (
content) - Translated to English for staff (
translatedContent)
Staff replies are translated to the guest’s language before delivery.
Supported languages include English, Vietnamese, Korean, Japanese, Chinese, and more (configured via Settings → Language).
Unread Count
The unreadCount is calculated server-side per conversation. It resets to 0 each time a staff member opens the conversation detail view.
Related Features
- Orders — Staff can create an order while in a conversation (
/ordersinside the chat context) - QR Codes — Each conversation originates from a specific QR token
- Divisions — Conversations are routed to and visible by the assigned Division’s staff