Skip to content
Free Agents force Blog
Menu
  • Home
  • Agentforce
    • Agentforce 2.0
    • Agentforce 3.0
  • Data Cloud
  • Python
    • Autonomous Agents
    • Mini Apps
    • Utility
Menu

Volunteer Response Agent

Posted on July 4, 2025

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
ToolPurpose
PythonCore logic
imaplib, emailRead volunteer signup emails
openpyxl / csvLog volunteer data
smtplib / yagmailSend replies
(Optional) OpenAI APISmart classification
schedule or cronPeriodic execution

Your agent will:

  1. Read the email
  2. Detect the interest: education, mentoring
  3. Detect location: Bangalore
  4. Log the name, email, interest, location in a file
  5. 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()

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Agentforce
  • Agentforce 2.0
  • Autonomous Agents
  • Python
  • Salesforce

Latest Post

  • Resume Filter Agent
  • Volunteer Response Agent
  • Email Cleanup Agent
©2025 Free Agents force Blog | Design: Newspaperly WordPress Theme