Skip to content

Google Business new components #18074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 19, 2025

Conversation

GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented Aug 15, 2025

Closes #17821

Summary by CodeRabbit

  • New Features

    • New actions: fetch reviews across multiple locations, retrieve a specific review by ID, and list all reviews for a location.
    • New source: monitor new reviews across multiple locations and a source that summarizes new review content.
  • Bug Fixes

    • Added null-safety to review processing to prevent errors when no items are returned.
  • Chores

    • Updated versions/metadata for several Google My Business actions/sources and bumped package to 0.2.0.

Copy link

vercel bot commented Aug 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Ignored Ignored Preview Aug 15, 2025 8:53pm
pipedream-docs Ignored Ignored Aug 15, 2025 8:53pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Aug 15, 2025 8:53pm

Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

Walkthrough

Adds Google My Business review actions and sources, app endpoints and request/response types, multiple metadata version bumps, and a small error-message enhancement to JSON parse errors in the create-post action.

Changes

Cohort / File(s) Summary
New review actions
components/google_my_business/actions/get-reviews-multiple-locations/get-reviews-multiple-locations.ts, components/google_my_business/actions/get-specific-review/get-specific-review.ts, components/google_my_business/actions/list-all-reviews/list-all-reviews.ts
Add actions: Get Reviews from Multiple Locations, Get a Specific Review, and List All Reviews with props, run handlers, and summaries.
New multi-location source
components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts
Add source "New Review Created (Multiple Locations)" with location: string[] prop, deploy hook, getItems (uses batchGetReviews) and getSummary (truncates comments).
App API additions
components/google_my_business/app/google_my_business.app.ts
Add app methods getReview (GET single review) and batchGetReviews (POST batch-get-reviews) and export corresponding request/response types.
Request / response types
components/google_my_business/common/requestParams.ts, components/google_my_business/common/responseSchemas.ts
Add GetReviewParams, BatchGetReviewsParams, and BatchGetReviewsResponse interfaces.
Sources common null-safety
components/google_my_business/sources/common.ts
Make filteredItems null-safe using optional chaining and ?? [].
Error message enhancement
components/google_my_business/actions/create-post/create-post.ts
Append JSON parse error details to ConfigurationError message in checkAndParseObject error handling.
Metadata / version bumps
components/google_my_business/actions/create-update-reply-to-review/create-update-reply-to-review.ts, .../list-posts/list-posts.ts, components/google_my_business/sources/new-post-created/new-post-created.ts, .../sources/new-review-created/new-review-created.ts, components/google_my_business/package.json
Bump action/source versions and package version from 0.1.4 to 0.2.0; no functional changes.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Action as PD Action
  participant App as GMB App
  participant GoogleAPI as Google My Business API

  User->>Action: Run "Get Reviews from Multiple Locations"
  Action->>App: batchGetReviews({ account, data: { locationNames[], pageSize, orderBy, ... } })
  App->>GoogleAPI: POST /v4/accounts/{account}/locations:batchGetReviews
  GoogleAPI-->>App: BatchGetReviewsResponse
  App-->>Action: response
  Action-->>User: Export summary + return response
Loading
sequenceDiagram
  participant Source as New Review Source
  participant App as GMB App
  participant GoogleAPI as Google My Business API
  participant Workflow as PD Workflow

  Source->>App: batchGetReviews({ account, data: { locationNames[] } })
  App->>GoogleAPI: POST /v4/accounts/{account}/locations:batchGetReviews
  GoogleAPI-->>App: locationReviews[]
  App-->>Source: locationReviews
  Source->>Workflow: Emit events per review (with summary)
Loading
sequenceDiagram
  participant User
  participant Action as PD Action
  participant App as GMB App
  participant GoogleAPI as Google My Business API

  User->>Action: Run "Get a Specific Review"
  Action->>App: getReview({ account, location, review })
  App->>GoogleAPI: GET /v4/accounts/{a}/locations/{l}/reviews/{r}
  GoogleAPI-->>App: Review
  App-->>Action: Review
  Action-->>User: Export summary + return Review
