Files
leocrm/app/plugins/builtins/automation/prebuilt/email_triage_agent.py
T

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