DEV Community

March Pilot
March Pilot

Posted on

How to Automatically Schedule Office Cleanings Using Google Calendar API + Python

So there I was—Monday morning, buried in emails, trying to remember if I’d already booked a cleaning crew for the office or not. And no, sticky notes don’t help when you work remote.

That’s when it hit me: why not just automate it?

If you’re juggling multiple restaurant cleaning Glen Ellyn clients or just trying to keep your workspace consistently tidy, automating recurring bookings with the Google Calendar API is a total sanity-saver.


What You’ll Learn

  • Setting up Google Calendar API (without going gray)
  • Authenticating with OAuth2
  • Creating recurring cleaning events with Python
  • Formatting event details that make sense
  • Bonus: auto-emailing confirmations to your crew

Step 1: Enable Google Calendar API

Head over to the Google Cloud Consolehttps, create a new project, and enable the Calendar API.

Then, generate credentials. You’ll get a credentials.json file.


Step 2: Install Required Libraries

pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
Enter fullscreen mode Exit fullscreen mode

That’ll cover all your bases.


Step 3: Set Up Auth Flow

from google_auth_oauthlib.flow import InstalledAppFlow

flow = InstalledAppFlow.from_client_secrets_file('credentials.json', scopes=['https://www.googleapis.com/auth/calendar'])
creds = flow.run_local_server(port=0)
Enter fullscreen mode Exit fullscreen mode

Your browser will pop up asking for permission. Just follow the prompts.


Step 4: Create a Service Object

from googleapiclient.discovery import build

service = build("calendar", "v3", credentials=creds)
Enter fullscreen mode Exit fullscreen mode

Now you’re ready to start creating events.


Step 5: Build a Recurring Event

event = {
  'summary': 'Weekly Office Cleaning',
  'location': 'Main Office - 4th Floor',
  'description': 'Standard surface + floor package.',
  'start': {'dateTime': '2025-08-05T09:00:00-05:00', 'timeZone': 'America/Chicago'},
  'end': {'dateTime': '2025-08-05T10:30:00-05:00', 'timeZone': 'America/Chicago'},
  'recurrence': ['RRULE:FREQ=WEEKLY;BYDAY=TU'],
  'attendees': [{'email': 'crew@example.com'}]
}
Enter fullscreen mode Exit fullscreen mode

Tweak the details for your house cleaning in Glen Ellyn needs.


Step 6: Insert That Event

event_result = service.events().insert(calendarId='primary', body=event).execute()
print(f"Event created: {event_result.get('htmlLink')}")
Enter fullscreen mode Exit fullscreen mode

Done. That’s it. Really.


Bonus: Email Reminders

'reminders': {
  'useDefault': False,
  'overrides': [
    {'method': 'email', 'minutes': 60},
    {'method': 'popup', 'minutes': 10}
  ]
}
Enter fullscreen mode Exit fullscreen mode

Because your crew deserves a heads-up too.


Quick Case Study

After I rolled this out for a local team handling commercial cleaning services Glen Ellyn il their manager said, “Wait—this means I don’t have to check Google Sheets anymore?” Yep. Fully automated, zero effort.


Tools I Used

  • Google Calendar API (obviously)
  • Python 3.10
  • OAuth2 Playground for testing tokens
  • VS Code + Jupyter (for tinkering)

Final Thoughts

Whether you’re running a cleaning business or just trying to stay organized, setting up automated scheduling like this saves time, cuts stress, and seriously impresses clients.

Give it a try this week—you’ll see!

Top comments (0)