Loading
sequenceDiagram
  participant User
  participant Action as PD Action
  participant App as GMB App
  participant GoogleAPI as Google My Business API

  User->>Action: Run "List All Reviews"
  Action->>App: listReviews({ account, location })
  App->>GoogleAPI: GET /v4/accounts/{a}/locations/{l}/reviews
  GoogleAPI-->>App: Review[]
  App-->>Action: Review[]
  Action-->>User: Export summary + return Review[]
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Get reviews from multiple locations (#17821)
List all reviews (#17821)
Get a specific review (#17821)
New Review Created without specifying a location (any location under account) [BONUS] (#17821) The new multi-location source requires explicit locationNames (string[]); it does not auto-monitor all account locations without specifying them.

Out-of-scope changes

Code Change Explanation
Append JSON parse error details in checkAndParseObject (components/google_my_business/actions/create-post/create-post.ts) This modifies error messaging for create-post parsing; it is unrelated to the review-listing objectives in issue #17821.
Package version bump (components/google_my_business/package.json) Version metadata change only; not required by the linked issue objectives.
Action/source metadata version bumps (components/google_my_business/actions/..., components/google_my_business/sources/...) Metadata-only version increments across several actions/sources; unrelated to the requested review functionality.

Poem

I nibble through code with whiskers bright,
Fetching reviews by day and night.
Many locations, one quick hop,
I gather each review — then I stop.
Thump-thump — deploy! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f0894d3 and ac78af4.

📒 Files selected for processing (4)
  • components/google_my_business/actions/create-post/create-post.ts (2 hunks)
  • components/google_my_business/actions/get-reviews-multiple-locations/get-reviews-multiple-locations.ts (1 hunks)
  • components/google_my_business/common/requestParams.ts (1 hunks)
  • components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts
  • components/google_my_business/actions/create-post/create-post.ts
  • components/google_my_business/common/requestParams.ts
  • components/google_my_business/actions/get-reviews-multiple-locations/get-reviews-multiple-locations.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 17821-google-business-new-components

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (4)
components/google_my_business/actions/create-post/create-post.ts (1)

97-99: Fix ESLint failure: remove unused catch parameter

CI is failing with no-unused-vars for err. It's not used; remove the binding or use a leading underscore depending on lint config. Prefer empty catch for clarity.

Apply this diff:

-      } catch (err) {
+      } catch {
         throw new ConfigurationError(`**Invalid JSON string** for object prop: "${obj}"`);
       }
components/google_my_business/app/google_my_business.app.ts (3)

135-142: pageSize is not being sent: it must be inside params

_httpRequest forwards params to axios as query params. The current top-level pageSize is ignored, so the API will not receive it.

       const response = await this._httpRequest({
         url: `https://mybusinessbusinessinformation.googleapis.com/v1/accounts/${account}/locations`,
-        pageSize: 100,
         params: {
           filter,
           readMask: "name,title",
+          pageSize: 100,
         },
       });

148-151: pageSize is not being sent in List Reviews request

Same issue: pageSize must be under params to be sent as a query parameter. Currently ignored by axios.

       const response = await this._httpRequest({
         url: `https://mybusiness.googleapis.com/v4/accounts/${account}/locations/${location}/reviews`,
-        pageSize: 50,
+        params: {
+          pageSize: 50,
+        },
       });

165-168: pageSize is not being sent in List Posts (non-paginated path)

When paginate is false, pageSize must also be set inside params.

         const response: { localPosts?: LocalPost[]; } = await this._httpRequest({
           url,
-          pageSize: 100,
+          params: {
+            pageSize: 100,
+          },
         });
🧹 Nitpick comments (12)
components/google_my_business/actions/create-post/create-post.ts (1)

102-110: Validate media/mediaFormat pairing (avoid API errors)

Per your prop description, media requires mediaFormat and vice versa. Currently, media can be sent with mediaFormat undefined. Add a quick guard to fail fast with a helpful error.

Apply this diff to add validation just after destructuring:

   async run({ $ }) {
 
     const {
       account, location, topicType, languageCode, summary, media, mediaFormat, alertType,
     } = this;
 
+    if (media?.length && !mediaFormat) {
+      throw new ConfigurationError("Media Format is required when Media is provided.");
+    }
+    if (!media?.length && mediaFormat) {
+      throw new ConfigurationError("Media is required when Media Format is provided.");
+    }
components/google_my_business/common/requestParams.ts (2)

58-66: Constrain orderBy to known API values

Using a union tightens types and prevents invalid strings at compile time.

 export interface BatchGetReviewsParams extends PdAxiosRequest {
   account: string;
   data: {
     locationNames: string[];
     pageSize?: number;
     pageToken?: string;
-    orderBy?: string;
+    orderBy?: "createTime desc" | "createTime asc" | "updateTime desc" | "updateTime asc";
     ignoreRatingOnlyReviews?: boolean;
   };
 }

67-67: Fix linter error: add a newline at EOF

This addresses the “Newline required at end of file” failure.

 }
+
components/google_my_business/app/google_my_business.app.ts (3)

66-71: Type mismatch: mapping reviews as Location

The review prop options mapper is typed as Location but processes reviews. Use Review for correct typing.

-        }: Location) => ({
+        }: Review) => ({
           label: title,
           value: this.getCleanName(name) as string,
         }));

