Skip to content
Learn Agentic AI13 min read0 views

AI Agent for Membership Management: Registration, Renewals, and Engagement Tracking

Learn how to build an AI agent that manages member registrations, automates renewal reminders, tracks engagement scores, and personalizes communication for community organizations.

Why Membership Management Needs Intelligence

Community organizations — from neighborhood associations to professional groups to cultural clubs — depend on their membership base for sustainability. Yet managing memberships manually leads to lapsed renewals, disengaged members, and lost revenue. A typical organization loses 20-30% of members each year simply because renewal reminders went out too late or not at all.

An AI membership agent tracks every member's lifecycle from registration through renewal, calculates engagement scores to identify at-risk members, and personalizes outreach to keep people connected. The agent handles the operational burden so staff can focus on building community.

Membership Data Model

from dataclasses import dataclass, field
from datetime import datetime, date, timedelta
from typing import Optional
from enum import Enum
from uuid import uuid4


class MembershipTier(Enum):
    BASIC = "basic"
    STANDARD = "standard"
    PREMIUM = "premium"
    LIFETIME = "lifetime"


class MemberStatus(Enum):
    ACTIVE = "active"
    EXPIRING_SOON = "expiring_soon"
    EXPIRED = "expired"
    SUSPENDED = "suspended"


@dataclass
class Member:
    member_id: str = field(default_factory=lambda: str(uuid4()))
    first_name: str = ""
    last_name: str = ""
    email: str = ""
    phone: Optional[str] = None
    tier: MembershipTier = MembershipTier.STANDARD
    status: MemberStatus = MemberStatus.ACTIVE
    join_date: date = field(default_factory=date.today)
    expiration_date: date = field(
        default_factory=lambda: date.today() + timedelta(days=365)
    )
    events_attended: int = 0
    volunteer_hours: float = 0.0
    donations_total: float = 0.0
    last_interaction: Optional[date] = None
    engagement_score: float = 0.0
    auto_renew: bool = False
    renewal_reminders_sent: int = 0


TIER_PRICING = {
    MembershipTier.BASIC: 25.00,
    MembershipTier.STANDARD: 50.00,
    MembershipTier.PREMIUM: 100.00,
    MembershipTier.LIFETIME: 500.00,
}

Registration and Renewal Tools

from agents import function_tool

members_db: dict[str, Member] = {}


@function_tool
async def register_member(
    first_name: str,
    last_name: str,
    email: str,
    phone: str = "",
    tier: str = "standard",
) -> dict:
    """Register a new member with the organization."""
    for m in members_db.values():
        if m.email == email:
            return {
                "error": "Email already registered",
                "member_id": m.member_id,
            }

    membership_tier = MembershipTier(tier)
    member = Member(
        first_name=first_name,
        last_name=last_name,
        email=email,
        phone=phone or None,
        tier=membership_tier,
        last_interaction=date.today(),
    )
    members_db[member.member_id] = member

    return {
        "status": "registered",
        "member_id": member.member_id,
        "tier": tier,
        "expiration_date": str(member.expiration_date),
        "annual_fee": TIER_PRICING[membership_tier],
        "message": f"Welcome, {first_name}!",
    }


@function_tool
async def renew_membership(
    member_id: str,
    new_tier: str = "",
) -> dict:
    """Renew a member's membership, optionally upgrading tier."""
    member = members_db.get(member_id)
    if not member:
        return {"error": "Member not found"}

    if member.tier == MembershipTier.LIFETIME:
        return {
            "status": "lifetime",
            "message": "Lifetime members do not need to renew.",
        }

    if new_tier:
        member.tier = MembershipTier(new_tier)

    today = date.today()
    if member.expiration_date > today:
        member.expiration_date += timedelta(days=365)
    else:
        member.expiration_date = today + timedelta(days=365)

    member.status = MemberStatus.ACTIVE
    member.renewal_reminders_sent = 0

    return {
        "status": "renewed",
        "member": f"{member.first_name} {member.last_name}",
        "tier": member.tier.value,
        "new_expiration": str(member.expiration_date),
        "amount_due": TIER_PRICING[member.tier],
    }

Engagement Scoring

