Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -7,246 +7,84 @@ sdk: gradio
|
|
| 7 |
pinned: false
|
| 8 |
short_description: A simple Gradio app that greets users by name
|
| 9 |
---
|
| 10 |
-
# StrategyStack Recovery/Enrichment
|
| 11 |
|
| 12 |
-
|
| 13 |
-
This repository contains a modular recovery/enrichment agent capable of prioritized multi-source enrichment, live queue handoff, browser automation fallback, and human-in-the-loop escalation. All actions, outcomes, and escalations are logged for full audit and compliance.
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
### Key Features
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
- **Edit**: Update lead data and move to approved queue
|
| 37 |
-
- **Hold**: Keep in review queue with hold status for retry
|
| 38 |
-
- **Scrub**: Archive lead with documented reason
|
| 39 |
-
|
| 40 |
-
3. **Schema Validation**
|
| 41 |
-
- Pydantic-based schema validation for all review actions
|
| 42 |
-
- Business rule validation (e.g., required fields for edit actions)
|
| 43 |
-
- Reason validation for hold and scrub actions (minimum 10 characters)
|
| 44 |
-
- Real-time validation feedback with user-friendly error messages
|
| 45 |
-
|
| 46 |
-
4. **Feedback & Guardrails**
|
| 47 |
-
- Invalid actions are rejected with clear, actionable feedback
|
| 48 |
-
- Comprehensive error handling and logging
|
| 49 |
-
- Validation error tracking for audit purposes
|
| 50 |
-
- Success rate statistics and review analytics
|
| 51 |
-
|
| 52 |
-
5. **Resolution & Handoff**
|
| 53 |
-
- **Approved leads**: Routed to `approved_leads` queue for downstream processing
|
| 54 |
-
- **Edited leads**: Updated data validated and routed to `approved_leads` queue
|
| 55 |
-
- **Held leads**: Maintained in `on_hold` queue with documented reason
|
| 56 |
-
- **Scrubbed leads**: Archived to `scrubbed_leads` queue with reason
|
| 57 |
-
|
| 58 |
-
### API Interface
|
| 59 |
-
|
| 60 |
```python
|
| 61 |
-
from
|
| 62 |
-
|
| 63 |
-
# Initialize agent
|
| 64 |
-
agent = HumanValidationAgent(queue_connection=your_queue_connection)
|
| 65 |
|
| 66 |
-
#
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
# Submit single review
|
| 73 |
-
review_result = interface["submit_review"]({
|
| 74 |
-
"lead_id": "lead_001",
|
| 75 |
-
"action": "approve",
|
| 76 |
-
"reviewer_id": "reviewer_123"
|
| 77 |
})
|
| 78 |
|
| 79 |
-
#
|
| 80 |
-
|
| 81 |
-
"
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
"email": "updated@email.com",
|
| 93 |
-
"company": "Updated Corp"
|
| 94 |
-
},
|
| 95 |
-
"reviewer_id": "reviewer_123"
|
| 96 |
-
},
|
| 97 |
-
{
|
| 98 |
-
"lead_id": "lead_003",
|
| 99 |
-
"action": "scrub",
|
| 100 |
-
"reason": "Lead is a competitor and not a valid prospect",
|
| 101 |
-
"reviewer_id": "reviewer_123"
|
| 102 |
-
}
|
| 103 |
-
]
|
| 104 |
})
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
```
|
| 112 |
|
| 113 |
-
###
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
-
###
|
|
|
|
| 116 |
```python
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
"
|
| 120 |
-
"reason": str | None, # Required for "hold" and "scrub" actions
|
| 121 |
-
"edited_data": dict | None, # Required for "edit" action
|
| 122 |
-
"reviewer_id": str, # Required: Reviewer identifier
|
| 123 |
-
"reviewed_at": datetime # Auto-generated timestamp
|
| 124 |
-
}
|
| 125 |
```
|
| 126 |
|
| 127 |
-
###
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
"reviews": List[LeadReview], # Required: List of review objects
|
| 131 |
-
"batch_id": str | None # Optional: Batch identifier
|
| 132 |
-
}
|
| 133 |
-
```
|
| 134 |
-
|
| 135 |
-
### Validation Rules
|
| 136 |
-
|
| 137 |
-
1. **Approve Action**: No additional fields required
|
| 138 |
-
2. **Edit Action**: Must include `edited_data` with required fields (`name`, `email`, `company`)
|
| 139 |
-
3. **Hold Action**: Must include `reason` (minimum 10 characters)
|
| 140 |
-
4. **Scrub Action**: Must include `reason` (minimum 10 characters)
|
| 141 |
-
|
| 142 |
-
### Response Format
|
| 143 |
-
|
| 144 |
-
#### Batch Review Response
|
| 145 |
-
```json
|
| 146 |
-
{
|
| 147 |
-
"batch_id": "batch_1730832123.456",
|
| 148 |
-
"total_reviews": 3,
|
| 149 |
-
"successful": 2,
|
| 150 |
-
"failed": 1,
|
| 151 |
-
"results": [
|
| 152 |
-
{
|
| 153 |
-
"lead_id": "lead_001",
|
| 154 |
-
"action": "approve",
|
| 155 |
-
"status": "approved",
|
| 156 |
-
"next_queue": "approved_leads",
|
| 157 |
-
"timestamp": "2025-11-05T13:23:00"
|
| 158 |
-
}
|
| 159 |
-
],
|
| 160 |
-
"errors": [
|
| 161 |
-
{
|
| 162 |
-
"lead_id": "lead_002",
|
| 163 |
-
"error": "Missing required field in edited_data: email",
|
| 164 |
-
"feedback": "Edited lead data must include all required fields: name, email, and company."
|
| 165 |
-
}
|
| 166 |
-
]
|
| 167 |
-
}
|
| 168 |
-
```
|
| 169 |
-
|
| 170 |
-
### Statistics & Reporting
|
| 171 |
-
|
| 172 |
-
The agent tracks comprehensive statistics:
|
| 173 |
-
- Total reviews processed
|
| 174 |
-
- Reviews by action type (approve, edit, hold, scrub)
|
| 175 |
-
- Validation error count
|
| 176 |
-
- Success rate calculation
|
| 177 |
-
- Full history export to JSON
|
| 178 |
-
|
| 179 |
-
### Integration Points
|
| 180 |
-
|
| 181 |
-
1. **Upstream**: Receives leads from enrichment agent or browser agent
|
| 182 |
-
2. **Queue Connection**: Queries and updates lead queue system
|
| 183 |
-
3. **Downstream**: Routes to appropriate queues based on action:
|
| 184 |
-
- `approved_leads` → Next processing stage
|
| 185 |
-
- `on_hold` → Temporary hold for retry
|
| 186 |
-
- `scrubbed_leads` → Archived/removed from pipeline
|
| 187 |
-
|
| 188 |
-
### Error Handling
|
| 189 |
-
|
| 190 |
-
- Schema validation errors return detailed feedback
|
| 191 |
-
- Business rule violations provide actionable guidance
|
| 192 |
-
- All errors logged with timestamps for audit
|
| 193 |
-
- Failed reviews don't block successful reviews in batch operations
|
| 194 |
-
|
| 195 |
-
### Audit Trail
|
| 196 |
-
|
| 197 |
-
All review activities are logged with:
|
| 198 |
-
- Lead ID and action taken
|
| 199 |
-
- Reviewer ID and timestamp
|
| 200 |
-
- Reason for hold/scrub actions
|
| 201 |
-
- Updated fields for edit actions
|
| 202 |
-
- Validation errors and feedback
|
| 203 |
-
- Export capability for compliance reporting
|
| 204 |
|
| 205 |
---
|
| 206 |
-
|
| 207 |
-
## Usage
|
| 208 |
-
|
| 209 |
-
1. **Configure enrichment sources:**
|
| 210 |
-
Edit `docs/configs/enrichment_config.json` to set source order, rate limits, retry policies, and handoff rules.
|
| 211 |
-
|
| 212 |
-
2. **Run simulation or queue handoff:**
|
| 213 |
-
Execute `docs/enrichment_handoff_simulation.py` to simulate a queue item enrichment with browser fallback and human escalation.
|
| 214 |
-
|
| 215 |
-
3. **Human validation workflow:**
|
| 216 |
-
Use `human_validation_agent.py` to pull and review leads requiring manual intervention.
|
| 217 |
-
|
| 218 |
-
4. **Audit log review:**
|
| 219 |
-
Inspect `activity_log.csv` for all enrichment, handoff, error, and escalation events (timestamped and detailed).
|
| 220 |
-
|
| 221 |
-
## Example Config
|
| 222 |
-
|
| 223 |
-
```json
|
| 224 |
-
{
|
| 225 |
-
"enrichment_sources": {
|
| 226 |
-
"priority_order": ["crunchbase_api", "clearbit_api", "linkedin_browser"],
|
| 227 |
-
"source_configs": {
|
| 228 |
-
"crunchbase_api": {"rate_limit": {"requests_per_minute": 60}, "retry_policy": {"max_retries": 3}},
|
| 229 |
-
"linkedin_browser": {"requires_human_validation": true, "fallback_to_browser_agent": true}
|
| 230 |
-
}
|
| 231 |
-
},
|
| 232 |
-
"agent_handoff": {
|
| 233 |
-
"human_validation": {"enabled": true, "confidence_threshold": 0.75}
|
| 234 |
-
}
|
| 235 |
-
}
|
| 236 |
-
```
|
| 237 |
-
|
| 238 |
-
## Live Integration
|
| 239 |
-
|
| 240 |
-
- **Upstream:** Receives items from ingest/query queue.
|
| 241 |
-
- **Enrichment:** Prioritized API calls with fallback if rates/quality unmet.
|
| 242 |
-
- **Browser Agent:** Triggered if API unavailable, rate-limited, or data quality insufficient.
|
| 243 |
-
- **Human Validation:** Escalates for manual review if confidence/compliance requires human-in-the-loop.
|
| 244 |
-
- **Audit Trail:** Complete log of actions, fallback, escalations in CSV.
|
| 245 |
-
|
| 246 |
-
## Preparing for Next Agent
|
| 247 |
-
|
| 248 |
-
- Extend `docs/configs/enrichment_config.json` to add sources or escalation criteria.
|
| 249 |
-
- Integrate additional downstream agents via `integration` section of config.
|
| 250 |
-
- Full audit log available for compliance/modules handoff.
|
| 251 |
-
|
| 252 |
-
---
|
|
|
|
| 7 |
pinned: false
|
| 8 |
short_description: A simple Gradio app that greets users by name
|
| 9 |
---
|
| 10 |
+
# StrategyStack Recovery/Enrichment & Outreach Agents
|
| 11 |
|
| 12 |
+
(...existing content above remains unchanged...)
|
|
|
|
| 13 |
|
| 14 |
+
---
|
| 15 |
+
## Outreach Automation & Personalization Agent: `outreach_agent.py`
|
| 16 |
+
### Overview
|
| 17 |
+
The `outreach_agent.py` module provides advanced, high-fidelity outbound engagement with:
|
| 18 |
+
- Extensive lead enrichment and validation
|
| 19 |
+
- Context-specific message tailoring with maximal personalization
|
| 20 |
+
- Fully pluggable multi-channel delivery (Email, LinkedIn, SMS, Browser/Agent automation)
|
| 21 |
+
- Support for rich variables: context snippets, recent posts, complaints, industry hooks, urgency cues
|
| 22 |
+
- Automated browser-based social actions (connect, DM, comment, like, milestone)
|
| 23 |
+
- Robust error handling, analytics, engagement feedback loop, and lead asset state update
|
| 24 |
|
| 25 |
### Key Features
|
| 26 |
+
1. **Lead Intake & Validation**: Accepts, validates, and enriches leads for personalized messaging. Can auto-resolve incomplete fields and flags for missing persona or channel fit.
|
| 27 |
+
2. **Template Selection & Personalization**: Chooses and dynamically adapts outreach templates leveraging persona, pain/opportunity, buyer signals, historical engagement, and channel fit. Supports deep mapping of all relevant profile details.
|
| 28 |
+
3. **Rich Variables Support**: Message logic can use highly granular fields—contextual snippets, recent social or product posts, customer complaints, competitor/industry hooks, urgency/trigger events, and custom tags.
|
| 29 |
+
4. **Omnichannel Delivery**: Channel handlers for Email, LinkedIn, SMS, or direct browser-agent control. Pluggable dispatch for easy integration of new channels.
|
| 30 |
+
5. **Social Automation**: If browser-agent/capabilities available, automates connect, DM, comment, like, and milestone outreach on supported social platforms.
|
| 31 |
+
6. **Error Handling & Feedback Loop**: Comprehensive try/except with logging per-action and per-lead. Delivered message and social actions update lead analytics and asset state. Feedback methods enable continuous learning loop.
|
| 32 |
+
7. **Engagement Analytics & Traceability**: Per-lead transcript, channel actions, engagement results and context mapping are stored and can be queried for real-time stats or compliance reporting.
|
| 33 |
+
8. **Easy Integration**: Fully modular—custom channel handlers, callback hooks, and analytics sinks can be swapped in as business needs evolve.
|
| 34 |
+
|
| 35 |
+
### Example Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
```python
|
| 37 |
+
from outreach_agent import OutreachAgent, email_handler, linkedin_handler, sms_handler
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
# Initialize agent with pluggable channel handlers
|
| 40 |
+
agent = OutreachAgent(channel_handlers={
|
| 41 |
+
"email": email_handler,
|
| 42 |
+
"linkedin": linkedin_handler,
|
| 43 |
+
"sms": sms_handler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
})
|
| 45 |
|
| 46 |
+
# Intake enriched lead
|
| 47 |
+
lead = agent.intake_lead({
|
| 48 |
+
"id": "lead_42",
|
| 49 |
+
"name": "Sam Patel",
|
| 50 |
+
"persona": "Operations Manager",
|
| 51 |
+
"pain_opportunity": "reducing manual workload by 30%",
|
| 52 |
+
"buyer_signals": ["asked for automation demo", "visited pricing"],
|
| 53 |
+
"channel_fit": "linkedin",
|
| 54 |
+
"recent_posts": ["Looking for workflow improvement ideas"],
|
| 55 |
+
"context_snippets": "Their company just merged with a large provider.",
|
| 56 |
+
"customer_complaint_tags": ["integration delays"],
|
| 57 |
+
"competitor_industry_hooks": ["AcmeSoft success story"],
|
| 58 |
+
"urgency_triggers": "Budget cycle renews in 2 weeks."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
})
|
| 60 |
+
# Select template and personalize
|
| 61 |
+
template = agent.select_template(lead)
|
| 62 |
+
personalized = agent.tailor_message(lead, template)
|
| 63 |
+
# Deliver via chosen channel
|
| 64 |
+
delivery_result = agent.deliver(lead, personalized, channel="linkedin")
|
| 65 |
+
# Automate a milestone outreach if desired
|
| 66 |
+
soc_result = agent.browser_social_actions(lead, "connect")
|
| 67 |
+
# Capture feedback and stats
|
| 68 |
+
agent.feedback_loop(lead, feedback="Lead asked for more details.")
|
| 69 |
+
transcript = agent.get_transcript("lead_42")
|
| 70 |
+
print(transcript)
|
| 71 |
```
|
| 72 |
|
| 73 |
+
### System & Integration Points
|
| 74 |
+
- Integrates upstream from enrichment agent, downstream to analytics and customer asset store
|
| 75 |
+
- Can be used stand-alone or in orchestration/chain with search, validation, or queue agents
|
| 76 |
+
- Add custom channel or context processors as new channels emerge
|
| 77 |
|
| 78 |
+
### Channel Handler Example
|
| 79 |
+
- Add your own channel support by implementing a handler function:
|
| 80 |
```python
|
| 81 |
+
def whatsapp_handler(profile, message):
|
| 82 |
+
# Send WhatsApp message here
|
| 83 |
+
return {"status": "sent_via_whatsapp", "recipient": profile.get("phone", "n/a"), "message": message}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
```
|
| 85 |
|
| 86 |
+
### Logging & Feedback
|
| 87 |
+
- Comprehensive action/error/info logging using standard Python logging to file/console
|
| 88 |
+
- All actions update per-lead asset and engagement analytics in real time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|