Complete guide to recording, analyzing, managing, and optimizing prompts with Greenflash
Greenflash provides a comprehensive platform for managing and optimizing AI prompts based on real user interactions. This guide covers everything from basic prompt structure to advanced optimization strategies.
The easiest way to get started with Greenflash is to submit your system prompt as a simple string:
await greenflash.messages.log({ conversationId: "conv_123", productId: "your_product_id", systemPrompt: "You are a helpful customer service assistant. Always be professional and empathetic.", messages: [ { role: "user", content: "How do I reset my password?" }, { role: "assistant", content: "I'll help you reset your password..." } ]});
This simple format:
✅ Automatically tracks and versions your prompts
✅ Links prompts to conversation outcomes
✅ Generates optimization suggestions
✅ Provides performance analytics
❌ Can’t use template variables or dynamic content
❌ Can’t use component-level optimization
Perfect for: Teams wanting to start analyzing and optimizing prompts immediately without any structural changes.
For more control and features, prompts in Greenflash can be built from components - modular pieces that can be combined, versioned, and optimized independently:
const systemPrompt = { components: [ { type: "system", content: "You are a helpful customer service assistant.", name: "base_personality" }, { type: "system", content: "Always be professional and empathetic.", name: "tone_guidelines" }, { type: "rag", content: "Context: [Retrieved documents will be inserted here]", isDynamic: true, name: "rag_context" } ]};
Component Types:
system - Core instructions and behavior guidelines
user - User-provided context or instructions
tool - Tool outputs and function call results
guardrail - Safety checks and content moderation rules
Greenflash supports variable interpolation using Handlebars-style syntax ({{variableName}}), allowing you to create reusable templates:
// Define a template with variablesconst promptTemplate = { components: [{ type: "system", content: "You are an assistant for {{companyName}}. " + "The user's name is {{userName}} and their role is {{userRole}}.", isDynamic: false // Template components are NOT dynamic }]};// Variables are passed inside the systemPrompt objectawait greenflash.messages.log({ conversationId: "conv_123", productId: "your_product_id", systemPrompt: { ...promptTemplate, variables: { companyName: "Acme Corp", userName: "Alice", userRole: "Manager" } }, messages: [...]});
The quickest way to start - just pass your prompt as a string:
await greenflash.messages.log({ conversationId: "conv_456", productId: "product_123", systemPrompt: "You are a helpful assistant. Be concise and friendly.", messages: [ { role: "user", content: "What's the weather?" }, { role: "assistant", content: "I don't have access to real-time weather data..." } ]});
Greenflash automatically converts this to a component internally and tracks all the same metrics. When you’re ready for more features, you can switch to the component format.
The management API endpoints require component format. Simple string prompts are automatically converted to components when logged, but explicit prompt creation/updates need the structured format.
Greenflash automatically deduplicates prompts based on their template content, not the hydrated values. When you use variables, the template (with {{placeholders}}) is what gets hashed and versioned — different variable values reuse the same template.
// Best practice: use variables for per-conversation valuesconst prompt1 = { components: [{ content: "Hello {{userName}}, welcome to {{product}}" }], variables: { userName: "Alice", product: "Greenflash" }};const prompt2 = { components: [{ content: "Hello {{userName}}, welcome to {{product}}" }], variables: { userName: "Bob", product: "DataTool" }};// Both use the same template — no version explosion!// Auto-detection: if you send hydrated content without variables,// Greenflash will attempt to match it against existing templates:const prompt3 = { components: [{ content: "Hello Charlie, welcome to Greenflash" }]};// If a matching template exists, Greenflash extracts variables automatically// and returns templateMatch info in the response.
{ type: "system", content: "You are a helpful assistant."}
After Greenflash analysis:
{ type: "system", content: "You are a helpful assistant for {{companyName}}. " + "When users ask about pricing, always mention the free trial. " + "If technical issues arise, offer to create a support ticket. " + "Keep responses concise - aim for 2-3 sentences unless more detail is requested."}// Reasoning: Analysis of 1,000 conversations showed:// - 34% of users asked about pricing without getting trial info// - 28% had technical issues with no clear next steps// - 67% of users preferred shorter initial responses