File size: 3,010 Bytes
a5575eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
"""
Script to create AIDA_BOT user in the database
This ensures AIDA appears correctly in conversations with name and avatar
"""

import asyncio
import sys
from pathlib import Path
from datetime import datetime

# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))

from app.database import connect_db, disconnect_db, get_db
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# AIDA Bot configuration
AIDA_BOT_ID = "AIDA_BOT"
AIDA_AVATAR_URL = "https://imagedelivery.net/0utJlkqgAVuawL5OpMWxgw/aida-bot-avatar/public"  # You can update this


async def create_aida_bot_user():
    """Create or update AIDA_BOT user in the database"""
    
    try:
        # Connect to database
        await connect_db()
        db = await get_db()
        
        # Check if AIDA_BOT already exists
        existing = await db.users.find_one({"_id": AIDA_BOT_ID})
        
        if existing:
            logger.info(f"AIDA_BOT user already exists: {existing.get('name')}")
            
            # Update to ensure correct data
            await db.users.update_one(
                {"_id": AIDA_BOT_ID},
                {"$set": {
                    "name": "AIDA",
                    "email": "aida@lojiz.com",
                    "role": "bot",
                    "profilePicture": AIDA_AVATAR_URL,
                    "isActive": True,
                    "updated_at": datetime.utcnow()
                }}
            )
            logger.info("✅ AIDA_BOT user updated successfully")
        else:
            # Create new AIDA_BOT user
            aida_user = {
                "_id": AIDA_BOT_ID,
                "name": "AIDA",
                "email": "aida@lojiz.com",
                "role": "bot",  # Special role for bots
                "profilePicture": AIDA_AVATAR_URL,
                "bio": "Your AI property assistant. I help you find properties, create listings, and answer questions about real estate.",
                "isActive": True,
                "isEmailVerified": True,
                "isPhoneVerified": False,
                "createdAt": datetime.utcnow(),
                "updated_at": datetime.utcnow(),
                "totalListings": 0,
                "totalReviews": 0,
                "averageRating": 5.0,
            }
            
            await db.users.insert_one(aida_user)
            logger.info("✅ AIDA_BOT user created successfully")
        
        logger.info(f"\n{'='*60}")
        logger.info(f"AIDA Bot User Details:")
        logger.info(f"  ID: {AIDA_BOT_ID}")
        logger.info(f"  Name: AIDA")
        logger.info(f"  Avatar: {AIDA_AVATAR_URL}")
        logger.info(f"{'='*60}\n")
        
    except Exception as e:
        logger.error(f"Failed to create AIDA_BOT user: {e}")
        raise
    finally:
        await disconnect_db()


if __name__ == "__main__":
    logger.info("Creating AIDA_BOT user...")
    asyncio.run(create_aida_bot_user())