Monitor New Google Reviews and Get Alerts with Node.js
A small Node.js job that checks your locations for new Google Maps reviews once a day and posts the negative ones to Slack before they pile up.
Updated 8 min readBy the ScrapeMapsAPI team
A negative Google review that sits unanswered for two weeks does more damage than the review itself: every prospect who reads it also reads your silence. Review monitoring fixes that by checking your locations for new reviews on a schedule and putting the bad ones in front of someone who can reply. Commercial reputation tools do this for a monthly fee per location; the core of it is a small script.
This guide builds that script in Node.js, in about a hundred lines with no dependencies. It runs every hour from cron, checks each location for reviews it has not seen before, stores the IDs of seen reviews in a local JSON file, and posts every new review at or below 3 stars to a Slack channel through an incoming webhook. You need Node.js 18 or newer (for the built-in fetch), an API key and a Slack webhook URL.
How it works
The Google Maps Reviews API returns the reviews of a place one page at a time, up to 20 per call. With sort=newest, the first page holds the most recent reviews. The monitor keeps a set of review IDs it has already seen for each location. On every check it reads pages from the newest backwards and stops as soon as it meets a review it knows: everything before that point is new.
Three design decisions keep it cheap and quiet:
- A baseline on the first run. The first time a location is checked, its current reviews are recorded without alerts. Otherwise you would get a Slack flood of every review from the last year.
- A page cap. At most three pages (60 reviews) per check. A location that gets more than 60 reviews between checks is rare, and the cap guarantees a bug can never page through thousands of reviews.
- One check per location per day. The cron job runs hourly, but each location is checked only when its last check is at least 24 hours old. The API caches review pages for up to 24 hours (the response says so in
meta.cachedand theX-Cacheheader), so checking the same place more often costs credits without surfacing reviews any sooner. Running hourly spreads many locations across the day.
Setup
Create a Slack incoming webhook (Slack app settings, "Incoming Webhooks", add one for the channel), then set two environment variables:
export SCRAPEMAPSAPI_API_KEY="key_your_api_key"
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."The API key comes from your dashboard after you sign up. You need the place ID of each location: the reviews endpoint accepts a ChIJ place ID, a CID or a feature ID. If you only have a Google Maps link, call GET /v1/places/resolve?input=<link> once and copy the place_id; our guide to place IDs, CIDs and feature IDs explains the formats.
Before writing code, check that a call works:
curl "https://api.scrapemapsapi.com/v1/places/ChIJ8cLgoQNUKhMReGlaTjwrH40/reviews?sort=newest&limit=5" \
-H "X-API-Key: $SCRAPEMAPSAPI_API_KEY"The script
Save this as monitor.mjs:
import { readFile, writeFile } from "node:fs/promises";
const API = "https://api.scrapemapsapi.com/v1";
const KEY = process.env.SCRAPEMAPSAPI_API_KEY;
const SLACK = process.env.SLACK_WEBHOOK_URL;
const STATE_FILE = new URL("./review-monitor-state.json", import.meta.url);
const CHECK_EVERY_HOURS = 24;
const ALERT_AT_OR_BELOW = 3; // stars
const MAX_PAGES = 3; // 60 reviews per check at most
const KEEP_IDS = 1000; // seen IDs remembered per location
const LOCATIONS = [
{ name: "Florence - Via dei Neri", place: "ChIJ8cLgoQNUKhMReGlaTjwrH40" },
// { name: "Another location", place: "ChIJ..." },
];
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function get(path, params) {
for (let attempt = 0; attempt < 5; attempt++) {
const res = await fetch(`${API}${path}?${new URLSearchParams(params)}`, {
headers: { "X-API-Key": KEY },
});
if (res.status === 429) {
await sleep(Number(res.headers.get("Retry-After") || 30) * 1000);
continue;
}
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${JSON.stringify(body.detail)}`);
return body;
}
throw new Error("still rate limited after 5 attempts");
}
async function loadState() {
try {
return JSON.parse(await readFile(STATE_FILE, "utf8"));
} catch {
return { places: {} };
}
}
async function newReviews(place, seen) {
const found = [];
let params = { sort: "newest", language: "en", limit: "20" };
let cid = null;
for (let page = 0; page < MAX_PAGES; page++) {
const body = await get(`/places/${place}/reviews`, params);
cid = body.meta.cid;
for (const review of body.data) {
if (seen.has(review.id)) return { found, cid };
found.push(review);
}
if (!body.pagination.has_more) break;
params = { cursor: body.pagination.next_cursor };
}
return { found, cid };
}
async function postToSlack(text) {
const res = await fetch(SLACK, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text }),
});
if (!res.ok) throw new Error(`Slack answered ${res.status}`);
}
function format(location, review, cid) {
const stars = "★".repeat(review.rating ?? 0) + "☆".repeat(5 - (review.rating ?? 0));
const text = review.translated_text ?? review.text ?? "(rating only, no text)";
const link = `https://www.google.com/maps?cid=${cid}`;
return `${stars} new review for *${location.name}* (${review.relative_date ?? review.published_at})\n> ${text.slice(0, 600)}\n${link}`;
}
const state = await loadState();
const now = Date.now();
for (const location of LOCATIONS) {
const entry = state.places[location.place] ?? { lastCheck: null, seen: [] };
if (entry.lastCheck && now - Date.parse(entry.lastCheck) < CHECK_EVERY_HOURS * 3600 * 1000) continue;
try {
const baseline = entry.lastCheck === null;
const { found, cid } = await newReviews(location.place, new Set(entry.seen));
if (!baseline) {
for (const review of found.filter((r) => (r.rating ?? 5) <= ALERT_AT_OR_BELOW)) {
await postToSlack(format(location, review, cid));
}
}
entry.seen = [...found.map((r) => r.id), ...entry.seen].slice(0, KEEP_IDS);
entry.lastCheck = new Date(now).toISOString();
state.places[location.place] = entry;
await writeFile(STATE_FILE, JSON.stringify(state, null, 2));
console.log(`${location.name}: ${found.length} new${baseline ? " (baseline)" : ""}`);
} catch (err) {
console.error(`${location.name}: ${err.message}`);
}
}A few details worth knowing:
- Translations.
language=enmakes the API return Google's English translation intranslated_textfor reviews written in another language, so a team in London can read a review left in Japanese. The original stays intext. - Rating-only reviews. Many Google reviews have stars but no text;
textis thennull, and the message says so. - No reviewer names. The API returns a pseudonymous author ID, never names or profile pictures. The Slack message links to the place on Google Maps, where you reply from your Business Profile as usual.
- State is written after every location, so a crash halfway through never re-sends alerts for the locations already done.
- Errors are per location. A
404 place_not_foundfor a deleted listing, or a temporary503, is logged and the next location goes on. Errors are never billed. The full list of codes is in the errors documentation.
Schedule it
Run it once by hand to record the baseline:
node monitor.mjsThen add an hourly cron entry on any always-on machine (a small VPS, a home server, a CI runner with persistent storage):
0 * * * * cd /opt/review-monitor && /usr/bin/node monitor.mjs >> monitor.log 2>&1The state file must survive between runs: that rules out stateless serverless functions unless you move the state to a database or a key-value store. The logic stays the same; only loadState and the writeFile call change.
Variations
The script is deliberately small, so adapting it is easy:
- Other channels. Microsoft Teams and Discord also accept incoming webhooks with a JSON body (Discord expects
contentinstead oftext). For e-mail, replacepostToSlackwith a call to your transactional e-mail provider. - A daily digest of positives. Collect the 4 and 5 star reviews in an array and post one summary message per run: "12 new reviews, average 4.6".
- Reply tracking. Each review carries
owner_response,nulluntil the owner replies. Re-reading the newest page lets you list negative reviews still unanswered after 48 hours and nudge the channel again. - Keywords. Alert on 4-star reviews too when they contain words like "dirty", "rude" or "refund".
- Trends. Append every new review to a CSV and you have a dataset for sentiment analysis with Python, or for tracking review velocity against competitors as in our local SEO competitor analysis.
What it costs
Every successful call costs 1 credit and returns up to 20 reviews. With one check per location per day, a location uses about 30 calls a month (a little more on days with more than 20 new reviews). The 200 free calls you get every month cover about six locations; a chain with 100 locations needs around 3,000 calls a month, $9 at the list price of $3 per 1,000 calls and less with credit packs (see pricing). Compare that with reputation tools billed per location per month.
Why not the official Places API?
Google's Places API returns at most 5 reviews per place, chosen by its own relevance ranking, and its newest-first sort still stops at 5. For monitoring you need every review in date order, which is what the cursor-paged reviews endpoint gives you. We compare the two approaches in Google Places API only returns 5 reviews.
To try it on one place first, the free reviews tool shows a place's newest reviews without an account. The API reference documents every parameter used above.
FAQ
How can I get notified of new Google reviews?
Google Business Profile can send owner notifications by e-mail, but for several locations or a team channel the usual approach is a scheduled script: read each location's reviews sorted by newest through a reviews API, compare the review IDs with the ones already seen, and post the new ones to Slack, Teams or e-mail.
How often should I check for new Google reviews?
Once a day per location is enough for most businesses and matches the API's review cache of up to 24 hours, so more frequent checks of the same place cost credits without finding reviews sooner. Run the job hourly and check each location when its last check is a day old to spread many locations over the day.
How do I avoid duplicate alerts for the same review?
Store the IDs of reviews you have already processed, for example in a JSON file per location, and alert only on IDs you have not seen. Record a baseline on the first run without alerting, and save the state after each location so a crash never sends the same alert twice.
Can I monitor Google reviews with the official Places API?
Only partially. The Places API returns at most 5 reviews per place, so on a busy location new reviews can be missed between checks and older ones are not available at all. A reviews API with cursor paging returns every review sorted by newest, which is what monitoring needs.
How much does Google review monitoring cost with an API?
With one check per location per day, each location uses about 30 API calls a month at 1 credit per call. The 200 free monthly calls cover about six locations; 100 locations need around 3,000 calls a month, about $9 at $3 per 1,000 calls.
Try it on your own data
Create a free account and get 200 free API calls every month. No credit card required.