Completion Phase
Overview
The completion phase is where everything comes together. After a lead has journeyed through authentication, validation, enrichment, and delivery, this final phase ensures that:
- Every action is recorded in the event stream
- The source receives comprehensive feedback
- Analytics data is captured
- The complete audit trail is available
Think of this as the closing ceremony - documenting what happened, notifying participants, and preparing the data for analysis.
Event Finalization
The Complete Event Stream
Throughout processing, events accumulated at each step. The completion phase finalizes this stream:
What's in the Event Stream:
Journey Timeline:
├── Source Event (Summary of entire journey)
├── Pre-Processing Events
│ ├── Authentication success
│ ├── Field mapping applied
│ └── Purchasing decisions completed
├── Business Logic Events
│ ├── Acceptance criteria evaluation
│ ├── Suppression list checks
│ ├── Pricing determination
│ └── Volume cap checks
├── Step Processing Events
│ ├── Filter evaluations
│ ├── Enhancement requests/responses
│ ├── Recipient notifications
│ └── Routing decisions
└── Delivery Events
├── Delivery attempts
├── Success/failure outcomes
└── Response data
Event Aggregation
The source event aggregates the entire journey:
{
type: "source",
outcome: "success",
reason: null,
lead_id: "abc-123-def",
price: 15.00,
revenue: 15.00,
duration_ms: 347,
steps_completed: 8,
enhancements: 3,
deliveries: {
attempted: 2,
successful: 1,
failed: 1
}
}
Key Metrics Captured
Every lead processing captures:
- Total duration - End-to-end processing time
- Step count - How many steps executed
- Enhancement count - External services called
- Delivery outcomes - Success/failure per destination
- Price/revenue - Financial impact
- Data quality - Validation results
Source Response
Response Structure
The source receives a comprehensive response:
{
"outcome": "success",
"lead_id": "550f9c08-ff79-4dbb-b62b-ae9a8cf38e5e",
"price": 15.00,
"duration": 347,
"accepted": true,
"reason": null,
"destinations": {
"Salesforce CRM": {
"outcome": "success",
"id": "00Q1234567"
}
}
}
Response Codes
HTTP status codes indicate overall outcome:
Code | Meaning | When Used |
---|---|---|
201 | Created | Lead accepted and processed |
200 | OK | Successful (backward compatibility) |
400 | Bad Request | Invalid data format |
401 | Unauthorized | Authentication failed |
402 | Payment Required | Billing issue |
422 | Unprocessable | Failed business logic |
Rejection Responses
When leads are rejected, sources get specifics:
{
"outcome": "failure",
"lead_id": "550f9c08-ff79-4dbb-b62b-ae9a8cf38e5e",
"accepted": false,
"reason": "State not serviced: NY",
"price": 0,
"field_errors": {
"phone_1": "Invalid format"
}
}
Common rejection reasons:
- "Duplicate lead - seen 7 days ago"
- "Missing required field: email"
- "Cap exceeded: Daily limit reached"
- "Invalid consent certificate"
- "Phone on DNC list"
Analytics Preparation
Data Points Created
The completion phase generates analytics data:
Lead Metrics:
- Source performance
- Acceptance rates
- Rejection reasons
- Processing duration
- Enhancement success
Financial Metrics:
- Cost per lead by source
- Revenue by destination
- Margin analysis
- Price distribution
Quality Metrics:
- Field validation rates
- Data completeness
- Enhancement match rates
- Delivery success rates
Real-Time Updates
Completion triggers real-time updates to:
- Dashboard metrics
- Source performance stats
- Cap utilization
- Revenue tracking
- Quality scores
Audit Trail
Compliance Documentation
Every lead has a complete audit trail:
- Who submitted (source identity)
- When submitted (timestamps)
- What was received (raw data)
- How it was processed (every decision)
- Where it went (destinations)
- Why decisions were made (rule evaluations)
Data Retention
The completion phase ensures:
- Events are persisted immediately
- Data is available for reporting
- Retention policies are applied
- Sensitive data is handled appropriately
Investigation Support
The audit trail enables:
- Dispute resolution with sources
- Delivery confirmation with buyers
- Quality investigations
- Compliance verification
- Performance analysis
Post-Completion Actions
Triggered Workflows
Completion can trigger additional actions:
- Email summaries for high-value leads
- Alerts for quality issues
- API callbacks to source systems
- Internal workflow updates
Feedback Loops
Data from completion feeds back into:
- Source quality scoring
- Acceptance criteria refinement
- Pricing adjustments
- Cap modifications
- Enhancement optimization
Error Scenarios
Partial Success
When some deliveries fail:
Lead accepted → Enhancement successful →
Delivery 1: Success ✓
Delivery 2: Failed ✗
Overall: Partial success
The source response indicates:
- Overall accepted status
- Individual delivery outcomes
- Which systems received the lead
Complete Failure
When processing fails entirely:
- Source gets immediate feedback
- Specific error reason provided
- No charge for failed leads
- Events still recorded for debugging
System Errors
For technical failures:
- Generic error response to source
- Detailed internal logging
- Monitoring alerts triggered
- Automatic retry if configured
Performance Considerations
Response Time
Total time from receipt to response:
- Simple flows: 200-500ms
- Complex flows: 500-2000ms
- Many enhancements: 2-5 seconds
Optimization
Completion phase is optimized for:
- Parallel event writing
- Efficient response generation
- Minimal processing overhead
- Quick source notification
Best Practices
Source Communication
- Always provide specific rejection reasons
- Include lead IDs for tracking
- Return destination outcomes
- Maintain consistent response format
Event Completeness
- Ensure all steps generate events
- Include relevant metadata
- Maintain event ordering
- Capture timing information
Error Handling
- Graceful degradation for partial failures
- Clear error messages
- Appropriate HTTP status codes
- Detailed internal logging
Performance
- Minimize response payload size
- Use efficient event batching
- Quick database writes
- Asynchronous processing where possible
The Complete Picture
By the end of the completion phase:
- Source knows - Exactly what happened to their lead
- You know - Every detail of processing
- Analytics know - All metrics are updated
- Compliance knows - Full audit trail exists
- Systems know - All deliveries are tracked
The lead's journey is complete, documented, and ready for analysis.
The completion phase ensures that every lead's journey through LeadConduit is properly concluded, documented, and communicated. It's the final quality check that makes the entire system transparent, reliable, and auditable.
Comments
0 comments
Please sign in to leave a comment.