Gmail sync

From Alex8791-cyber/cognithor · View interactive version

Gmail sync is an AI agent skill from the GitHub repository Alex8791-cyber/cognithor. API integration skill that fetches Gmail messages, syncs inbox labels, and processes attachments via the Gmail REST API. Use when fetching new emails, syncing inbox state, triaging unread messages, exporting mail data, or integrating Gmail into automated workflows.

How to use this skill

Skill file

Gmail Sync

Fetches Gmail messages, syncs labels, and processes attachments via the Gmail REST API using httpx. Requires network access.

Steps

  1. Authenticate — obtain or refresh the OAuth2 token:

```python

headers = {"Authorization": f"Bearer {access_token}"}

```

  1. Fetch new messages since the last sync timestamp:

```python

async with httpx.AsyncClient() as client:

resp = await client.get(

f"{API_BASE}/messages",

headers=headers,

params={"q": "after:{last_sync_epoch}"}

)

messages = resp.json().get("messages", [])

```

  1. Parse each message — extract sender, subject, body, labels, and attachment metadata
  2. Store locally — persist parsed data under $COGNITHOR_HOME/data/gmail/ as JSON
  3. Return summary — the skill returns {"data": <parsed_response>} with message counts

Example

User > Synchronisiere meine Gmail-Inbox
Cognithor > 14 neue Nachrichten synchronisiert (3 ungelesen, 2 mit Anhängen)
         Letzte Synchronisation: 2026-04-20 14:00 UTC

Error Handling

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.