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