Engagement scores help identify which members are thriving and which are drifting away.

See AI Voice Agents Handle Real Calls

Book a free demo or calculate how much you can save with AI voice automation.

@function_tool
async def calculate_engagement_score(member_id: str) -> dict:
    """Calculate a member's engagement score based on activity."""
    member = members_db.get(member_id)
    if not member:
        return {"error": "Member not found"}

    score = 0.0
    score += min(member.events_attended * 5, 30)
    score += min(member.volunteer_hours * 2.5, 25)
    if member.donations_total > 0:
        score += min(member.donations_total / 50, 20)

    if member.last_interaction:
        days_since = (date.today() - member.last_interaction).days
        if days_since <= 7:
            score += 25
        elif days_since <= 30:
            score += 20
        elif days_since <= 90:
            score += 10

    member.engagement_score = min(score, 100)
    risk = "high" if score < 20 else "medium" if score < 40 else "low"

    return {
        "member": f"{member.first_name} {member.last_name}",
        "score": round(member.engagement_score, 1),
        "risk_level": risk,
    }


@function_tool
async def find_expiring_memberships(
    days_ahead: int = 30,
) -> dict:
    """Find members whose memberships expire within a given window."""
    today = date.today()
    cutoff = today + timedelta(days=days_ahead)
    expiring = []

    for member in members_db.values():
        if member.tier == MembershipTier.LIFETIME:
            continue
        if today <= member.expiration_date <= cutoff:
            expiring.append({
                "member_id": member.member_id,
                "name": f"{member.first_name} {member.last_name}",
                "email": member.email,
                "tier": member.tier.value,
                "expires": str(member.expiration_date),
                "engagement_score": member.engagement_score,
                "auto_renew": member.auto_renew,
                "reminders_sent": member.renewal_reminders_sent,
            })

    expiring.sort(key=lambda x: x["expires"])
    return {"expiring_members": expiring, "count": len(expiring)}

Assembling the Membership Agent

from agents import Agent, Runner

membership_agent = Agent(
    name="Membership Management Agent",
    instructions="""You are the membership manager for the
Riverside Community Association. Your responsibilities:

1. Register new members with appropriate tier selection
2. Process membership renewals and tier upgrades
3. Calculate engagement scores to identify at-risk members
4. Find expiring memberships and trigger renewal reminders
5. High-risk members (score below 20) should receive
   personalized re-engagement outreach
6. For auto-renew members, process renewal automatically
7. Lifetime members never need renewal reminders
8. Always explain tier benefits when registering new members
9. Suggest tier upgrades for highly engaged members""",
    tools=[
        register_member,
        renew_membership,
        calculate_engagement_score,
        find_expiring_memberships,
    ],
)

result = Runner.run_sync(
    membership_agent,
    "Please check which memberships are expiring in the next 30 days "
    "and calculate the engagement score for each one. Prioritize "
    "outreach to the least engaged members.",
)
print(result.final_output)

FAQ

How is the engagement score calculated?

The score is a weighted composite of four factors: events attended (up to 30 points), volunteer hours (up to 25 points), donation history (up to 20 points), and recency of last interaction (up to 25 points). The maximum score is 100. Members below 20 are flagged as high risk, between 20-40 as medium risk, and above 40 as low risk.

What happens when a membership expires?

The agent updates the member's status to "expired" but does not delete their record. Expired members can still be contacted for re-engagement. The agent sends up to three renewal reminders: at 30 days, 14 days, and 3 days before expiration. After expiration, a final "we miss you" message is sent with a discounted renewal offer if the organization supports it.

Can members upgrade their tier mid-cycle?

Yes. The renew_membership tool accepts an optional new_tier parameter. When upgrading mid-cycle, the agent prorates the difference between the current tier price and the new tier price. The expiration date remains unchanged — the member pays the difference and enjoys upgraded benefits for the remainder of their current term.


#MembershipManagement #CommunityOrganizations #EngagementTracking #AgenticAI #Python #LearnAI #AIEngineering

Share this article
C

CallSphere Team

Expert insights on AI voice agents and customer communication automation.

Try CallSphere AI Voice Agents

See how AI voice agents work for your industry. Live demo available -- no signup required.