119-123: Optional: count actual items returned to control pagination more accurately

Incrementing by pageSize can prematurely stop fetching if fewer items are returned than requested. Use the length of resources instead.

-        resultCount += pageSize;
+        resultCount += Array.isArray(resources) ? resources.length : 0;

198-206: Return a strongly typed response for batchGetReviews

You’ve defined BatchGetReviewsResponse; returning it here improves type safety downstream.

-    }: BatchGetReviewsParams): Promise<object> {
+    }: BatchGetReviewsParams): Promise<BatchGetReviewsResponse> {
       return this._httpRequest({
         method: "POST",
         url: `https://mybusiness.googleapis.com/v4/accounts/${account}/locations:batchGetReviews`,
         ...args,
       });
     },

Also add the import:

  • At the import from ../common/responseSchemas, include BatchGetReviewsResponse.

Example:

import {
  Account, LocalPost, Location, Review, BatchGetReviewsResponse,
} from "../common/responseSchemas";
components/google_my_business/actions/get-specific-review/get-specific-review.ts (1)

55-59: Nit: make the summary more robust

If available, include the returned resource name. Falls back to the input review id.

-    $.export("$summary", `Successfully retrieved review: ${review}`);
+    $.export("$summary", `Successfully retrieved review: ${response?.name ?? review}`);
components/google_my_business/actions/get-reviews-multiple-locations/get-reviews-multiple-locations.ts (3)

49-49: Fix linter error: trailing whitespace

Remove the trailing space after "createTime asc".

-        "createTime asc", 
+        "createTime asc",

71-76: Prefer failing fast: make locationNames required (remove optional chaining)

This prop is conceptually required; mapping with ?. can hide missing input and result in an invalid payload. Also aligns with the summary that assumes a value.

-        locationNames: locationNames?.map((locationName: string) => `accounts/${account}/locations/${locationName}`),
+        locationNames: locationNames.map((locationName: string) => `accounts/${account}/locations/${locationName}`),

If you want to keep it defensive, consider validating and throwing a clear error when empty.


80-80: Guard summary when input might be empty

Defensive tweak to avoid a runtime error if locationNames is unexpectedly undefined.

-    $.export("$summary", `Successfully retrieved reviews from ${locationNames.length} locations`);
+    $.export("$summary", `Successfully retrieved reviews from ${locationNames?.length ?? 0} locations`);
components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts (2)

3-3: Fix lint: break named import across lines

Static analysis flagged object-curly-newline issues. Break the named import onto multiple lines to satisfy the style rule.

-import { BatchGetReviewsResponse, Review } from "../../common/responseSchemas";
+import {
+  BatchGetReviewsResponse,
+  Review,
+} from "../../common/responseSchemas";

19-30: Confirm multi-select behavior of the location propDefinition
Please verify that in the PropDog UI (or with a quick local script) the location prop in components/google_my_business/app.ts:

  • Renders as a multi‐select when used with type: "string[]", and
  • Returns the expected strings—either fully-qualified names (accounts/{account}/locations/{locationId}) or bare IDs.

Depending on what you get:

  • If it already returns fully-qualified names, remove any extra prefix logic to avoid double-prefixing.
  • If it returns only raw IDs, prefix each value with accounts/{account}/locations/ before use.

