You know find_events from Day 11 and add_task from Day 14. Before your thesis meeting you want a task for every upcoming deadline. How do you automate that?
Call find_events with the calendar ID and a time window, then loop over the results and call add_task for each event. The event title becomes the task title.
Exactly the right sequence. find_events returns a list of event dicts — each has a summary key for the title. Loop and insert:
def upcoming_to_tasks(cal_id: str, list_id: str) -> list:
events = find_events(cal_id, "2026-04-20T00:00:00Z")
created = []
for event in events:
title = event.get("summary", "Untitled event")
task = add_task(list_id, f"Deadline: {title}", "Auto-created from Calendar")
created.append(task)
print(f"Created {len(created)} tasks from {len(events)} events")
return createdWhat if the same event is already a task? I don't want duplicates.
For the capstone scope, we don't de-duplicate — that would require fetching existing tasks and comparing titles, which is a more complex workflow. Keep the function simple: convert events to tasks. If duplication is a concern, run it only once per session or add a title prefix that's easy to filter:
def upcoming_to_tasks(cal_id: str, list_id: str) -> list:
events = find_events(cal_id, "2026-04-20T00:00:00Z")
created = []
for event in events:
title = event.get("summary", "Untitled event")
notes = f"Auto-created from Calendar event: {title}"
task = add_task(list_id, f"[CAL] {title}", notes)
created.append(task)
print(f"Created {len(created)} tasks from {len(events)} events")
return createdThe [CAL] prefix makes them easy to identify and delete if I re-run. That's a simple de-duplication signal without extra API calls.
Low-tech but effective. Prefix conventions are a real pattern in task automation — they make programmatically created items distinguishable from manually created ones at a glance.
The [CAL] prefix is search-friendly too. I can filter my task list by [CAL] to see which tasks came from automation and delete them in bulk if needed.
Exactly. Programmatic prefixes give you a built-in audit trail. Any task created by your script is immediately distinguishable from one you typed manually — useful for debugging and cleanup.
find_events(cal_id, time_min) → loop events → add_task(list_id, title, notes) per event
Event dict key: event.get('summary', 'Untitled event') — the event title. Always use .get() with a fallback — some events may have no summary field.
Return a list of created task dicts — one per event. The caller can inspect the list length to confirm how many tasks were created.
Use a [CAL] prefix on task titles to distinguish programmatically created tasks from manual ones. This makes bulk deletion and filtering straightforward without extra API calls.
You know find_events from Day 11 and add_task from Day 14. Before your thesis meeting you want a task for every upcoming deadline. How do you automate that?
Call find_events with the calendar ID and a time window, then loop over the results and call add_task for each event. The event title becomes the task title.
Exactly the right sequence. find_events returns a list of event dicts — each has a summary key for the title. Loop and insert:
def upcoming_to_tasks(cal_id: str, list_id: str) -> list:
events = find_events(cal_id, "2026-04-20T00:00:00Z")
created = []
for event in events:
title = event.get("summary", "Untitled event")
task = add_task(list_id, f"Deadline: {title}", "Auto-created from Calendar")
created.append(task)
print(f"Created {len(created)} tasks from {len(events)} events")
return createdWhat if the same event is already a task? I don't want duplicates.
For the capstone scope, we don't de-duplicate — that would require fetching existing tasks and comparing titles, which is a more complex workflow. Keep the function simple: convert events to tasks. If duplication is a concern, run it only once per session or add a title prefix that's easy to filter:
def upcoming_to_tasks(cal_id: str, list_id: str) -> list:
events = find_events(cal_id, "2026-04-20T00:00:00Z")
created = []
for event in events:
title = event.get("summary", "Untitled event")
notes = f"Auto-created from Calendar event: {title}"
task = add_task(list_id, f"[CAL] {title}", notes)
created.append(task)
print(f"Created {len(created)} tasks from {len(events)} events")
return createdThe [CAL] prefix makes them easy to identify and delete if I re-run. That's a simple de-duplication signal without extra API calls.
Low-tech but effective. Prefix conventions are a real pattern in task automation — they make programmatically created items distinguishable from manually created ones at a glance.
The [CAL] prefix is search-friendly too. I can filter my task list by [CAL] to see which tasks came from automation and delete them in bulk if needed.
Exactly. Programmatic prefixes give you a built-in audit trail. Any task created by your script is immediately distinguishable from one you typed manually — useful for debugging and cleanup.
find_events(cal_id, time_min) → loop events → add_task(list_id, title, notes) per event
Event dict key: event.get('summary', 'Untitled event') — the event title. Always use .get() with a fallback — some events may have no summary field.
Return a list of created task dicts — one per event. The caller can inspect the list length to confirm how many tasks were created.
Use a [CAL] prefix on task titles to distinguish programmatically created tasks from manual ones. This makes bulk deletion and filtering straightforward without extra API calls.
Create a free account to get started. Paid plans unlock all tracks.