Skip to main content

CRM Events (Produced)

Events produced by the CRM service for downstream consumers.


Overview

The CRM service produces events to notify other services about profile changes, segment membership updates, and risk alerts.


Profile Events

crm.profile.created

Fired when a new CustomerProfile is created.

{
type: "crm.profile.created",
version: "1.0",
timestamp: "2025-12-14T10:00:00Z",
tenantId: "tenant_123",
source: "crm",
correlationId: "evt_incoming_123",
payload: {
id: "profile_uuid_789",
email: "john@example.com",
phoneNumber: "+27821234567",
firstName: "John",
lastName: "Smith",
source: "scl.member.created",
linkedIds: {
sclMemberId: 5678,
authUserId: "auth0|123"
},
createdAt: "2025-12-14T10:00:00Z"
}
}

Consumers:

  • Messaging service (to create contact)
  • Analytics service (for tracking)

crm.profile.updated

Fired when profile is updated.

{
type: "crm.profile.updated",
version: "1.0",
timestamp: "2025-12-14T10:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
id: "profile_uuid_789",
changes: ["engagementScore", "churnRiskScore", "membershipTier"],
engagementScore: 75,
churnRiskScore: 15,
membershipTier: "Gold",
updatedAt: "2025-12-14T10:00:00Z"
}
}

Consumers:

  • Messaging service (for dynamic content)
  • Dashboard/Reporting services

crm.profile.merged

Fired when two profiles are merged.

{
type: "crm.profile.merged",
version: "1.0",
timestamp: "2025-12-14T10:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
winnerId: "profile_uuid_789",
loserId: "profile_uuid_790",
loserLinkedIds: {
messagingContactId: "contact_456"
},
mergedFields: ["activities", "notes", "segmentMemberships"],
mergedBy: "user_123",
mergedAt: "2025-12-14T10:00:00Z"
}
}

Consumers:

  • Messaging service (to update contact linkages)
  • Other services with linked records

crm.profile.deleted

Fired when profile is soft-deleted.

{
type: "crm.profile.deleted",
version: "1.0",
timestamp: "2025-12-14T10:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
id: "profile_uuid_789",
reason: "gdpr_request",
deletedBy: "user_123",
deletedAt: "2025-12-14T10:00:00Z"
}
}

Consumers:

  • Messaging service (for GDPR compliance)
  • Analytics service

Segment Events

crm.segment.membership.changed

Fired when segment membership changes.

{
type: "crm.segment.membership.changed",
version: "1.0",
timestamp: "2025-12-14T10:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
segmentId: "segment_123",
segmentName: "High-Value Members",
messagingSegmentId: "msg_segment_456",
profileId: "profile_uuid_789",
action: "JOINED", // or "LEFT"
reason: "engagementScore increased to 75",
occurredAt: "2025-12-14T10:00:00Z"
}
}

Consumers:

  • Messaging service (for real-time segment sync)
  • Journey triggers

Actions:

  • JOINED - Customer met segment criteria
  • LEFT - Customer no longer meets criteria

crm.segment.refreshed

Fired when a segment refresh completes.

{
type: "crm.segment.refreshed",
version: "1.0",
timestamp: "2025-12-14T02:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
segmentId: "segment_123",
segmentName: "High-Value Members",
previousCount: 340,
newCount: 345,
added: 8,
removed: 3,
duration: 1250, // ms
refreshedAt: "2025-12-14T02:00:00Z"
}
}

Consumers:

  • Monitoring/alerting
  • Messaging service (batch sync)

Engagement Events

crm.engagement.score.changed

Fired when engagement score crosses a threshold.

{
type: "crm.engagement.score.changed",
version: "1.0",
timestamp: "2025-12-14T02:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
profileId: "profile_uuid_789",
previousScore: 65,
newScore: 72,
threshold: 70,
direction: "increased",
factors: [
"Recent booking activity",
"Email engagement improved"
],
calculatedAt: "2025-12-14T02:00:00Z"
}
}

Consumers:

  • Marketing automation (trigger campaigns)
  • Notifications/alerts

Churn Risk Events

crm.churn.risk.high

Fired when customer's churn risk exceeds 70%.

{
type: "crm.churn.risk.high",
version: "1.0",
timestamp: "2025-12-14T02:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
profileId: "profile_uuid_789",
customerName: "John Smith",
email: "john@example.com",
churnRiskScore: 75,
previousScore: 55,
riskFactors: [
"No activity in 30 days",
"Payment failed last month",
"Engagement score dropped 25%"
],
detectedAt: "2025-12-14T02:00:00Z"
}
}

Consumers:

  • Retention campaigns (auto-trigger)
  • Staff notifications
  • Dashboard alerts

crm.churn.risk.critical

Fired when customer's churn risk exceeds 90%.

{
type: "crm.churn.risk.critical",
version: "1.0",
timestamp: "2025-12-14T02:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
profileId: "profile_uuid_789",
customerName: "John Smith",
email: "john@example.com",
churnRiskScore: 92,
membershipTier: "Gold",
lifetimeValue: 500000,
riskFactors: [
"No activity in 60 days",
"Membership expiring in 10 days",
"Multiple payment failures"
],
suggestedActions: [
"Personal outreach from account manager",
"Offer renewal discount"
],
detectedAt: "2025-12-14T02:00:00Z"
}
}

Consumers:

  • Urgent staff notifications
  • Escalation workflows
  • High-value retention campaigns

Campaign Events

crm.campaign.executed

Fired when a campaign is executed.

{
type: "crm.campaign.executed",
version: "1.0",
timestamp: "2025-12-14T09:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
campaignId: "campaign_123",
campaignName: "December Newsletter",
segmentId: "segment_456",
targetCount: 500,
executedAt: "2025-12-14T09:00:00Z"
}
}

crm.journey.enrollment

Fired when a customer is enrolled in a journey.

{
type: "crm.journey.enrollment",
version: "1.0",
timestamp: "2025-12-14T10:00:00Z",
tenantId: "tenant_123",
source: "crm",
payload: {
journeyId: "journey_123",
journeyName: "New Member Onboarding",
enrollmentId: "enrollment_456",
profileId: "profile_uuid_789",
trigger: "scl.member.created",
enrolledAt: "2025-12-14T10:00:00Z"
}
}

Event Summary

Event TypeTrigger
crm.profile.createdNew profile created
crm.profile.updatedProfile fields changed
crm.profile.mergedTwo profiles merged
crm.profile.deletedProfile soft-deleted
crm.segment.membership.changedCustomer joins/leaves segment
crm.segment.refreshedSegment recalculation complete
crm.engagement.score.changedScore threshold crossed
crm.churn.risk.highChurn risk > 70
crm.churn.risk.criticalChurn risk > 90
crm.campaign.executedCampaign sent
crm.journey.enrollmentCustomer enrolled in journey