# Agent 4 — Response Qualifier Agent

**Build Priority:** 4
**Time to Build:** 2–3 days
**Impact:** ⭐⭐⭐⭐ — 24/7 response is a superpower
**Cost/Month:** $5–10 (Twilio)

## What It Does

Handles the first interaction when an owner responds to your mail. Qualifies the lead, answers basic questions, and books the pitch meeting — all before you touch the conversation.

## Channels

- **SMS** (via Twilio)
- **Email** (via Gmail API)
- **Web form submissions** (via webhook)
- **Phone calls** (via Twilio + ElevenLabs voice agent)

## How to Build

### Twilio SMS Agent

```python
from flask import Flask, request
import openai

app = Flask(__name__)

SYSTEM_PROMPT = """You are an Airbnb co-hosting assistant for [COMPANY NAME].
Your job:
1. Answer basic questions about how co-hosting works
2. If they ask about revenue: "I'd love to run the exact numbers for your property. Can we set up a 15-minute call?"
3. Your only goal is to get them to book a pitch call.
4. Never give firm revenue numbers.
5. Be warm, professional, and brief."""

@app.route('/sms', methods=['POST'])
def handle_sms():
    incoming_msg = request.form['Body']
    from_number = request.form['From']
    history = get_conversation(from_number)
    response = openai.ChatCompletion.create(
        model="gpt-4o",
        messages=[{"role": "system", "content": SYSTEM_PROMPT}, *history,
                  {"role": "user", "content": incoming_msg}]
    )
    reply = response.choices[0].message.content
    send_sms(from_number, reply)
    if is_qualified(history):
        send_alert_to_host(f"Hot lead: {from_number}")
    return ''
```

### Voice Agent (Optional, Higher Complexity)

Twilio Voice Webhook → ElevenLabs Conversational AI Agent
- Answers calls 24/7
- Books Calendly appointments directly
- Sends transcript + summary after each call
- Cost: ~$0.30/min (ElevenLabs + Twilio)

### Email Agent

Gmail API webhook → similar LLM pipeline
- Watch for replies to your direct mail follow-up emails
- Auto-reply within 5 minutes, same qualification logic

## Qualification Criteria

LLM is prompted to classify leads as:
- **Hot:** Ready to book a call → immediate SMS alert to you
- **Warm:** Interested but need more info → auto-send FAQ + Calendly link
- **Cold:** Not interested → log as "not interested" with reason