Let me know what the prop yields so we can finalize the mapping logic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3352100 and 0dcedf7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • components/google_my_business/actions/create-post/create-post.ts (1 hunks)
  • components/google_my_business/actions/create-update-reply-to-review/create-update-reply-to-review.ts (1 hunks)
  • components/google_my_business/actions/get-reviews-multiple-locations/get-reviews-multiple-locations.ts (1 hunks)
  • components/google_my_business/actions/get-specific-review/get-specific-review.ts (1 hunks)
  • components/google_my_business/actions/list-all-reviews/list-all-reviews.ts (1 hunks)
  • components/google_my_business/actions/list-posts/list-posts.ts (1 hunks)
  • components/google_my_business/app/google_my_business.app.ts (2 hunks)
  • components/google_my_business/common/requestParams.ts (1 hunks)
  • components/google_my_business/common/responseSchemas.ts (1 hunks)
  • components/google_my_business/package.json (1 hunks)
  • components/google_my_business/sources/new-post-created/new-post-created.ts (1 hunks)
  • components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts (1 hunks)
  • components/google_my_business/sources/new-review-created/new-review-created.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
components/google_my_business/actions/get-reviews-multiple-locations/get-reviews-multiple-locations.ts (1)
components/google_my_business/common/requestParams.ts (1)
  • BatchGetReviewsParams (58-67)
components/google_my_business/actions/list-all-reviews/list-all-reviews.ts (1)
components/google_my_business/common/requestParams.ts (1)
  • ListReviewsParams (32-32)
components/google_my_business/actions/get-specific-review/get-specific-review.ts (1)
components/google_my_business/common/requestParams.ts (1)
  • GetReviewParams (54-56)
components/google_my_business/app/google_my_business.app.ts (2)
components/google_my_business/common/requestParams.ts (2)
  • GetReviewParams (54-56)
  • BatchGetReviewsParams (58-67)
components/google_my_business/common/responseSchemas.ts (1)
  • Review (18-21)
components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts (2)
components/google_my_business/common/responseSchemas.ts (2)
  • Review (18-21)
  • BatchGetReviewsResponse (26-30)
components/google_my_business/common/requestParams.ts (1)
  • BatchGetReviewsParams (58-67)
🪛 GitHub Check: Lint Code Base
components/google_my_business/common/requestParams.ts

[failure] 67-67:
Newline required at end of file but not found

components/google_my_business/actions/get-reviews-multiple-locations/get-reviews-multiple-locations.ts

[failure] 49-49:
Trailing spaces not allowed

components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts

[failure] 3-3:
Expected a line break before this closing brace


[failure] 3-3:
Expected a line break after this opening brace

🪛 GitHub Actions: Pull Request Checks
components/google_my_business/actions/create-post/create-post.ts

[error] 97-97: ESLint: 'err' is defined but never used. (no-unused-vars)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (12)
components/google_my_business/actions/create-update-reply-to-review/create-update-reply-to-review.ts (1)

11-11: Version bump only — LGTM

No functional changes. Version aligns with the package bump and broader review-related additions in this PR.

components/google_my_business/package.json (1)

3-3: Version bump looks consistent

"0.2.0" aligns with the added review functionality and other action/source version bumps. No issues spotted.

components/google_my_business/sources/new-review-created/new-review-created.ts (1)

13-13: Version bump only — LGTM

No logic changes. Source continues to dedupe by unique id and returns typed Review[] via listReviews.

components/google_my_business/actions/create-post/create-post.ts (1)

15-15: Version bump only — LGTM

No functional alterations to post creation flow.

components/google_my_business/sources/new-post-created/new-post-created.ts (1)

13-13: Version bump only — LGTM

No functional changes to event emission or summarization.

components/google_my_business/common/requestParams.ts (1)

54-56: LGTM: GetReviewParams shape is correct and consistent with usage

Extends AccountLocation and adds the expected review identifier.

components/google_my_business/actions/list-posts/list-posts.ts (1)

12-12: Version bump only — looks good

No functional changes here; version increment aligns with app updates.

components/google_my_business/actions/list-all-reviews/list-all-reviews.ts (2)

21-29: Props wiring for dependent location looks good

