Machine Learning

Building My Personal AI Assistant: Stories, Part 2

the first part of my construction journey Fernãomy personal AI agent. Now it's time to continue the story and let's get into the second part!

In this post, I will walk you through the latest developments in Fernãorefining existing features and adding new capabilities to the agent. Let's start with what has changed.


Remember the task that downloaded the calendar in ICS (universal calendar format) and extracted my calendar tasks?

That work was a mess and showed poor architectural judgment. ICS calendars do not support native filtering, which means that all the application needs to do is pull all the events from the calendar and sort them afterwards. Actually, Fernão I've been downloading my entire program to release a few relevant meetings.

This was like bringing an entire library home just to look up one sentence in one book.

The more I tried to improve the work, the less I would get anywhere, because I needed a new system solution. I needed to change the way the system was getting the calendar and I CAN'T get around this problem with ICS.

So I dug deeper and found that Google offers calendar access through an API that supports native filtering. Fernão now it returns only the events it needs. This improved the productivity of the schedule, which dropped from about five minutes to about twenty seconds.

With this new pipe in place, I also included the surrounding concept. All work is now much cleaner and faster. Now we have a nice way to download calendar events via API:

def get_events_for_date(target_date=None, use_api=True):
    """
    Fetches events for a specific date from Google Calendar.
    Tries API first (if use_api=True), falls back to ICS if API fails.
    
    Args:
        target_date: datetime.date object for the target day. If None, uses today.
        use_api: If True, try Google Calendar API first. If False, use ICS only.
    
    Returns:
        List of event dictionaries.
    """
    if use_api and GCAL_API_AVAILABLE:
        print("[GCal] Attempting to use Google Calendar API...")
        try:
            events = get_events_for_date_api(target_date)
            if events is not None:
                print(f"[GCal] Successfully fetched {len(events)} events via API")
                return events
            else:
                print("[GCal] API returned None. Falling back to ICS...")
        except Exception as e:
            print(f"[GCal] API failed with error: {e}")
            print("[GCal] Falling back to ICS...")
    
    # Fallback to ICS
    print("[GCal] Using ICS feed method...")
    return get_events_for_date_ics(target_date)

.. and here is our API download:

def get_events_for_date_api(target_date=None):
    """
    Fetches events for a specific date from Google Calendar using the Calendar API.
    
    Args:
        target_date: datetime.date object for the target day. If None, uses today.
    
    Returns:
        List of event dictionaries, or None if API call fails.
    """
    service = get_calendar_service()
    if not service:
        return None
    
    day_start, day_end, target_date, tz_name, local = _get_local_time_range(target_date)
    
    print(f"n[GCal API] Fetching events for {target_date.strftime('%Y-%m-%d')}")
    print(f"  Timezone: {tz_name}")
    
    # Get calendar IDs from environment, or use primary
    calendar_ids_str = os.getenv('GCAL_CALENDAR_IDS', '')
    if calendar_ids_str:
        calendar_ids = [cid.strip() for cid in calendar_ids_str.split(',')]
    else:
        calendar_ids = ['primary']
    
    all_events = []
    
    # Fetch from each calendar
    for calendar_id in calendar_ids:
        try:
            print(f"[GCal API] Fetching from calendar: {calendar_id}")
            
            # Call the Calendar API with timeoutlobally
            old_timeout = socket.getdefaulttimeout()
            socket.setdefaulttimeout(10)
            
            try:
                events_result = service.events().list(
                    calendarId=calendar_id,
                    timeMin=day_start.isoformat(),
                    timeMax=day_end.isoformat(),
                    singleEvents=True,
                    orderBy='startTime'
                ).execute()
            finally:
                socket.setdefaulttimeout(old_timeout)
            
            events = events_result.get('items', [])
            print(f"[GCal API] Found {len(events)} event(s) in {calendar_id}")
            
            # Parse events
            for event in events:
                # Get start time
                start = event['start'].get('dateTime', event['start'].get('date'))
                end = event['end'].get('dateTime', event['end'].get('date'))
                
                # Parse datetime
                if 'T' in start:  # DateTime
                    start_dt = datetime.fromisoformat(start.replace('Z', '+00:00'))
                    end_dt = datetime.fromisoformat(end.replace('Z', '+00:00'))
                    
                    # Convert to local timezone
                    start_local = start_dt.astimezone(local)
                    end_local = end_dt.astimezone(local)
                    
                    start_str = start_local.strftime("%H:%M")
                    end_str = end_local.strftime("%H:%M")
                else:  # All-day event
                    start_str = "00:00"
                    end_str = "23:59"
                
                all_events.append({
                    "title": event.get('summary', 'Untitled Event'),
                    "start": start_str,
                    "end": end_str,
                    "location": event.get('location', ''),
                    "description": event.get('description', '')
                })
        
        except Exception as e:
            print(f"[GCal API] Error fetching from {calendar_id}: {e}")
            continue
    
    # Sort by start time
    all_events.sort(key=lambda x: x["start"])
    
    print(f"[GCal API] Total events: {len(all_events)}")
    return all_events

Besides the back-end improvements, I have also added new features to the assistant.

In the schedule view, I can now mark tasks as completed. The nice thing is that when I do it, they automatically sync too Microsoft To-Do app.

Examining activities in the app – Image By Author
Examining activities in the app – Image By Author

It's amazing!

It makes me think that, over time, many of us will end up building our own “personal apps”, integrating workflows into the tools we like, integrating what we need, and switching components whenever better options arise. If features become easy to replicate, loyalty to certain platforms will weaken.

