Prompt Templates
Template System
StackFlow's prompt template system allows administrators and AI engineers to customize the instructions given to LLMs for every AI task in the platform. Templates are stored in Aurora PostgreSQL and versioned — changes create new template versions while existing AI interactions continue using their version until explicitly upgraded. Templates support Jinja2-style variable interpolation.
- DynamoDB:
StackFlow_PromptTemplatetable with at least one record for each AI feature in use (triage, remediation, KB search) - Required Templates:
incident-triage-v1,kb-rag-answer-v1,change-risk-assessment-v1must exist - IAM:
StackFlowAPIRolewithdynamodb:GetItemonStackFlow_PromptTemplate - Versioning: Template updates must increment
versionattribute; old versions retained for audit
Built-in Templates
| Template Name | Task | Editable |
|---|---|---|
incident_triage_system | Incident classification and routing | Yes |
article_generation_system | KB article generation from incidents | Yes |
copilot_system | AI Copilot context and persona | Yes |
rca_analysis_system | Root cause analysis assistance | Yes |
change_risk_system | Change risk assessment reasoning | Yes |
pir_generation_system | Post-incident review draft generation | Yes |
Creating Templates
curl -X POST https://your-instance.stackflow-tech.com/prod/api/ai/prompt-templates -H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" -d '{
"name": "custom_sla_advisor_system",
"type": "system",
"content": "You are an ITSM SLA advisor for {{ tenant_name }}. When given an incident, recommend whether the SLA can be met based on current team capacity and historical resolution times. Always consider business hours ({{ business_hours_timezone }}) in your analysis.",
"variables": ["tenant_name", "business_hours_timezone"]
}'
Variables and Context
Template variables are automatically populated by the AI engine at runtime. Common variables include tenant_name, current_user_name, record_type, record_id, current_date, and module-specific context like incident_priority or article_category. Custom variables can be passed via the AI API for workflow-triggered AI calls.
Testing Templates
Test templates in the template editor by clicking Test Template and providing sample variable values and a test user message. The test sends a real Bedrock API call and displays the model's response alongside token usage and cost. Template tests are logged in the AI Observability module for review.