Files
leocrm/app/plugins/builtins/automation/prebuilt/email_triage_agent.py
T
Agent Zero 8ed6d27885
Check Cross-Plugin Imports / check (push) Has been cancelled
feat(F): F-WORK agent_workstream + F-EMAIL/CONTACT/FOLLOW/REPORT prebuilt agents
- 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
2026-08-17 18:33:45 +02:00

52 lines
1.7 KiB
Python

"""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,
)