Skip to main content
This guide walks you through building a complete Gmail agent with NSP. By the end you will have a working Python script that reads your inbox, archives messages, sends verified replies, and reacts to new emails in real time — all by talking directly to Gmail’s live runtime state through the NSP daemon, with no browser automation or UI scraping involved.
1

Prerequisites

Before you start, confirm you have everything in place:
  • NSP daemon installed and running. Download the latest Nelieo NSP Setup.exe from platform.nelieo.com/download. The installer registers the daemon as a Windows Service that auto-starts on login and listens on port 7842.
  • Chrome launched with the remote debugging port enabled. NSP reads Gmail’s V8 state through the Chrome DevTools Protocol (CDP). You must start Chrome with the flag before opening Gmail.
  • Gmail open in a tab. Navigate to mail.google.com after Chrome is running.
  • Python 3.11+ and the NSP SDK installed.
  • An NSP API key from platform.nelieo.com.
Launch Chrome with CDP enabled:
Close all existing Chrome windows before running either command. Chrome only supports one debugging session per user profile — if another instance is already running, it silently ignores the flag.
Install the SDK:
Set your API key as an environment variable so you never hardcode it:
2

Connect to Gmail

NSPClient manages the connection to your local daemon. Call attach() with the app name — NSP resolves the correct process automatically, so you never need to track PIDs yourself.
Expected output:
If Gmail has not been probed yet (first run), attach() may take up to 30 seconds while the daemon runs a cold V8 heap snapshot. On subsequent runs the schema is cached and attachment completes in under a second. Use client.wait_for_app("Gmail", timeout=30.0) if you want an explicit timeout with automatic retries.
3

Read Inbox State

Once attached, read typed state values directly from the session using dot-notation keys. NSP normalises Gmail’s V8 runtime data into the Substrate Schema Format (SSF) so every key is stable and predictable across probe cycles.
Expected output:
4

List Available Actions

Every session exposes the actions that NSP discovered for the current app. Iterate session.actions to see what your agent can do, along with each action’s type signature and reversibility classification.
Example output:
Pay attention to the reversibility column. Actions classified as irreversible_write (like send_reply and delete) require you to pass verify=True and a verify_expression — NSP enforces this automatically and raises NSPIrreversibleNotConfirmedError if you omit it.
5

Archive an Email (Reversible)

archive is a reversible_write action — it moves an email out of your inbox but you can undo it by unarchiving later. Reversible actions do not require a verify_expression, though you can add one for extra confidence.
Expected output:
6

Send a Reply (Irreversible)

send_reply is an irreversible_write action — once sent, the email cannot be recalled. NSP requires verify=True and a verify_expression for all irreversible actions. The daemon executes the action, then polls post-action state until your expression evaluates to true (or the timeout elapses).
Expected output:
Omitting verify=True on an irreversible action raises NSPIrreversibleNotConfirmedError immediately — the action is never dispatched. This is a safety contract, not a hint.
7

Watch for New Emails (Real-Time Streaming)

Instead of polling for changes, open a WebSocket watch stream. The daemon fires an event on every probe cycle (roughly every 2 seconds) that contains a list of which state keys changed. Use auto_refresh_on_event=True so that session.get_*() calls inside the loop always return the latest values.
Expected output (as new mail arrives):

Full Agent Script

The script below combines every step above into a single, copy-pasteable file. It reads the inbox on startup, prints a summary, then streams for new arrivals and auto-replies to each one.
Expected output: