CRM

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 NameEmitted WhenPayload Highlights
LeadCapturedA new lead is created from an inbound channel.Lead identifier, channel, UTM parameters, contact hints, timestamp.
LeadEnrichedAdditional data is applied to a lead record.Enrichment source, confidence score, updated attributes.
LeadScoredLead scoring model is executed.Score, scoring model version, qualifying threshold status.
LeadQualifiedLead meets qualification criteria.Lead identifier, qualification reason, assigned owner.
LeadDisqualifiedLead is determined unfit for pursuit.Lead identifier, reason code, elaboration, requalification flag.
ContactMaterializedA lead is converted into a unified contact.Contact identifier, account link, persona, consent status.
AccountMaterializedA new corporate account is created or linked.Account identifier, domain, tax identifier, parent account.
ContactMergedDuplicate contact records are merged.Surviving contact ID, merged contact IDs, history transfer summary.
AccountMergedDuplicate account records are merged.Surviving account ID, merged account IDs, hierarchy transfer summary.
DealCreatedA new opportunity is opened.Deal identifier, account/contact, pipeline, stage, value, expected close date.
DealStageChangedA deal advances or regresses in the pipeline.Deal identifier, from stage, to stage, probability, reason.
DealWonA deal reaches Closed-Won.Deal identifier, final value, close date, account/contact, product lines.
DealLostA deal reaches Closed-Lost.Deal identifier, loss reason code, competitor, recovery notes.
TicketOpenedA new helpdesk ticket is created.Ticket identifier, requester, account, priority, queue, SLA target.
TicketAssignedA ticket is assigned to an agent or queue.Ticket identifier, assignee, queue, assignment timestamp.
FirstResponseSentAgent sends first response to customer.Ticket identifier, response time, SLA status.
SlaBreachedTicket exceeds SLA target.Ticket identifier, SLA target, elapsed time, breach type.
TicketEscalatedTicket escalated per SLA or manual rule.Ticket identifier, escalation level, reason, new assignee.
TicketResolvedAgent marks ticket as resolved.Ticket identifier, resolution details, resolution time.
TicketClosedTicket confirmed resolved or auto-closed.Ticket identifier, closure reason, satisfaction link.
TouchpointRecordedAny interaction is logged against a CRM entity.Touchpoint type, linked entities, owner, timestamp.
ConsentUpdatedContact 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 EventOMS ActionResulting OMS Document
DealWonMaterialize a draft Sales Order from the deal’s product lines, account, and commercial terms.Draft Sales Order.
DealWonReserve or allocate quoted products against inventory where applicable.Allocation Request / Reservation.
DealStageChangedUpdate quote validity and available-to-promise dates.Quote Status Update.
AccountMaterializedLink 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 EventFMS ActionResulting FMS Impact
DealWonEstablish or verify customer credit parameters and billing profile.Customer Credit Check / Account Setup.
AccountMaterializedCreate or update customer master record for invoicing and receivables.Customer Master Update.
DealWonLink deal value to revenue recognition forecasts where applicable.Revenue Forecast Entry.
ContactMergedConsolidate 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 EventWMS ActionResulting WMS Document
DealWonReceive allocation request for deal products if sales order is created.Stock Reservation.
AccountMaterializedLink 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 EventEngagement Tool ActionResulting Output
LeadCapturedTrigger welcome or nurture sequence based on channel and persona.Automated message flow.
LeadQualifiedNotify assigned sales owner and pause broad nurture.Sales alert.
DealWonTrigger customer onboarding or expansion campaign.Onboarding sequence.
DealLostTrigger win-back or feedback survey campaign.Retention sequence.
TicketOpenedOffer automated triage, knowledge base suggestions, or chatbot handoff.Suggested response.
TicketEscalatedNotify 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 EventTMS ActionResulting TMS Document
AccountMaterializedRegister 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 EventKnowledge Base ActionResulting Output
TicketOpenedSuggest relevant articles based on ticket subject and category.Suggested Articles.
TicketResolvedUpdate 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 EventACL TranslationCRM Result
Chat transcript receivedMap chat user to contact/lead; extract intent and sentiment.TouchpointRecorded or LeadCaptured.
Form submitted on websiteParse UTM tags; deduplicate against email/phone; create or update lead.LeadCaptured / LeadEnriched.
Email campaign openedRecord engagement touchpoint against contact and campaign.TouchpointRecorded.
Support chat completedCreate 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 ScenarioRule
OMS replayRe-materialize sales order drafts using idempotency keys derived from DealWon event identifiers.
FMS replayRe-apply customer master updates without duplicating credit checks.
Engagement tool replayRe-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 EventACL Translation for OMSACL Translation for FMS
DealWonConvert deal product lines to sales order lines; map account to customer alias.Map account to customer master; prepare credit and revenue recognition facts.
AccountMaterializedUpdate customer alias for quotes and orders.Create or update customer master and billing profile.
SlaBreachedN/AN/A
TicketResolvedN/AN/A

This event-driven, ACL-protected integration model ensures that CRM remains a pure, autonomous domain while participating fully in the broader ERP ecosystem.

Our Premium Sponsors

Obelaw is proudly open-source. Continued development, bug fixes, and community support are made possible by the generosity of our sponsors.

Sponsor Obelaw