This also raises an interesting question: will companies eventually try to lock down their systems by limiting APIs and external integrations? It is possible. But isolation will not work in the long run. If users can't plug tools into their workflow, they'll just go somewhere else (… and is this going to be a power-user-only behavior?)

With this new ability in Schedule Maker, I went ahead and made another feature Fernãosuggested one of the students.

Introducing: Task Breaker.

Fernão's new job-breaking role – Photo by Author – Produced by Gemini

I Task Breaker follows a simple application:

  • Start with a large, medium task Microsoft To Do;
  • Add context on how work should be broken down;
  • Fernão destroys the work and creates a plan;
  • The resulting tasks are saved back to Tasks on set dates, and later appear in the daily assistant;
Fernão Task Breaker – Photo by Author

Here's how Task Breaker appears in the sidebar:

Task Breaker Module – Image By Author

And here is the current (still solid) front of the Task Breaker:

Task Breaker Module – Image By Author

Let's take a real example. One of the biggest tasks sitting on my To-Do list Project Writing at DareData. This is not a small functional project, it is a structural project.

The goal is to consolidate and formalize internal company information in Notion, ensuring that key questions about the business are clearly answered for us. Knowledge Hub. That means reviewing all departments, identifying gaps, creating or modifying pages, organizing information appropriately, and assigning clear ownership to each section.

Essentially, this requires auditing, documentation, and management decisions. It's not something you “just do” all at once and I want to finish it in three weeks. In fact, I can dedicate between 30 minutes to one hour a day.

This is exactly the kind of task that benefits from decomposition, so I'm going to use some context knowledge in Task Breaker and turn this gigabyte of work into a working program:

I’m currently building our Knowledge Hub in Notion. Here’s the current structure of Notion and Departments:

# DareData Hub

## Handbook for Network Members

[DareData Network Member Handbook ]

## Teams

### Sales & Partnerships

### Marketing (Brand and Gen-OS)

### Finance

### Delivery

[Tech Specialists]

[Principals]

[Account Managers]

I’ll need to:

- Go Through Every department and create the pages that make sense (search the web for more context on what DareData is if you need ideas of the pages I need to create on every department or use your knowledge on what definitely needs to be documented in a 130 people B2B company).

- Make sure that every page has an Owner

- Revisit the Suggestions recorded by my team in the suggestions, I can probably pick one or two suggestions every day

- Add some departments that are not in there: Admin, Core Members, Finance, Product

I have around 30 minutes to 1 hour to work every day and want to complete this project by 7 March 2026.

After clicking “separation”, Fernão will start doing:

Fernão Forging the Task – Image by Author

Amazing x2!

Work Breakdown – Photo by Author

Now we can review the tasks and the generated schedule and send it to my Microsoft To-Do. I also need to assign which list in Microsoft To-Do they will be assigned to:

Microsoft To-Do List – Image by Author

Good! Let's see how it looks in the Microsoft app:

Perfecto.

While testing this, I realized I wanted to fix two things.

  • First, Fernão it's meant to be an ancient writer, not a fictional hero, so I'm going to change the composition design. Her clothes should feel comfortable.
  • Second, on a practical note, I need “Send All” button. Moving tasks one by one is tedious, especially when analyzing large projects.

Let's break down another function after making these changes:

Fernão now you make a proper medieval vest:

Fernão invents again – Photo by Author

And now we can use the good”Send All” button:

Post new jobs To Do – Photo By Author

I might remove the emoji. That kind of”emojification” is very familiar to the LLM generated code before, and it really annoys me.

Anyway, building this new feature Fernão it was really satisfying. If you have ideas for additional features, I'm open to suggestions!

Below is the current command I use to split the job. I will continue to refine it as I try and see how it works in real use cases.

name: task_breakdown
description: Break down a task into 20-minute actionable subtasks
max_tokens: 4096

variables:
- task_name
- task_context
- current_date
template: |
You are a productivity expert helping break down complex tasks into manageable 20-minute chunks.

**CURRENT DATE:** {current_date}
**TASK TO BREAK DOWN:**
{task_name}
**CONTEXT PROVIDED BY USER:**
{task_context}

**YOUR JOB:**

Break this task into specific, actionable subtasks that can each be completed in approximately 20 minutes.
**RULES:**
1. Each subtask should be concrete and actionable (starts with a verb)
2. Each subtask should take ~20 minutes (can be 15-25 min, but aim for 20)
3. Subtasks should follow a logical order
4. Be specific - avoid vague tasks like “work on X”
5. If the task is already small enough, you can create 1-3 subtasks
6. If it’s large, create > 5 subtasks
7. Consider the context provided - use it to make subtasks relevant and specific
8. **SCHEDULING:** Based on the user’s context (e.g., “every other day”, “weekends only”), suggest a specific Due Date for each task starting from the Current Date.

**OUTPUT FORMAT:**

Return ONLY a markdown list of subtasks in this format:
- {task_name} - [Subtask description] (20 min) [Due: YYYY-MM-DD]

Example:
- {task_name} - Create project repository (20 min) [Due: 2026-02-13]
- {task_name} - Configure CI/CD pipeline (20 min) [Due: 2026-02-15]
Do NOT include any other text or explanations. Just the list.

In parallel, I am already working on several new modules:

  • A Dividend Analyzer making income from my stocks and ETFs
  • A Writing Assistant creating an editorial plan for my writing.
  • A Discounts module to check the relevant promotions when I plan to buy
  • A Guitar editor planning and scheduling practice sessions whenever I pick up my guitar

Stay tuned for the next modules and hope this inspires you in your own projects too!

Source link

Related Articles

Leave a Reply

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

Back to top button