Support Reply Generator
Generate contextual support responses by analyzing ticket history and knowledge base.
This workflow retrieves relevant documentation, analyzes conversation history, and drafts personalized responses.
Implementation
1import { relay } from "@relayplane/workflows";23const result = await relay4 .workflow("support-reply-generator")56 // Step 1: Search knowledge base for relevant articles7 .step("search-kb")8 .with("openai:gpt-4o")9 .prompt(`Given this support ticket, identify the most relevant help articles:1011Current Message: {{currentMessage}}12Previous Messages: {{conversationHistory}}1314Our knowledge base categories:15- Getting Started16- API Documentation17- Billing & Plans18- Troubleshooting19- Integrations2021Return top 3 most relevant article titles and why they're relevant.`)2223 // Step 2: Analyze customer sentiment and issue severity24 .step("analyze-context")25 .with("anthropic:claude-3.5-sonnet")26 .depends("search-kb")27 .prompt(`Analyze this support conversation:2829History: {{conversationHistory}}30Latest: {{currentMessage}}3132Assess:33- Customer sentiment and frustration level34- Issue severity (blocker vs nice-to-have)35- How many times they've asked similar question36- Whether they're a churning risk3738Relevant KB Articles: {{search-kb.output}}`)3940 // Step 3: Draft personalized response41 .step("draft-reply")42 .with("anthropic:claude-3.5-sonnet")43 .depends("search-kb", "analyze-context")44 .prompt(`Draft a support response:4546Context Analysis: {{analyze-context.output}}47Relevant Articles: {{search-kb.output}}4849Customer Message: {{currentMessage}}50Customer Name: {{customerName}}5152Requirements:53- Address their specific question directly54- Reference conversation history if they're repeating55- Link to 1-2 most relevant help articles56- Match tone to their sentiment (extra empathy if frustrated)57- Provide code examples if technical58- End with "anything else?" to encourage resolution5960Maximum 250 words.`)6162 .run({63 currentMessage: ticket.latestMessage,64 conversationHistory: ticket.previousMessages.join("\n\n"),65 customerName: ticket.customer.name,66 });6768console.log("Draft Reply:", result.steps["draft-reply"].output);69console.log("Sentiment:", result.steps["analyze-context"].output);Advanced: RAG with Vector Search
For production use, replace the search-kb step with vector similarity search:
1import { relay } from "@relayplane/workflows";2import { searchDocs } from "./vector-db";34// Pre-process: Get relevant docs from vector DB5const relevantDocs = await searchDocs(ticket.latestMessage, {6 limit: 5,7 threshold: 0.7,8});910const result = await relay11 .workflow("support-reply-generator")12 .step("draft-reply")13 .with("anthropic:claude-3.5-sonnet")14 .prompt(`Draft a support response using these relevant docs:1516{{relevantDocs}}1718Customer question: {{currentMessage}}19Tone: {{sentiment}}`)20 .run({21 relevantDocs: relevantDocs.map(d => d.content).join("\n\n"),22 currentMessage: ticket.latestMessage,23 sentiment: "empathetic",24 });Quality Metrics
- Response time: Under 5 seconds
- Accuracy: 80%+ responses require minimal editing
- Customer satisfaction: 4.5/5 average rating
- Agent productivity: 3x more tickets handled per day