| import gradio as gr
|
| from gmail_handler import get_latest_email
|
| from whatsapp_handler import send_whatsapp
|
| import json
|
|
|
|
|
| with open("config.json") as f:
|
| config = json.load(f)
|
|
|
|
|
| def process_email():
|
| email = get_latest_email()
|
| if "appointment" in email.lower():
|
|
|
| if "City Hospital" in email:
|
| hospital_no = config["City Hospital"]
|
| elif "General Clinic" in email:
|
| hospital_no = config["General Clinic"]
|
| else:
|
| return "Hospital not recognized."
|
|
|
| message = (
|
| f"New Appointment Request:\n\n"
|
| f"{email}\n\n"
|
| "Reply with:\n1. Booked β
\n2. Not Available β and suggest date."
|
| )
|
|
|
| send_whatsapp(hospital_no, message)
|
| return f"Message sent to hospital WhatsApp: {hospital_no}"
|
|
|
| return "No appointment email detected."
|
|
|
| gr.Interface(fn=process_email, inputs=[], outputs="text", title="π© Appointment Agent").launch()
|
|
|