Contents
To monitor X (Twitter) mentions programmatically, you poll a mentions endpoint on an interval, diff the results against the mentions you have already seen, and act only on the new ones. There is no need for an open stream or the expensive official X API. This guide shows the polling pattern with runnable code using the XAutoDM API.
Mentions are a high-signal lead source: someone naming your handle or brand is already engaged. Catching them automatically means you can reply, log, or reach out while the interest is fresh.
The pattern: poll, diff, act
Real-time streams are fragile and most data APIs do not offer one. The robust approach is a loop:
- Poll the mentions endpoint every few minutes.
- Diff the returned mentions against a stored set of IDs you have already handled.
- Act on the new ones (notify, log, or reach out), then add them to the seen set.
This is the same durable pattern behind reply tracking and any "watch for new X" automation.
Fetch mentions
Mentions are a scrape source on the XAutoDM API, so you request them the same way as any other source, by passing
source_type: "mentions"curl -X POST https://app.xautodm.com/api/v1/scrapes \ -H "Authorization: Bearer xad_live_..." \ -H "Content-Type: application/json" \ -d '{ "source_type": "mentions", "source_value": "yourhandle", "count": 100 }'
You need an API key, which you request on the API page while the API is in early access.
The polling loop in Node.js
const seen = new Set(); // persist this across runs (DB, file, KV) async function checkMentions() { const res = await fetch("https://app.xautodm.com/api/v1/scrapes", { method: "POST", headers: { "Authorization": "Bearer xad_live_...", "Content-Type": "application/json", }, body: JSON.stringify({ source_type: "mentions", source_value: "yourhandle", count: 100 }), }); const { data } = await res.json(); for (const m of data) { if (seen.has(m.id)) continue; // already handled seen.add(m.id); await handleMention(m); // notify, log, or reach out } } setInterval(checkMentions, 10 * 60 * 1000); // every 10 minutes
The
seenSeed the seen set on first run
The first time you run this, mark everything currently returned as already-seen and do nothing with it. Otherwise your very first poll treats every historical mention as new. On subsequent polls, only genuinely new mentions get through.
// First run: seed, do not act const first = await fetchMentions(); first.forEach((m) => seen.add(m.id));
Pace your polling
Every poll costs credits, so match the interval to how fast you actually need to react. Every 5 to 15 minutes is near-real-time for outreach and social listening. Tighter cadences cost more and rarely change the result.
Turning a mention into a booked call
Detecting a mention is step one. If the account fits your customer profile, the natural next move is paced, personalized outreach, which the same platform handles. Keep any automated DMs personalized and under X's DM limits so you stay safe. For the full data side, see how to scrape X data with an API, and request a key on the API page.
Your next customer is already on X.
Find the people talking about what you sell, message them on a safe schedule, and turn the replies into booked calls.
- Scrape leads from any tweet, keyword or X List
- Auto-DM new followers and people who engage
- Follow-ups that stop the moment someone replies
- Safe daily limits and warm-up, built in
- Every reply tracked through to a booked call
Free Test plan · no credit card.
Related posts
Ready to automate your Twitter DMs?
Start sending personalized DM campaigns to your target audience today. Get higher response rates and more leads than cold emails.