Leveraging propDefinition with the account-scoped resolver for location is consistent with other components.


31-47: No defensive guard needed: listReviews returns an array
Verified that in components/google_my_business/app.ts:145 the method

async listReviews({ account, location }: ListReviewsParams): Promise<Review[]> {  }

returns a Review[]. Using response.length and returning response is correct.

Likely an incorrect or invalid review comment.

components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts (3)

32-36: Deploy hook is appropriate for initial backfill

Calling getAndProcessData() on deploy aligns with the source pattern and ensures an initial run.


54-60: Summary generation looks good

Concise, readable summary with sensible truncation for long comments.


38-53: The search didn’t reveal a BatchGetReviewsParams definition or how additional params are merged into the HTTP request. To be safe, please manually verify that:

  • The BatchGetReviewsParams interface actually allows orderBy and pageSize (or arbitrary query/body fields) under ...args.
  • The HTTP body sent by batchGetReviews puts these fields in the correct place (e.g. under data).
  • The Google My Business batchGetReviews endpoint supports orderBy and pageSize parameters.

Once confirmed, you can apply the refactor below; otherwise you may need to adjust/remove the orderBy/pageSize additions.

Suggested refactor

   async getItems(): Promise<Review[]> {
     const { account, locationNames } = this;

+    const toFullName = (name: string) =>
+      name.startsWith("accounts/") ? name : `accounts/${account}/locations/${name}`;

-    const params: BatchGetReviewsParams = {
-      account,
-      data: {
-        locationNames: locationNames?.map((locationName: string) => `accounts/${account}/locations/${locationName}`),
-      },
-    };
+    const params: BatchGetReviewsParams = {
+      account,
+      data: {
+        locationNames: locationNames?.map(toFullName) ?? [],
+        // Fetch newest only—remove or adjust pageSize if you need multiple reviews
+        orderBy: "updateTime desc",
+        pageSize: 1,
+      },
+    };

     const response: BatchGetReviewsResponse = await this.app.batchGetReviews(params);

-    return response?.locationReviews?.map((item) => item.review);
+    // Always return an array and flatten nested reviews
+    return (
+      response.locationReviews?.flatMap((lr) =>
+        lr.reviews ?? (lr.review ? [lr.review] : [])
+      ) ?? []
+    );
   },

Please confirm that orderBy and pageSize are accepted by both the params type and the My Business API before merging.

Comment on lines +26 to +30
export interface BatchGetReviewsResponse {
locationReviews: {
review: Review
}[];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Response shape likely needs reviews: Review[] (not singular), and optional fields

The Google Business Profile batch endpoint typically returns multiple reviews per location. Current typing (review: Review) risks runtime issues when mapping in consumers and may drop reviews. Consider supporting both shapes or aligning to reviews: Review[]. Also add trailing semicolons for consistency.

-export interface BatchGetReviewsResponse {
-  locationReviews: {
-    review: Review
-  }[];
-}
+export interface BatchGetReviewsResponse {
+  locationReviews: Array<{
+    // Fully-qualified location name, if returned
+    locationName?: string;
+    // Some implementations may return a single review
+    review?: Review;
+    // Prefer this if available: multiple reviews per location
+    reviews?: Review[];
+    // Pagination token per location, if applicable
+    nextPageToken?: string;
+  }>;
+}

If you want to confirm the official schema first:


🌐 Web query:

What is the response schema of the Google Business Profile API batchGetReviews endpoint? Does it return a list `reviews` per location, and what fields are present under `locationReviews`?

💡 Result:

The response schema of the Google Business Profile API batchGetReviews endpoint consists of a top-level object containing a list called locationReviews, with each element representing reviews for a specific location. Each locationReview contains the location's identifier and a single review object (not a list), with all standard review fields present.

Key structure and fields:

  • Top-level fields in response:

    • locationReviews: An array of objects, each corresponding to a location and its associated review.
    • nextPageToken: A string for pagination, present if more results are available[1][4][5].
  • Fields under locationReviews:

