RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Business Automation with Local AI
  6. /Ch. 4
Business Automation with Local AI

04. Automated Responses

Chapter 4 of 18 · 15 min
KEY INSIGHT

Few-shot prompting with clear tone and format instructions produces consistent, brand-appropriate responses.

Drafting responses requires more from the model than classification. The response must be factually accurate, match company tone, and actually address the sender's question or concern.

The response generation approach uses few-shot prompting to establish the desired format and tone:

RESPONSE_TEMPLATE = """You are a customer service assistant for a mid-sized company. Write professional, concise email responses.

TONE: Helpful but professional. Do not be overly casual or robotic.
LENGTH: 2-4 sentences for simple questions. Up to 2 paragraphs for complex issues.
ACCURACY: Only state facts you are certain about. Do not make up policies or prices.
FORMAT: Plain text, no emojis, no markdown formatting.

EXAMPLES:

Perfect Example (greeting):
"Thank you for reaching out. Yes, we do offer overnight shipping for all domestic orders over $50. You can select this option at checkout."

Perfect Example (referral):
"Thank you for your patience. I'm escalating your account question to our billing specialists who can access your specific records. Expect a response within 24 hours."

CONTEXT:
Customer's question about: {topic}
{relevant_context}

Customer Email:
{email_body}

Write a response:
"""

def generate_response(email_body, topic_hint="general inquiry", context=None):
    """Generate an email response."""
    context_section = ""
    if context:
        context_section = f"Relevant information: {context}"
    
    prompt = RESPONSE_TEMPLATE.format(
        topic=topic_hint,
        email_body=email_body,
        relevant_context=context_section
    )
    
    response = chat(model='llama3.1:8b', messages=[
        {'role': 'user', 'content': prompt}
    ])
    
    return response['message']['content']

Different email types require different approaches. Acknowledgment emails are straightforward—you confirm receipt and provide a timeline. Support responses need careful handling to avoid hallucinating solutions. Sales responses must be accurate about pricing and availability.

A critical production pattern is the review step. Even with high confidence, automated drafts should go to a queue for human review before sending, especially in the early stages of deployment. Capture user feedback on draft quality and use it to refine prompts.

def create_draft(email_data):
    """Create a response draft for human review."""
    classification = classify_email(email_data['subject'], email_data['body'])
    
    topic_hints = {
        'support_request': 'technical support',
        'sales_inquiry': 'product information and pricing',
        'customer_complaint': 'customer satisfaction concern'
    }
    
    draft = generate_response(
        email_data['body'],
        topic_hint=topic_hints.get(classification['category'], 'general inquiry'),
        context=get_relevant_context(classification['category'])
    )
    
    return {
        'draft': draft,
        'original_email': email_data,
        'classification': classification,
        'status': 'pending_review'
    }
EXERCISE

Write three "perfect examples" that match your company's actual voice. Adapt the template and test drafts on ten real emails.

← Chapter 3
Email Classification
Chapter 5 →
Report Generation