task icon Task

Setup Gmail Connection

Instructions
You MUST use a todo list to complete these steps in order. Never move on to one step if you haven't completed the previous step. If you have multiple read steps in a row, read them all at once (in parallel).
1

Check if the Gmail profile exists in uiConnection Profiles with a 'Last analyzed:' timestamp.
If fresh (< 30 days): Show you know them - 'You email Person-A and Person-B a lot. Most of your threads are about topic-X.' Then ask what they want to do. STOP here.
If stale (> 30 days): 'Been a while since I checked your inbox - want me to refresh?' If they decline, use existing profile. STOP if they decline.
If no profile exists: Proceed to next step.

2

Ask permission casually with time estimate: 'Mind if I look at your inbox? Takes about 3 mins.' Wait for confirmation before proceeding.

3

Say 'Checking...' then run the code.

5

Check the code output. If success is false or counts are 0, tell the user: 'We can't connect to gmail right now.'

6

Verify both uiGmail Profile Analysis and uiGmail Writing Samples were written. Check both files exist and contain data. If either is missing or empty, tell the user the Gmail connection failed and stop - do not proceed to subagents.

11

Present your findings:

  1. Lead with 1-2 genuine insights from the data. The discovery data is your goldmine — if they have travel bookings, pets, or platform usage, lead with that.
    Example: 'I noticed you travel a fair amount — lots of booking confirmations. You email Sarah and Mike the most, and it's mutual.'

  2. List what was added to their knowledge:

    • Gmail profile
    • Writing style
    • User profile
    • Key people
  3. End with (bold): 'I'll use this to personalize how I help you going forward.'

                    You MUST use a todo list to complete these steps in order. Never move on to one step if you haven't completed the previous step. If you have multiple read steps in a row, read them all at once (in parallel).

Add all steps to your todo list now and begin executing.

## Steps

1. Check if the Gmail profile exists in `./documents/connections/[service-name].md` with a 'Last analyzed:' timestamp.
If fresh (< 30 days): Show you know them - 'You email Person-A and Person-B a lot. Most of your threads are about topic-X.' Then ask what they want to do. STOP here.
If stale (> 30 days): 'Been a while since I checked your inbox - want me to refresh?' If they decline, use existing profile. STOP if they decline.
If no profile exists: Proceed to next step.

2. Ask permission casually with time estimate: 'Mind if I look at your inbox? Takes about 3 mins.' Wait for confirmation before proceeding.

3. Say 'Checking...' then run the code.

4. [Gather Arguments: Connect to Gmail] The next step has the following requirements for arguments, do not proceed until you have all the required information:
- `profileOutputPath`: ./documents/tmp/gmail-profile-analysis.json
- `writingSamplesOutputPath`: ./documents/tmp/writing-samples-gmail.json

5. [Run Code: Connect to Gmail]: Call `run_script` with:

```json
{
  "file": {
    "path": https://sk.ills.app/code/gmail.inbox.connect/preview,
    "args": [
      "profileOutputPath",
      "writingSamplesOutputPath"
    ]
  },
  "packages": null
}
```

6. Check the code output. If success is false or counts are 0, tell the user: 'We can't connect to gmail right now.'

7. Verify both `./documents/tmp/gmail-profile-analysis.json` and `./documents/tmp/writing-samples-gmail.json` were written. Check both files exist and contain data. If either is missing or empty, tell the user the Gmail connection failed and stop - do not proceed to subagents.

8. Run these 4 tasks in parallel as subagents:
- `./skills/sauna/[skill_id]/references/recipes/gmail.inbox.profile.md` → writes `./documents/connections/[service-name].md`
- `./skills/sauna/[skill_id]/references/recipes/context.style.analyze.md` → writes `./documents/user/writing_style.md`
- `./skills/sauna/[skill_id]/references/recipes/gmail.profile.discover.md` → writes `./documents/user/[personal|work|goals|interests].md`
- `./skills/sauna/[skill_id]/references/recipes/gmail.entities.extract.md` → writes `./documents/entities/people/*.md`


9. Clean up: delete `./documents/tmp/gmail-profile-analysis.json` and `./documents/tmp/writing-samples-gmail.json`

10. [Read Wow Moments Framework]: Read the documentation in: `./skills/sauna/[skill_id]/references/context.wow.framework.md` (Core principles for presenting insights)

11. [Read Gmail Wow Moments]: Read the documentation in: `./skills/sauna/[skill_id]/references/gmail.inbox.wow.md` (Gmail-specific wow patterns)

12. Present your findings:

1. Lead with 1-2 genuine insights from the data. The discovery data is your goldmine — if they have travel bookings, pets, or platform usage, lead with that.
Example: 'I noticed you travel a fair amount — lots of booking confirmations. You email Sarah and Mike the most, and it's mutual.'

2. List what was added to their knowledge:
   - Gmail profile
   - Writing style
   - User profile
   - Key people

3. End with (bold): 'I'll use this to personalize how I help you going forward.'