    • name: The location resource name (string), e.g., "accounts/123/locations/456".
    • review: An object containing the review data for the location[1].

Example response schema (JSON representation):

{
  "locationReviews": [
    {
      "name": "accounts/123/locations/456",
      "review": {
        "reviewId": "string",
        "comment": "string",
        "reviewer": { /* reviewer info */ },
        "starRating": "INTEGER",
        "createTime": "timestamp",
        "reviewReply": {
            "comment": "string",
            "updateTime": "timestamp"
        }
        // ...other review fields
      }
    }
    // ...more locationReview objects
  ],
  "nextPageToken": "string"
}

Important details:

  • locationReviews does not return a list of reviews per location. Instead, each entry in locationReviews represents a single review for a location. When requesting reviews for multiple locations, the endpoint returns a flattened list of individual reviews, with each including information about its associated location. You do not get a grouped list like {"location": ..., "reviews": [...]}[1][4].
  • The fields under review mirror those available in the standard Review object (see accounts.locations.reviews.list or .get), including, but not limited to:
    • reviewId
    • comment
    • reviewer
    • starRating
    • createTime
    • reviewReply (optional, may be missing for some reviews)[4][1][3]

Summary Table

Field Type Description
locationReviews Array Each item holds a location and a single review for that location
└─ name String Resource name of the location
└─ review Object The review data (reviewId, comment, reviewer, starRating, etc.)
nextPageToken String (optional) Used for pagination; not present if there are no more reviews

In summary:

  • The batchGetReviews response does not return a list of reviews per location.
  • Instead, it returns a flat list of locationReviews, each with one review and the associated location name[1][4][5].
  • The fields under locationReviews are name and review, with review containing all standard review data fields.

This design allows you to efficiently process reviews across multiple locations in one API call, but grouping reviews by location must be handled client-side if needed[1][4].

Citations:


Align BatchGetReviewsResponse with actual API schema

The batchGetReviews endpoint returns a flat list of location reviews—each entry has a single review plus the location’s resource name—and an optional top-level nextPageToken. There is no reviews: Review[] array per location.

Please update your interface accordingly:

• File: components/google_my_business/common/responseSchemas.ts
• Replace existing definition with:

export interface BatchGetReviewsResponse {
  /** All returned reviews, one per location */
  locationReviews: Array<{
    /** Resource name of the location, e.g. "accounts/123/locations/456" */
    name: string;
    /** The review data for this location */
    review: Review;
  }>;
  /** Pagination token, if more reviews remain */
  nextPageToken?: string;
}

• Add trailing semicolons for consistency.
• Remove any reviews?: Review[] fields—those are not part of this endpoint’s response.

🤖 Prompt for AI Agents
In components/google_my_business/common/responseSchemas.ts around lines 26 to
30, the BatchGetReviewsResponse shape is incorrect: replace the current
per-location structure with a flat locationReviews array where each item
includes name: string and review: Review, add an optional top-level
nextPageToken?: string, remove any per-location reviews?: Review[] fields, and
ensure trailing semicolons are added to the interface members for consistency.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
components/google_my_business/sources/common.ts (1)

54-54: Type fix: allow null from getLastRun()

getLastRun() returns Date | null, but lastRun is typed as Date. This can fail type-checking and obscures nullability.

Apply this diff:

-      const lastRun: Date = this.getLastRun();
+      const lastRun: Date | null = this.getLastRun();
🧹 Nitpick comments (1)
components/google_my_business/sources/common.ts (1)

58-60: Avoid duplicate emissions across runs: use strict '>' and compare Dates via getTime()

Relational comparison against Date objects with >= can re-emit items created exactly at the lastRun boundary. Comparing numeric timestamps with a strict greater-than avoids duplicates and is clearer.

Apply this diff:

-        ? items?.filter(({ createTime }) => new Date(createTime) >= lastRun)
+        ? items?.filter(({ createTime }) => new Date(createTime).getTime() > lastRun.getTime())
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0dcedf7 and f0894d3.

📒 Files selected for processing (2)
  • components/google_my_business/sources/common.ts (1 hunks)
  • components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/google_my_business/sources/new-review-created-multiple-locations/new-review-created-multiple-locations.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components

@vunguyenhung vunguyenhung merged commit 3abc3ae into master Aug 19, 2025
11 checks passed
@vunguyenhung vunguyenhung deleted the 17821-google-business-new-components branch August 19, 2025 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ACTION] Google business profile - List review
3 participants