CRM - Domain Events & Integration Contracts
Domain events, integration contracts, and asynchronous reactions between CRM and the broader Obelaw ecosystem.
Domain Events & Integration Contracts
CRM communicates with the rest of the Obelaw ecosystem exclusively through domain events and integration contracts. This event-driven architecture preserves domain boundaries, enables asynchronous processing, and allows downstream contexts to react to relationship facts without direct coupling.
1. Domain Events Emitted
The following table lists the primary domain events emitted by the CRM bounded context.
| Event Name | Emitted When | Payload Highlights |
|---|---|---|
| LeadCaptured | A new lead is created from an inbound channel. | Lead identifier, channel, UTM parameters, contact hints, timestamp. |
| LeadEnriched | Additional data is applied to a lead record. | Enrichment source, confidence score, updated attributes. |
| LeadScored | Lead scoring model is executed. | Score, scoring model version, qualifying threshold status. |
| LeadQualified | Lead meets qualification criteria. | Lead identifier, qualification reason, assigned owner. |
| LeadDisqualified | Lead is determined unfit for pursuit. | Lead identifier, reason code, elaboration, requalification flag. |
| ContactMaterialized | A lead is converted into a unified contact. | Contact identifier, account link, persona, consent status. |
| AccountMaterialized | A new corporate account is created or linked. | Account identifier, domain, tax identifier, parent account. |
| ContactMerged | Duplicate contact records are merged. | Surviving contact ID, merged contact IDs, history transfer summary. |
| AccountMerged | Duplicate account records are merged. | Surviving account ID, merged account IDs, hierarchy transfer summary. |
| DealCreated | A new opportunity is opened. | Deal identifier, account/contact, pipeline, stage, value, expected close date. |
| DealStageChanged | A deal advances or regresses in the pipeline. | Deal identifier, from stage, to stage, probability, reason. |
| DealWon | A deal reaches Closed-Won. | Deal identifier, final value, close date, account/contact, product lines. |
| DealLost | A deal reaches Closed-Lost. | Deal identifier, loss reason code, competitor, recovery notes. |
| TicketOpened | A new helpdesk ticket is created. | Ticket identifier, requester, account, priority, queue, SLA target. |
| TicketAssigned | A ticket is assigned to an agent or queue. | Ticket identifier, assignee, queue, assignment timestamp. |
| FirstResponseSent | Agent sends first response to customer. | Ticket identifier, response time, SLA status. |
| SlaBreached | Ticket exceeds SLA target. | Ticket identifier, SLA target, elapsed time, breach type. |
| TicketEscalated | Ticket escalated per SLA or manual rule. | Ticket identifier, escalation level, reason, new assignee. |
| TicketResolved | Agent marks ticket as resolved. | Ticket identifier, resolution details, resolution time. |
| TicketClosed | Ticket confirmed resolved or auto-closed. | Ticket identifier, closure reason, satisfaction link. |
| TouchpointRecorded | Any interaction is logged against a CRM entity. | Touchpoint type, linked entities, owner, timestamp. |
| ConsentUpdated | Contact consent preferences change. | Contact identifier, consent type, status, source, timestamp. |
2. Integration Contracts & Asynchronous Reactions
Downstream contexts subscribe to CRM events and translate them into their own internal workflows. The CRM context does not know how these reactions are implemented; it only publishes facts.
Sales / OMS Reactions
| Subscribed Event | OMS Action | Resulting OMS Document |
|---|---|---|
| DealWon | Materialize a draft Sales Order from the deal’s product lines, account, and commercial terms. | Draft Sales Order. |
| DealWon | Reserve or allocate quoted products against inventory where applicable. | Allocation Request / Reservation. |
| DealStageChanged | Update quote validity and available-to-promise dates. | Quote Status Update. |
| AccountMaterialized | Link new customer account to existing quotes and open orders. | Account Linkage Update. |
Responsibility Boundary
- CRM decides that a deal is won and publishes the commercial facts.
- Sales / OMS decides how to price, reserve, and dispatch the resulting order.
- CRM never queries OMS tables directly; OMS never manipulates CRM pipeline stages.
Accounting / FMS Reactions
| Subscribed Event | FMS Action | Resulting FMS Impact |
|---|---|---|
| DealWon | Establish or verify customer credit parameters and billing profile. | Customer Credit Check / Account Setup. |
| AccountMaterialized | Create or update customer master record for invoicing and receivables. | Customer Master Update. |
| DealWon | Link deal value to revenue recognition forecasts where applicable. | Revenue Forecast Entry. |
| ContactMerged | Consolidate customer master references under surviving contact/account aliases. | Alias Consolidation. |
Responsibility Boundary
- CRM emits account and deal facts.
- FMS applies chart of accounts, credit policies, and customer master rules.
- CRM does not post journal entries or manage receivables.
Inventory / WMS Reactions
| Subscribed Event | WMS Action | Resulting WMS Document |
|---|---|---|
| DealWon | Receive allocation request for deal products if sales order is created. | Stock Reservation. |
| AccountMaterialized | Link delivery addresses to account for future shipments. | Address Book Update. |
Responsibility Boundary
- CRM knows the account and delivery address.
- WMS owns stock availability, picking, packing, and bin-level operations.
Marketing Automation / Flowchat Reactions
| Subscribed Event | Engagement Tool Action | Resulting Output |
|---|---|---|
| LeadCaptured | Trigger welcome or nurture sequence based on channel and persona. | Automated message flow. |
| LeadQualified | Notify assigned sales owner and pause broad nurture. | Sales alert. |
| DealWon | Trigger customer onboarding or expansion campaign. | Onboarding sequence. |
| DealLost | Trigger win-back or feedback survey campaign. | Retention sequence. |
| TicketOpened | Offer automated triage, knowledge base suggestions, or chatbot handoff. | Suggested response. |
| TicketEscalated | Notify supervisor and update chatbot status. | Escalation message. |
Responsibility Boundary
- CRM is the system of record for contacts, accounts, leads, deals, and tickets.
- Engagement tools execute messages and capture responses; responses are ingested back into CRM as touchpoints.
- Two-way synchronization flows through the ACL to prevent circular updates.
Transport / TMS Reactions
| Subscribed Event | TMS Action | Resulting TMS Document |
|---|---|---|
| AccountMaterialized | Register delivery addresses and shipping preferences. | Address Master Update. |
| DealWon (via OMS) | Receive shipment request when order is dispatched. | Shipment Order. |
Responsibility Boundary
- CRM provides account and address data.
- TMS owns carrier selection, route planning, and shipment tracking.
Support / Knowledge Base Reactions
| Subscribed Event | Knowledge Base Action | Resulting Output |
|---|---|---|
| TicketOpened | Suggest relevant articles based on ticket subject and category. | Suggested Articles. |
| TicketResolved | Update article helpfulness ratings and identify content gaps. | Content Gap Report. |
3. Ingestion from External Engagement Tools
CRM ingests events from external engagement tools (e.g., chat platforms, marketing automation, call centers) through its ACL:
┌─────────────────────┐ ┌─────────────────────────────┐ ┌─────────────────────┐
│ External Engagement │ │ Anti-Corruption Layer │ │ CRM Domain │
│ Tool │ ───► │ (Validate / Translate / │ ───► │ (Event Consumer) │
│ │ │ Deduplicate / Enrich) │ │ │
└─────────────────────┘ └─────────────────────────────┘ └─────────────────────┘
Ingestion Examples
| External Event | ACL Translation | CRM Result |
|---|---|---|
| Chat transcript received | Map chat user to contact/lead; extract intent and sentiment. | TouchpointRecorded or LeadCaptured. |
| Form submitted on website | Parse UTM tags; deduplicate against email/phone; create or update lead. | LeadCaptured / LeadEnriched. |
| Email campaign opened | Record engagement touchpoint against contact and campaign. | TouchpointRecorded. |
| Support chat completed | Create ticket if unresolved; add transcript to activity stream. | TicketOpened / TouchpointRecorded. |
4. Event Sourcing & Replay Considerations
Because CRM state is reconstructed from immutable event history, downstream contexts can replay events for recovery, audit, or reprocessing:
| Replay Scenario | Rule |
|---|---|
| OMS replay | Re-materialize sales order drafts using idempotency keys derived from DealWon event identifiers. |
| FMS replay | Re-apply customer master updates without duplicating credit checks. |
| Engagement tool replay | Re-trigger nurture sequences only if not already executed for the same lead/touchpoint. |
All events carry a unique event identifier, timestamp, source entity reference, and correlation identifier to support idempotent processing and end-to-end traceability.
5. Anti-Corruption Layer in Event Flow
The ACL validates and translates CRM events before they cross context boundaries:
┌─────────────────────┐ ┌─────────────────────────────┐ ┌─────────────────────┐
│ CRM Domain │ │ Anti-Corruption Layer │ │ Downstream Context │
│ (Event Publisher) │ ───► │ (Validate / Translate / │ ───► │ (Event Subscriber) │
│ │ │ Enrich / Drop) │ │ │
└─────────────────────┘ └─────────────────────────────┘ └─────────────────────┘
ACL Translation Examples
| CRM Event | ACL Translation for OMS | ACL Translation for FMS |
|---|---|---|
DealWon | Convert deal product lines to sales order lines; map account to customer alias. | Map account to customer master; prepare credit and revenue recognition facts. |
AccountMaterialized | Update customer alias for quotes and orders. | Create or update customer master and billing profile. |
SlaBreached | N/A | N/A |
TicketResolved | N/A | N/A |
This event-driven, ACL-protected integration model ensures that CRM remains a pure, autonomous domain while participating fully in the broader ERP ecosystem.