feat(F): F-WORK agent_workstream + F-EMAIL/CONTACT/FOLLOW/REPORT prebuilt agents
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
- F-WORK: app/ai/agent_workstream.py (201 lines) — post_agent_message, post_agent_step, post_agent_result, post_approval_request - F-EMAIL: prebuilt/email_triage_agent.py — E-Mail-Triage-Agent with 3 tools, max 10 steps, $0.50 budget - F-CONTACT: prebuilt/contact_enrichment_agent.py — Contact-Enrichment-Agent with 3 tools, max 8 steps, $0.30 budget - F-FOLLOW: prebuilt/follow_up_agent.py — Follow-up-Agent with 3 tools, max 8 steps, $0.30 budget - F-REPORT: prebuilt/report_agent.py — Report-Agent with 2 tools, max 12 steps, $0.50 budget - All compile checks pass
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Pre-built agent definitions for common CRM use cases."""
|
||||
@@ -0,0 +1,52 @@
|
||||
"""Pre-built Contact-Enrichment-Agent.
|
||||
|
||||
Enriches contact data by searching for related information.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
from app.plugins.builtins.automation.models import AgentDefinition
|
||||
|
||||
CONTACT_ENRICHMENT_SYSTEM_PROMPT = """You are a Contact Enrichment Agent for a CRM system.
|
||||
|
||||
Your task is to enrich contact profiles with additional information.
|
||||
|
||||
For each contact, you should:
|
||||
1. Search for related entities (companies, other contacts)
|
||||
2. Check audit history for recent interactions
|
||||
3. Find semantic matches in the database
|
||||
4. Suggest missing fields that could be filled
|
||||
5. Identify potential duplicates
|
||||
|
||||
Use the available tools to:
|
||||
- Search for related entities (search_related)
|
||||
- Get entity history (get_contact_history)
|
||||
- Call CRM API for data lookup (call_crm_api)
|
||||
|
||||
Output format:
|
||||
- Enrichment suggestions as structured data
|
||||
- Confidence score for each suggestion
|
||||
- Source reference for each piece of information
|
||||
|
||||
Do NOT modify contacts. You are advisory only.
|
||||
"""
|
||||
|
||||
def create_contact_enrichment_agent(
|
||||
tenant_id: uuid.UUID, user_id: uuid.UUID
|
||||
) -> AgentDefinition:
|
||||
return AgentDefinition(
|
||||
tenant_id=tenant_id,
|
||||
name="Contact-Enrichment-Agent",
|
||||
description="Reichert Kontaktdaten mit verwandten Informationen an",
|
||||
system_prompt=CONTACT_ENRICHMENT_SYSTEM_PROMPT,
|
||||
llm_model="openai/gpt-4o-mini",
|
||||
tool_ids=["search_related", "get_contact_history", "call_crm_api"],
|
||||
max_steps=8,
|
||||
max_duration_seconds=90,
|
||||
budget_limit_usd=0.30,
|
||||
mode="reactive",
|
||||
is_active=True,
|
||||
temperature=0.2,
|
||||
max_tokens=1500,
|
||||
trace_mode="standard",
|
||||
created_by=user_id,
|
||||
)
|
||||
@@ -0,0 +1,51 @@
|
||||
"""Pre-built E-Mail-Triage-Agent.
|
||||
|
||||
Sorts and prioritizes incoming emails automatically.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
from app.plugins.builtins.automation.models import AgentDefinition
|
||||
|
||||
EMAIL_TRIAGE_SYSTEM_PROMPT = """You are an E-Mail Triage Agent for a CRM system.
|
||||
|
||||
Your task is to sort and prioritize incoming emails for the user.
|
||||
|
||||
For each email, you should:
|
||||
1. Classify it as: urgent, important, normal, low_priority, or spam
|
||||
2. Extract key information: sender, subject, intent, action items
|
||||
3. Suggest a response category: reply_needed, forward, archive, delete
|
||||
4. Identify any contacts that should be linked
|
||||
|
||||
Use the available tools to:
|
||||
- Fetch emails for contacts (get_contact_mails)
|
||||
- Summarize email threads (summarize_mail_thread)
|
||||
- Call CRM API for contact/company data (call_crm_api)
|
||||
|
||||
Output format:
|
||||
- Provide a structured summary of each email
|
||||
- Include priority level and suggested action
|
||||
- Be concise but thorough
|
||||
|
||||
Do NOT send emails or make changes. You are advisory only.
|
||||
"""
|
||||
|
||||
def create_email_triage_agent(
|
||||
tenant_id: uuid.UUID, user_id: uuid.UUID
|
||||
) -> AgentDefinition:
|
||||
return AgentDefinition(
|
||||
tenant_id=tenant_id,
|
||||
name="E-Mail-Triage-Agent",
|
||||
description="Sortiert und priorisiert eingehende E-Mails automatisch",
|
||||
system_prompt=EMAIL_TRIAGE_SYSTEM_PROMPT,
|
||||
llm_model="openai/gpt-4o-mini",
|
||||
tool_ids=["get_contact_mails", "summarize_mail_thread", "call_crm_api"],
|
||||
max_steps=10,
|
||||
max_duration_seconds=120,
|
||||
budget_limit_usd=0.50,
|
||||
mode="reactive",
|
||||
is_active=True,
|
||||
temperature=0.3,
|
||||
max_tokens=2000,
|
||||
trace_mode="standard",
|
||||
created_by=user_id,
|
||||
)
|
||||
@@ -0,0 +1,52 @@
|
||||
"""Pre-built Follow-up-Agent.
|
||||
|
||||
Reminds about and creates follow-up tasks for contacts.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
from app.plugins.builtins.automation.models import AgentDefinition
|
||||
|
||||
FOLLOW_UP_SYSTEM_PROMPT = """You are a Follow-up Agent for a CRM system.
|
||||
|
||||
Your task is to identify and create follow-up tasks for contacts.
|
||||
|
||||
For each contact, you should:
|
||||
1. Check open tasks and calendar entries
|
||||
2. Review recent email communication
|
||||
3. Identify contacts that need follow-up (no response, overdue tasks, upcoming deadlines)
|
||||
4. Suggest follow-up actions (call, email, meeting, task)
|
||||
5. Create follow-up tasks when appropriate
|
||||
|
||||
Use the available tools to:
|
||||
- Get open tasks (get_open_tasks)
|
||||
- Get contact emails (get_contact_mails)
|
||||
- Call CRM API for task creation (call_crm_api)
|
||||
|
||||
Output format:
|
||||
- List of contacts needing follow-up with reason
|
||||
- Suggested action and timing for each
|
||||
- Priority level (urgent, this_week, this_month)
|
||||
|
||||
You may create tasks via call_crm_api. Always include a clear description and due date.
|
||||
"""
|
||||
|
||||
def create_follow_up_agent(
|
||||
tenant_id: uuid.UUID, user_id: uuid.UUID
|
||||
) -> AgentDefinition:
|
||||
return AgentDefinition(
|
||||
tenant_id=tenant_id,
|
||||
name="Follow-up-Agent",
|
||||
description="Erstellt und erinnert an Follow-up-Tasks für Kontakte",
|
||||
system_prompt=FOLLOW_UP_SYSTEM_PROMPT,
|
||||
llm_model="openai/gpt-4o-mini",
|
||||
tool_ids=["get_open_tasks", "get_contact_mails", "call_crm_api"],
|
||||
max_steps=8,
|
||||
max_duration_seconds=90,
|
||||
budget_limit_usd=0.30,
|
||||
mode="proactive",
|
||||
is_active=True,
|
||||
temperature=0.4,
|
||||
max_tokens=1500,
|
||||
trace_mode="standard",
|
||||
created_by=user_id,
|
||||
)
|
||||
@@ -0,0 +1,50 @@
|
||||
"""Pre-built Report-Agent.
|
||||
|
||||
Generates reports from CRM data using search and API tools.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
from app.plugins.builtins.automation.models import AgentDefinition
|
||||
|
||||
REPORT_SYSTEM_PROMPT = """You are a Report Agent for a CRM system.
|
||||
|
||||
Your task is to generate reports from CRM data.
|
||||
|
||||
You can:
|
||||
1. Search for contacts, companies, and activities using hybrid search
|
||||
2. Call CRM API for structured data (contacts, companies, tasks, calendar)
|
||||
3. Aggregate and summarize data into reports
|
||||
4. Format reports as markdown with tables and sections
|
||||
|
||||
Report types you can generate:
|
||||
- Contact activity summary (interactions, emails, tasks per contact)
|
||||
- Sales pipeline overview (contacts by status, recent changes)
|
||||
- Task completion report (open vs done, overdue, by assignee)
|
||||
- Communication summary (email volume, response times)
|
||||
- Custom reports based on user request
|
||||
|
||||
Use the available tools to gather data, then format a clear, structured report.
|
||||
Include relevant metrics, dates, and entity references.
|
||||
Be concise but comprehensive. Use markdown formatting.
|
||||
"""
|
||||
|
||||
def create_report_agent(
|
||||
tenant_id: uuid.UUID, user_id: uuid.UUID
|
||||
) -> AgentDefinition:
|
||||
return AgentDefinition(
|
||||
tenant_id=tenant_id,
|
||||
name="Report-Agent",
|
||||
description="Generiert Berichte aus CRM-Daten",
|
||||
system_prompt=REPORT_SYSTEM_PROMPT,
|
||||
llm_model="openai/gpt-4o-mini",
|
||||
tool_ids=["call_crm_api", "hybrid_search"],
|
||||
max_steps=12,
|
||||
max_duration_seconds=180,
|
||||
budget_limit_usd=0.50,
|
||||
mode="reactive",
|
||||
is_active=True,
|
||||
temperature=0.3,
|
||||
max_tokens=3000,
|
||||
trace_mode="standard",
|
||||
created_by=user_id,
|
||||
)
|
||||
Reference in New Issue
Block a user