惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
量子位
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
V
Visual Studio Blog
雷峰网
雷峰网
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Track Email Opens From Your Agent's Outreach
Qasim Muhammad · 2026-06-14 · via DEV Community

You built an outreach agent, it sent 80 follow-ups this week, and you have no idea what happened to any of them. Did the prospect open the message? Click the demo link? Is the silence a "no" or a spam-folder problem? Without engagement signals, your agent is firing into the void and your follow-up logic is guesswork.

The fix has two parts: turn tracking on when you send, and subscribe to the webhooks that report what recipients do.

Tracking starts at send time, not after

Opens, clicks, and replies are only reported for messages sent with tracking enabled — you can't retroactively track a message that's already out. On the Send Message request, pass a tracking_options object with three booleans plus an optional label that gets echoed back in every notification:

curl --request POST \
  --url 'https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/messages/send' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --data-raw '{
    "subject": "Quick follow-up on your trial",
    "body": "Thanks for trying us out. Reply or <a href=\"https://example.com/demo\">book a demo</a> when ready.",
    "to": [{ "name": "Kim Townsend", "email": "kim@example.com" }],
    "tracking_options": {
      "opens": true,
      "links": true,
      "thread_replies": true,
      "label": "trial-followup-q2"
    }
  }'

The label is the piece agents should lean on: stamp it with your campaign ID or contact ID and every later notification carries it, so your handler matches events back to outreach state without storing a message-ID mapping. One caveat before you test: message tracking needs a production application — trial accounts get "Tracking options are not allowed for trial accounts" back.

Three triggers, one endpoint

Engagement events arrive over webhooks. Subscribe one HTTPS endpoint to all three triggers — message.opened, message.link_clicked, and thread.replied:

curl --request POST \
  --url 'https://api.us.nylas.com/v3/webhooks/' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --data-raw '{
    "trigger_types": ["message.opened", "message.link_clicked", "thread.replied"],
    "webhook_url": "https://yourapp.com/webhooks/nylas",
    "description": "Email engagement tracking"
  }'

One activation detail trips people up: when you create the webhook, Nylas sends a GET request with a challenge query parameter, and your endpoint has to echo it back before the subscription goes live. If your route only handles POST, the webhook never activates and you'll be staring at zero events wondering why.

Each payload names the tracked message's ID, your label, and a recents array holding the last 50 events for that message — each stamped with a timestamp, IP, and user agent. Return 200 OK within 10 seconds or the delivery counts as failed and gets retried, which an idempotency-naive agent will misread as a second open.

A minimal handler that covers the challenge handshake and routes on trigger type:

from flask import Flask, request

app = Flask(__name__)

@app.route("/webhooks/nylas", methods=["GET", "POST"])
def nylas_webhook():
    if request.method == "GET":
        return request.args.get("challenge", ""), 200

    event = request.get_json()
    trigger = event["type"]
    message_id = event["data"]["object"]["message_id"]

    if trigger == "message.opened":
        record_open(message_id)        # soft signal — log it, don't act on it
    elif trigger == "message.link_clicked":
        warm_up_sequence(message_id)   # real human action
    elif trigger == "thread.replied":
        stop_sequence(message_id)      # strongest signal — hand off the thread

    return "", 200

The three trigger names map cleanly onto agent decisions, which is why routing on event["type"] at the top of the handler beats funneling everything into one "engagement" counter.

The three signals are not equally honest

Here's where outreach agents go wrong: treating an open as intent.

Open tracking works by embedding a transparent one-pixel image that the recipient's client loads. Corporate gateways and privacy-focused clients block remote images, silently dropping real opens. Worse, prefetching proxies do the opposite — Apple Mail Privacy Protection, on by default since iOS 15, pre-loads images through Apple's proxy and registers an open whether or not a human read anything. Apple's share of the email client market sits near 50%, so a large slice of your open data is inflated. Report opens as "opened at least once," never as a read count, and never let your agent escalate on an open alone.

Clicks are sturdier: a click is a real human action. With links: true, every valid HTML anchor in the body gets rewritten to a tracking URL (capped at 100 tracked links per message, and URLs carrying login credentials are skipped so authenticated destinations don't break). Replies, via thread.replied, are the strongest signal of the three — unambiguous intent.

A sane decision policy for an outreach agent: open → no action, maybe shorten the follow-up interval; click → move the contact to a warmer sequence; reply → stop the sequence immediately and hand the thread to your reply-handling logic.

A caveat if your agent sends from its own mailbox

If your outreach agent runs on a Nylas-hosted Agent Account — the beta feature that gives an agent its own dedicated mailbox rather than a connected Gmail or Outlook grant — know that native message tracking isn't available on its direct API sends. message.opened and message.link_clicked aren't emitted for messages sent through POST /messages/send on those accounts. Deliverability visibility comes instead from the send-side triggers: message.send_success, message.send_failed, and message.bounce_detected.

In practice that's a reasonable trade. Send-side triggers tell you what actually got delivered or bounced, replies still land in the agent's inbox and fire message.created, and reply-based routing — the strongest signal anyway — works exactly the same. The tracking flags above apply when you're sending through connected provider grants, which is how a lot of outreach tooling runs.

Two smaller gotchas

Each trigger also ships a .legacy variant — message.opened.legacy, message.link_clicked.legacy, thread.replied.legacy — for applications on the older notification format. New integrations should subscribe to the non-legacy names; mixing the two gets you duplicate events with different payload shapes, which is a miserable thing to debug.

And remember what tracking actually does: it rewrites your message content and pixels your recipients. The flags work the same whether the sending grant is Google, Microsoft, or another provider, so one send path covers your whole sender base — but that also means your disclosure obligations follow every message. Honor consent, disclose tracking where your jurisdiction requires it, and don't track links that carry sensitive data.

Wire the weakest signal last

Build the reply path first, clicks second, opens last — the reverse of how most teams do it, and the order that matches signal quality. Full payload schemas and per-provider behavior are in the tracking recipe.

Next step: add tracking_options to one live campaign, log the three trigger types for a week, and compare your open rate against your click rate. If they tell wildly different stories — which signal is your follow-up logic currently trusting?