Automatically reads new volunteer sign-up emails or form submissions, categorizes them (e.g., interest area, location), and sends a personalized acknowledgment email.

Goals
- Perceive: New volunteer emails or form entries
- Reason: Categorize by role/interest (events, education, logistics, etc.)
- Act: Send personalized reply and update volunteer log
- Loop: Do this every hour/day automatically
Tool | Purpose |
---|---|
Python | Core logic |
imaplib , email | Read volunteer signup emails |
openpyxl / csv | Log volunteer data |
smtplib / yagmail | Send replies |
(Optional) OpenAI API | Smart classification |
schedule or cron | Periodic execution |
Your agent will:
- Read the email
- Detect the interest:
education, mentoring
- Detect location:
Bangalore
- Log the name, email, interest, location in a file
- Send a friendly email back with next steps
import imaplib, email, smtplib
from email.mime.text import MIMEText
EMAIL = '[email protected]'
PASSWORD = 'your-password'
IMAP_SERVER = 'imap.yourprovider.com'
SMTP_SERVER = 'smtp.yourprovider.com'
def read_and_process_emails():
mail = imaplib.IMAP4_SSL(IMAP_SERVER)
mail.login(EMAIL, PASSWORD)
mail.select("inbox")
typ, data = mail.search(None, 'UNSEEN')
for num in data[0].split():
typ, msg_data = mail.fetch(num, '(RFC822)')
msg = email.message_from_bytes(msg_data[0][1])
from_email = email.utils.parseaddr(msg['From'])[1]
subject = msg['Subject']
body = get_body(msg)
interest = extract_interest(body)
location = extract_location(body)
log_volunteer(from_email, interest, location)
send_acknowledgement(from_email, interest)
mail.logout()
def get_body(msg):
if msg.is_multipart():
for part in msg.walk():
if part.get_content_type() == 'text/plain':
return part.get_payload(decode=True).decode()
return msg.get_payload(decode=True).decode()
def extract_interest(text):
keywords = ['education', 'events', 'logistics', 'fundraising']
return ', '.join([kw for kw in keywords if kw in text.lower()])
def extract_location(text):
# Very basic (for now). Can replace with geotagging or NER.
cities = ['Bangalore', 'Mumbai', 'Delhi']
for city in cities:
if city.lower() in text.lower():
return city
return "Unknown"
def log_volunteer(email, interest, location):
with open('volunteers.csv', 'a') as f:
f.write(f"{email},{interest},{location}\n")
def send_acknowledgement(to_email, interest):
msg = MIMEText(f"Hi, thanks for volunteering in {interest}! We'll contact you soon.")
msg['Subject'] = 'Thanks for signing up!'
msg['From'] = EMAIL
msg['To'] = to_email
server = smtplib.SMTP_SSL(SMTP_SERVER, 465)
server.login(EMAIL, PASSWORD)
server.send_message(msg)
server.quit()
# Optional: Schedule this to run hourly
# import schedule
# schedule.every(1).hours.do(read_and_process_emails)
# while True: schedule.run_pending()