System Design Atlas

Omnichannel customer service

05 / 10Worked example

Data and states

What changes to Service Case must apply together, and what remains protected after completion?

The contracts require a authoritative data store for Support case F-34. E-mail message ID and provider message identifier are deduplicated in the respective source namespace. Similar subject lines justify a proposal, not an automatic identity merge. Knowledge suggestions indicate the source and status; the service team is responsible for the confirmed answer text. The state is stored together with its command result; this keeps the same change task visible after restart.

Starting point Sending binds the text, recipient and channel.

Assumptions for the example case

Own fictitious example design. A service case via e-mail and chat with human confirmed knowledge suggestions. A send command without evidenced status is added to the investigation list from 120 seconds. All figures and test goals are illustrative assumptions.

Authoritative data and permitted state transitions

Entities and life cycle

Service case F-34Authoritative state and linked follow-up cases
Message N-34deduplicated customer or agent message
Draft A-34Confirmed text version for exactly one send
Servicefall F-34 → Nachricht N-34contains 1..n deduplicated messages
Servicefall F-34 → Entwurf A-34Owns the confirmed reply version
1offen → in_bearbeitung
2→ wartet_auf_fachteam | antwort_offen
3antwort_offen → beantwortet → geschlossen
4Closed (terminal)

Sending binds the confirmed draft version and selected channel.

E-mail message ID and provider message identifier are deduplicated in the respective source namespace. Similar subject lines justify a proposal, not an automatic identity merge. Knowledge suggestions indicate the source and status; the service team is responsible for the confirmed answer text.

Domain entities and relationships

EntityAuthoritative attributesRelationship
Service caseF-34; verified customer reference and case ownershipMany channel messages can be associated with a case.
MessageN-34; source namespace, provider identifier and contentDeduplication occurs within the source namespace.
Draft responseA-34; text, source version and human confirmationEach change generates a new revision in need of confirmation.
Send commandDraft, Recipient, Channel and Provider ReferenceOpen, confirmed or definitively failed; a timeout does not create a new intent.

Service case

Authoritative attributes
F-34; verified customer reference and case ownership
Relationship
Many channel messages can be associated with a case.

Message

Authoritative attributes
N-34; source namespace, provider identifier and content
Relationship
Deduplication occurs within the source namespace.

Draft response

Authoritative attributes
A-34; text, source version and human confirmation
Relationship
Each change generates a new revision in need of confirmation.

Send command

Authoritative attributes
Draft, Recipient, Channel and Provider Reference
Relationship
Open, confirmed or definitively failed; a timeout does not create a new intent.

Permitted state transitions

Starting pointTargetPrecondition
offenin_bearbeitungService team takes over the case.
in_bearbeitungwartet_auf_fachteamDocumented handover with question.
in_bearbeitung or wartet_auf_fachteamantwort_offenThe human-confirmed reply draft is durably queued for sending.
antwort_offenAnswerChannel provider confirms acceptance of the same send command.
AnswerClosedService team confirms completion of processing.
ClosedterminalNew message generates a linked follow-up case.

offen

Target
in_bearbeitung
Precondition
Service team takes over the case.

in_bearbeitung

Target
wartet_auf_fachteam
Precondition
Documented handover with question.

in_bearbeitung or wartet_auf_fachteam

Target
antwort_offen
Precondition
The human-confirmed reply draft is durably queued for sending.

antwort_offen

Target
Answer
Precondition
Channel provider confirms acceptance of the same send command.

Answer

Target
Closed
Precondition
Service team confirms completion of processing.

Closed

Target
terminal
Precondition
New message generates a linked follow-up case.

Atomic changes and versions

Content reference
E-mail message ID and provider message identifier are deduplicated in the respective source namespace. Similar subject lines justify a proposal, not an automatic identity merge. Knowledge suggestions indicate the source and status; the service team is responsible for the confirmed answer text.
Shared commit
Support case API checks service case version, response draft hash, recipient and channel and writes domain change, command result and, if applicable, pending work in a transaction. Commit means that these changes will be permanently visible together. Before commit, a rollback ends the attempt without partial effect.
Concurrency
Two send commands expect version 4. In either order, one wins and the second receives a conflict. After a fresh read, another send is possible only as a new, deliberately confirmed reply.
Terminal completion
A closed case does not accept a new send command. A new customer message generates a subsequent case with reference.

Cover the full scope of the case

Concrete rule
Provider acceptance proves technical acceptance, not that the customer has read the reply. Without a provider contract that supports deduplication, an instruction with an unknown outcome remains open for manual investigation; automatically sending it again is not a permitted retry strategy.

Derive storage needs from access patterns

Authoritative relational datastore
Many channel messages can be associated with a case. Deduplication occurs within the source namespace. The draft therefore selects a relational metadata store with uniqueness constraints and short transactions. Historical versions remain referenceable; a rebuildable read model must not overwrite the authoritative state.
Large content and measurement series
Derived views and extensive measurement or event histories are read separately according to their access patterns. Binding state decisions remain in the authoritative datastore.

Message references remain unique within their source namespace

Message references remain unique within their source namespace

Message references remain unique within their source namespace.

Two send commands expect version 4. In either order, one wins and the second receives a conflict. After a fresh read, another send is possible only as a new, deliberately confirmed reply.

A closed case does not accept a new send command. A new customer message generates a subsequent case with reference. The exercise specifies the input and expected result.

Alternative considered
Separate unversioned changes allow an older state to overwrite the newer one.
Trade-off
Changes to Support case F-34 will be serialized briefly.
Reassess
Measurable waiting times for two parallel responses to the same service case justify a check of the transaction duration.

Try it yourself

Explain the two possible winner orders in the case contract. Also determine the behaviour after terminal completion.

A hint for your attempt

Content revision and aggregate version have different tasks.

Compare with a possible solution
Concurrency
Two send commands expect version 4. In either order, one wins and the second receives a conflict. After a fresh read, another send is possible only as a new, deliberately confirmed reply.
Completion
A closed case does not accept a new send command. A new customer message generates a subsequent case with reference.

Apply to your project

Which states must remain protected in your model against late replay?

Next: Channel processing runs outside the case commit.