# Agent 8 — Guest Communication Manager Agent

**Build Priority:** 5
**Time to Build:** 3–5 days
**Impact:** ⭐⭐⭐⭐⭐ — Operations is the product
**Cost/Month:** $10–20 (OpenAI)

## What It Does

Handles 100% of guest messages. Replaces template-based approaches with an LLM that understands context, handles edge cases, and adapts tone.

## How It's Different from Templates

- Templates answer "WiFi not working" with fixed text
- This agent reads: *"The internet is down and I have a Zoom call in 20 minutes!!"*
- Responds with empathy + specific troubleshooting + "I've also reset the router remotely just in case — try now."
- Triages: auto-resolve what it can, escalate what it can't

## How to Build

### Option A — Hospitable + OpenAI (Hybrid)

Use Hospitable for predictable timeline messages (booking confirmation, pre-arrival) and an LLM fallback for anything that doesn't match a template.

### Option B — Full Custom (More Control)

```python
SYSTEM_PROMPT = """You are the host of [PROPERTY NAME], a highly-rated Airbnb.
Your tone: warm, helpful, concise. Never robotic.

Your priorities:
1. Emergency (water leak, fire, lockout, injury): call immediately
2. Fixable remotely (WiFi, thermostat): step-by-step instructions
3. Complaint: apologize genuinely, offer specific fix
4. Question about area: local recommendations
5. Always end with: "Anything else I can help with?"

RULES:
- Never mention you're an AI
- Never make promises you can't keep
- If unsure, say "Let me check and get right back to you"
"""

class GuestCommAgent:
    def handle_message(self, guest_name, message, booking_context):
        intent = self.classify_intent(message)
        if intent == 'emergency':
            self.escalate_to_host(booking_context, message)
            return f"Hi {guest_name}, I'm calling you right now."

        response = openai.ChatCompletion.create(
            model="gpt-4o-mini",
            messages=[
                {"role": "system", "content": SYSTEM_PROMPT},
                {"role": "system", "content": f"Booking context: {json.dumps(booking_context)}"},
                {"role": "user", "content": message}
            ]
        )
        return response.choices[0].message.content

    def escalate_to_host(self, context, message):
        """Send emergency alert via Twilio SMS + phone call"""
```

## Integration

Use Airbnb's API webhooks or a PMS like Guesty's API for message ingestion.
