Skip to main content
NSP attaches to Gmail running in Chrome and exposes a live state tree you can query and act on from Python. This guide walks you through every step — from connecting to the Chrome debug port all the way to streaming new-email notifications as they land.

Prerequisites

Before you write any code, make sure the following are in place:

Chrome Debug Port

Chrome must be running with --remote-debugging-port=9222. See the Chrome Setup guide for launch instructions.

Gmail Open

Open mail.google.com in a Chrome tab. The daemon matches the tab by URL within about 5 seconds.

NSP Daemon Running

Run axon-daemon.exe run (or start the Windows Service). The daemon listens on http://localhost:7842 by default.

SDK Installed

Install the Python SDK: pip install nelieo-nsp

Step 1 — Verify Gmail Is Detected

Before building your agent, confirm the daemon has picked up Gmail. Run a quick list check:
Gmail should appear with confidence >= 0.95. If it doesn’t show up yet, wait 30–60 seconds for the cold probe to complete.

Step 2 — Connect to Gmail

Use wait_for_app instead of a bare attach call. It retries until Gmail is ready, which is safer on startup:

Step 3 — Read Inbox State

Call session.refresh() before reading to get the latest snapshot, then pull fields from the state tree using typed accessors:

Available inbox state keys

Step 4 — Send a Reply

send_reply and send_email are both irreversible_write actions. Once dispatched, the message is sent and cannot be recalled. Always pass verify=True with a verify_expression to confirm the send succeeded before your agent continues.

Step 5 — Archive and Mark as Read

These are reversible_write actions so they don’t require a verify_expression, though adding one is still good practice:

Step 6 — Stream New Emails in Real Time

Use session.watch() with auto_refresh_on_event=True so the session state is always current inside the loop. Filter on inbox.unread_count to detect arrivals:
The /watch WebSocket endpoint is not subject to the daemon’s rate limiter. You can keep a stream open indefinitely without consuming your request quota.

Complete Agent

Here is the full working agent combining all of the above steps:

Available Gmail Actions

Start with reversible_write actions like archive and mark_read while testing. Only enable send_reply and send_email once you’re confident in your agent’s logic.