task icon Task

Archive Gmail Messages

Archive emails from inbox based on search criteria or message IDs

Requirements
Search criteria or message IDs to archive
3

Determine what user wants to archive:

  • If user provided message IDs from a prior search, use those directly
  • If user provided search criteria, run taskSearch Gmail first to find messages
4

Write a preview draft with _action frontmatter:


_action:
label: "Archive messages"
prompt: "Archive these Gmail messages using the IDs listed below"
isComplete: false

Messages to Archive

  • Total: X messages
  • [Subject line 1] from [sender]
  • [Subject line 2] from [sender]
  • ... (up to 10, then "and X more...")

Message IDs: [comma-separated list]

Sauna displays this as a preview card with an "Archive messages" button.
User reviews the list, then clicks to archive.

6

Report results to user:

  • Success: "Done. Archived X messages—they're still in All Mail if you need them."
  • Partial: "Archived X of Y messages. Some failed: [details]"
  • Failure: "Couldn't archive messages: [error details]"
                    To run this task you must have the following required information:

> Search criteria or message IDs to archive

If you don't have all of this information, exit here and respond asking for any extra information you require, and instructions to run this task again with ALL required information.

---

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 CONSECUTIVE read steps in a row, read them all at once (in parallel). Otherwise, do not read a file until you reach that step.

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

## Steps

1. [Read External Actions Guide]: Read the documentation in: `skills/sauna/[skill_id]/references/sauna.actions.external.md` (Preview UI pattern for external actions)

2. [Read Gmail Guide]: Read the documentation in: `skills/sauna/[skill_id]/references/email.gmail.guide.md` (Reference Gmail search operators)

3. Determine what user wants to archive:
- If user provided message IDs from a prior search, use those directly
- If user provided search criteria, run `skills/sauna/[skill_id]/references/recipes/gmail.inbox.search.md` first to find messages


4. Write a preview draft with _action frontmatter:

---
_action:
  label: "Archive messages"
  prompt: "Archive these Gmail messages using the IDs listed below"
  isComplete: false
---

## Messages to Archive

- **Total:** X messages
- [Subject line 1] from [sender]
- [Subject line 2] from [sender]
- ... (up to 10, then "and X more...")

**Message IDs:** [comma-separated list]

Sauna displays this as a preview card with an "Archive messages" button.
User reviews the list, then clicks to archive.


5. [Gather Arguments: Archive Gmail Messages] The next step has the following requirements for arguments, do not proceed until you have all the required information:
- `messageIds`: {{messageIds}}
- `outputPath` (default: "session/archive-results.json"): session/archive-results.json

6. [Run Code: Archive Gmail Messages]: Call `run_script` with:

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

7. Report results to user:
- Success: "Done. Archived X messages—they're still in All Mail if you need them."
- Partial: "Archived X of Y messages. Some failed: [details]"
- Failure: "Couldn't archive messages: [error details]"