from sqlalchemy import select from sqlalchemy.orm import Session from .models import AgentMessageTemplate DEFAULT_AGENT_TEMPLATES = [ { "slug": "agent_run_completion", "name": "Agent Run Success", "description": ( "Notify end users when an Urmi AI agent run completes, with a dynamic " "View Report button linking to the completion report." ), "header_text": "Agent Run Successful", "body_preview": ( "Hello {{customer_name}}, your agent run is complete, you can access " "the completion report at your URMI AI Portal." ), "footer_text": "Thanks and regards, team - URMI AI", "meta_template_name": "agent_run_completion_v2", "language": "en", "category": "utility", "parameters": [ { "name": "customer_name", "type": "string", "required": True, "description": "Recipient display name (template body variable)", "example": "Suyash", }, { "name": "report_group", "type": "string", "required": True, "description": "Urmiport report group slug", "example": "desi-clans-test", }, { "name": "report_id", "type": "string", "required": True, "description": "Report postfix; combined with report_group for the button URL suffix", "example": "2026-10-03", }, ], "button_label": "View Report", "button_url_base": "https://urmiai.com/reports/", }, ] def seed_agent_message_templates(db: Session) -> None: for item in DEFAULT_AGENT_TEMPLATES: existing = db.scalar(select(AgentMessageTemplate).where(AgentMessageTemplate.slug == item["slug"])) if existing: existing.name = item["name"] existing.description = item["description"] existing.header_text = item["header_text"] existing.body_preview = item["body_preview"] existing.footer_text = item["footer_text"] existing.meta_template_name = item["meta_template_name"] existing.language = item["language"] existing.category = item["category"] existing.parameters = item["parameters"] existing.button_label = item["button_label"] existing.button_url_base = item["button_url_base"] existing.is_active = True else: db.add(AgentMessageTemplate(**item)) db.commit()