How to Build a Twitter Mention Monitor

A Twitter mention monitor runs a search for your brand's handle, name, website and common misspellings on a schedule, removes your own posts, and sends each new mention to your team, sorted into questions, complaints and praise.

Cover card reading 'How to Build a Twitter Mention Monitor'

A Twitter mention monitor runs a search for your brand’s handle, name, website and common misspellings on a schedule, removes your own posts, and sends each new mention to your team, sorted into questions, complaints and praise. With apidojo’s Twitter Scraper Unlimited on Apify, an hourly mention check costs $0.016 per run plus a small fee per mention beyond the first 40.

The scheduling, deduplication and cost model come from how to monitor a keyword on X with an API. This guide adds what’s specific to mentions: the query, the triage and the routing.

How Do You Write a Mention Query?

Write one query that catches every way people refer to your brand, then remove your own account and reposts. Listed below are the 5 parts of a mention query (twitter-advanced-search reference).

  1. Your handle: @acme.
  2. Your name, in quotes if it has more than one word: "acme analytics".
  3. Your domain: url:acme.com.
  4. Common misspellings: acmee OR akme.
  5. Exclusions: -from:acme -filter:retweets.
(@acme OR "acme analytics" OR url:acme.com OR acmee) -from:acme -filter:retweets within_time:2h

Mention search by hand is covered in how to search tweets mentioning a user.

How Do You Sort Mentions Into Questions, Complaints and Praise?

Sort mentions with simple keyword rules first; they route most posts correctly and are easy to adjust. The table shows a starting set; tune the words to your product.

Category Matching words Route to
Complaint broken, refund, not working, worst, cancel, bug Support, urgent
Question ?, how do, does it, anyone know, help Support
Praise love, thanks, great, recommend Marketing
Other everything else Daily digest

How Do You Build the Monitor in Python?

Run the query through Twitter Scraper Unlimited, skip post IDs you’ve already handled, label each new mention and send it to the right channel. The fields come from the actor’s output example (Apify).

import json, os, pathlib, requests
from apify_client import ApifyClient

QUERY = '(@acme OR "acme analytics" OR url:acme.com) -from:acme -filter:retweets within_time:2h'
RULES = {
    "complaint": ["broken", "refund", "not working", "worst", "cancel", "bug"],
    "question": ["?", "how do", "does it", "anyone know", "help"],
    "praise": ["love", "thanks", "great", "recommend"],
}
WEBHOOKS = {"complaint": os.environ["SUPPORT_HOOK"], "question": os.environ["SUPPORT_HOOK"],
            "praise": os.environ["MARKETING_HOOK"], "other": os.environ["DIGEST_HOOK"]}

def label(text: str) -> str:
    t = text.lower()
    for name, words in RULES.items():
        if any(w in t for w in words):
            return name
    return "other"

seen_file = pathlib.Path("seen_mentions.json")
seen = set(json.loads(seen_file.read_text())) if seen_file.exists() else set()
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("apidojo/twitter-scraper-lite").call(run_input={"searchTerms": [QUERY], "sort": "Latest"})

for t in client.dataset(run.default_dataset_id).iterate_items():
    if t["id"] in seen:
        continue
    kind = label(t["text"])
    requests.post(WEBHOOKS[kind], json={"text": f"[{kind}] @{t['author']['userName']}: {t['text']}\n{t['url']}"})
    seen.add(t["id"])

seen_file.write_text(json.dumps(sorted(seen)))

Run it hourly with cron or an Apify schedule, as described in how to monitor a keyword on X with an API.

What Does a Mention Monitor Cost?

An hourly mention monitor costs $11.52 over 30 days in query fees, plus $0.0004 for each mention beyond the first 40 in a run. A brand with 20 mentions an hour stays inside the included results; a brand with 200 an hour adds about $0.064 per run (Apify).

How Do You Report on Mentions Over Time?

Store every labelled mention with its date and engagement, then chart weekly counts by category. A rising share of complaints is an early warning; a spike in praise after a launch is a result to share. Scoring tone more precisely than keyword rules is covered in how to collect tweets for sentiment analysis.

Questions people ask

Does a mention monitor catch posts that don't tag the brand?

Yes, if the query includes your name and domain, not just the handle.

Can you monitor competitors' mentions too?

Yes, add their handles and names as separate queries; see how to build a competitor tweet tracker.

Where do you start?

At the apidojo Twitter Scraper.