Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -5,86 +5,112 @@ colorFrom: blue
|
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
pinned: false
|
| 8 |
-
short_description: A simple Gradio app
|
| 9 |
---
|
| 10 |
-
# StrategyStack Recovery/Enrichment & Outreach Agents
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
---
|
| 15 |
-
|
| 16 |
-
##
|
| 17 |
-
|
| 18 |
-
-
|
| 19 |
-
-
|
| 20 |
-
-
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 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 |
---
|
|
|
|
|
|
|
|
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
pinned: false
|
| 8 |
+
short_description: A simple Gradio app
|
| 9 |
---
|
|
|
|
| 10 |
|
| 11 |
+
# StrategyStack Recovery, Enrichment & Outreach Platform
|
| 12 |
+
|
| 13 |
+
**Modular pipeline for automated asset enrichment, engagement, analytics, and agent/handoff orchestration—including API, UI, test logic, upgrade/migration, and troubleshooting.**
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## Pipeline Workflow
|
| 18 |
+
|
| 19 |
+
1. **Input/Asset Ingestion** (`activity_ingestion.py`):
|
| 20 |
+
- Receives assets or lead lists (CSV, API, UI submission).
|
| 21 |
+
- Validates schema (see `schema_registry.py`).
|
| 22 |
+
- Logs activity (`activity_log.csv`).
|
| 23 |
+
2. **Automated Enrichment** (`recovery_enrichment_agent.py`):
|
| 24 |
+
- Fills gaps: persona, recent posts, complaints, engagement metrics.
|
| 25 |
+
- Invokes external APIs as needed or generates synthetic context.
|
| 26 |
+
- Handoff to validation agent if enrichment uncertain.
|
| 27 |
+
3. **Human/Machine Validation** (`human_validation_agent.py`):
|
| 28 |
+
- Receives enriched assets where automated logic lacks confidence.
|
| 29 |
+
- Interactive review and correction (UI or API endpoint).
|
| 30 |
+
- Returns enriched/validated assets to pipeline.
|
| 31 |
+
4. **Outreach/Engagement** (`outreach_agent.py`):
|
| 32 |
+
- Selects template, personalizes using context fields.
|
| 33 |
+
- Delivers via pluggable channels: email, LinkedIn, SMS, browser automation.
|
| 34 |
+
- Supports automated social actions and feedback.
|
| 35 |
+
5. **Analytics & Reporting** (`analytics_agent.py`):
|
| 36 |
+
- Logs all asset/channel outcomes, engagement stats.
|
| 37 |
+
- Computes dashboards, actionable feedback, and improvement triggers.
|
| 38 |
+
6. **Research/Search Integration** (`research_agent.py`, `query_search_agent.py`):
|
| 39 |
+
- Supplements enrichment with web or corpus search, updates context/data.
|
| 40 |
+
- Used by outreach for deep personalization or compliance needs.
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## API Endpoints
|
| 45 |
+
|
| 46 |
+
- `/ingest` (**POST**): Upload asset batch (CSV/JSON), triggers validation & enrichment.
|
| 47 |
+
- `/validate` (**POST**): Human/machine validation of asset content.
|
| 48 |
+
- `/enrich` (**POST**): Force re-enrichment or supplemental context fill.
|
| 49 |
+
- `/outreach` (**POST**): Initiates personalized outreach actions; returns status/transcript.
|
| 50 |
+
- `/analytics` (**GET**): Fetch per-asset, per-campaign, or global reports/statistics.
|
| 51 |
+
- **Authentication/Authorization**: All endpoints respect granular role controls, see config in `docs/configs/`.
|
| 52 |
+
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## UI Dashboard Features
|
| 56 |
+
|
| 57 |
+
- Asset ingestion/upload table with schema/state indicators.
|
| 58 |
+
- Visualization of validation/enrichment status, gaps, and overrides (human/manual call-outs).
|
| 59 |
+
- Outreach composer: preview, edit, and dispatch personalized messages across channels.
|
| 60 |
+
- Live stats: engagement rates, delivery status, trigger diagnostics, per-asset and per-campaign.
|
| 61 |
+
- Agent handoff log: view/trace enrichment, validation, and outreach chain per asset.
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
## Test Case Logic
|
| 66 |
+
|
| 67 |
+
- Test scripts: `test_schema_tools.py`, `test_validation.py` (unit tests for all schema/enrichment/validation logic).
|
| 68 |
+
- CI-friendly: All test scripts runnable standalone or via `pytest`, support fixtures for human/machine edge cases.
|
| 69 |
+
- Example cases cover incomplete asset, fuzzy enrichment, validation override, pipeline/integration chain.
|
| 70 |
+
|
| 71 |
+
---
|
| 72 |
+
|
| 73 |
+
## Agent & Asset Wiring
|
| 74 |
+
|
| 75 |
+
- Each module is pluggable: you can sub in new enrichment, validation, or channel handler without altering others.
|
| 76 |
+
- Agent handoff: all context (original, intermediate states) passes via in-memory or file-based serialization; reference logic in `enrichment_handoff_simulation.py` (`docs/`).
|
| 77 |
+
- Asset state maintained through pipeline, logging all hops. Schemas upgradable (see `SCHEMA_VERSIONING.md`).
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
## Upgrade & Migration Guide
|
| 82 |
+
|
| 83 |
+
- **Schema Versioning**: Asset, enrichment, and analytics schema tracked with incremental migrations (`SCHEMA_VERSIONING.md`).
|
| 84 |
+
- **Future DB Integration**: Swap out CSV with SQL/NoSQL backend by implementing new state store hooks in `app.py` and updating config in `docs/configs/`.
|
| 85 |
+
- Migration scripts: Provided for legacy log/asset conversion.
|
| 86 |
+
|
| 87 |
+
---
|
| 88 |
+
|
| 89 |
+
## Best Practices: Setup, Usage, Troubleshooting
|
| 90 |
+
|
| 91 |
+
- **Setup**: `pip install -r requirements.txt`; run `app.py` to launch UI and API.
|
| 92 |
+
- **Usage**: Ingest assets via UI or API, follow pipeline in dashboard, manually validate flagged inputs.
|
| 93 |
+
- **Troubleshooting**:
|
| 94 |
+
- Logs/errors to console and CSV.
|
| 95 |
+
- Validation steps highlight schema mismatches.
|
| 96 |
+
- Check agent handoff logs for stuck or dropped assets.
|
| 97 |
+
- Update configs/schemas via `docs/configs/` for custom needs.
|
| 98 |
|
| 99 |
---
|
| 100 |
+
|
| 101 |
+
## Module, Config, Script, and Logic Reference
|
| 102 |
+
|
| 103 |
+
- **Core Modules**:
|
| 104 |
+
- `activity_ingestion.py`, `outreach_agent.py`, `recovery_enrichment_agent.py`, `analytics_agent.py`, `research_agent.py`, `human_validation_agent.py`, `query_search_agent.py`
|
| 105 |
+
- **Config Files**:
|
| 106 |
+
- All YAML/JSON in `docs/configs/`, plus channel/handler settings in each agent.
|
| 107 |
+
- **Schema & Versioning**:
|
| 108 |
+
- `schema_registry.py`, `SCHEMA_VERSIONING.md`
|
| 109 |
+
- **Test Scripts**:
|
| 110 |
+
- `test_schema_tools.py`, `test_validation.py`
|
| 111 |
+
- **Agent Handoff Logic**:
|
| 112 |
+
- `docs/enrichment_handoff_simulation.py`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
---
|
| 115 |
+
|
| 116 |
+
For further explanation, workflows, and custom case studies—see full documentation and module-level docstrings.
|