Skip to content

Commit 28e91bb

Browse files
seynadioAfstklaclaudecoderabbitai[bot]michelle0927
authored
Implement comprehensive Trustpilot webhooks and review management (#17613)
* Implement comprehensive Trustpilot integration with polling sources ## Overview Complete Trustpilot integration using polling approach (webhooks not supported by Trustpilot API). ## Features Implemented ### Authentication & Core App - Enhanced trustpilot.app.ts with OAuth and API key authentication - Added comprehensive API methods for reviews, products, and conversations - Support for both public and private endpoints - Proper error handling, validation, and retry logic with rate limiting ### Actions (6 total) - **fetch-service-reviews** - Get service reviews with filtering and pagination - **fetch-service-review-by-id** - Get specific service review - **fetch-product-reviews** - Get product reviews with filtering and pagination - **fetch-product-review-by-id** - Get specific product review - **reply-to-service-review** - Reply to service reviews - **reply-to-product-review** - Reply to product reviews ### Polling Sources (8 total) - **new-service-reviews** - New service reviews (public + private endpoints) - **updated-service-reviews** - Updated/revised service reviews - **new-product-reviews** - New product reviews - **updated-product-reviews** - Updated/revised product reviews - **new-service-review-replies** - New replies to service reviews - **new-product-review-replies** - New replies to product reviews - **new-conversations** - New conversations started - **updated-conversations** - Updated conversations (new messages) ### Technical Implementation - 15-minute polling intervals following Google Drive pattern - Smart deduplication by reviewId + timestamp - Business unit filtering (optional) - 24-hour lookback on first run - Comprehensive constants and utilities - Proper pagination and error handling ## API Endpoints Used - `/business-units/{businessUnitId}/reviews` (public) - `/private/business-units/{businessUnitId}/reviews` (private service) - `/private/product-reviews/business-units/{businessUnitId}/reviews` (products) - `/private/conversations` (conversations) - All reply endpoints for posting responses Addresses all requirements from https://developers.trustpilot.com/introduction/ * Apply patches: Update pnpm-lock.yaml and fix security vulnerabilities in Trustpilot integration * Address PR feedback: Update dependencies, improve code quality, and follow best practices - Update @pipedream/platform to ^3.1.0 - Add authentication validation in _getAuthHeaders - Extract common review fetching logic to reduce duplication (DRY) - Remove unnecessary try/catch from _makeRequest - Use ConfigurationError for user input errors - Remove publishedAt from all components - Update polling descriptions to be more generic - Improve code maintainability and error handling Co-Authored-By: Claude <noreply@anthropic.com> * Fix CI/CD failures: bump component version, update lockfile, fix TypeScript errors - Increment trustpilot component version from 0.0.1 to 0.1.0 - Update pnpm lockfile to sync @pipedream/platform dependency (^3.0.0 -> ^3.1.0) - Fix TypeScript compilation errors by adding proper type annotations - Fix crypto import to use ES module syntax 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * typescript issues * Update components/trustpilot/app/trustpilot.app.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/trustpilot/app/trustpilot.app.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update trustpilot.app.ts * Rename app * add back app * ts --> js * fixes * delete .gitignore, update package.json * pnpm-lock.yaml --------- Co-authored-by: Job Nijenhuis <job@neople.io> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Job <9075380+Afstkla@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Michelle Bergeron <michelle.bergeron@gmail.com>
1 parent 550d464 commit 28e91bb

File tree

22 files changed

+1909
-20
lines changed

22 files changed

+1909
-20
lines changed

components/trustpilot/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import trustpilot from "../../trustpilot.app.mjs";
2+
3+
export default {
4+
key: "trustpilot-fetch-product-review-by-id",
5+
name: "Fetch Product Review by ID",
6+
description: "Retrieves detailed information about a specific product review on Trustpilot. Use this action to get comprehensive data about a single product review, including customer feedback, star rating, review text, and metadata. Perfect for analyzing individual customer experiences, responding to specific feedback, or integrating review data into your customer service workflows. [See the documentation](https://developers.trustpilot.com/product-reviews-api#get-private-product-review)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
trustpilot,
11+
reviewId: {
12+
propDefinition: [
13+
trustpilot,
14+
"reviewId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const { reviewId } = this;
20+
21+
try {
22+
const review = await this.trustpilot.getProductReviewById({
23+
reviewId,
24+
});
25+
26+
$.export("$summary", `Successfully fetched product review ${reviewId}`);
27+
28+
return {
29+
review,
30+
metadata: {
31+
reviewId,
32+
requestTime: new Date().toISOString(),
33+
},
34+
};
35+
} catch (error) {
36+
throw new Error(`Failed to fetch product review: ${error.message}`);
37+
}
38+
},
39+
};
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import trustpilot from "../../trustpilot.app.mjs";
2+
3+
export default {
4+
key: "trustpilot-fetch-product-reviews",
5+
name: "Fetch Product Reviews",
6+
description: "Retrieves a list of product reviews for a specific business unit on Trustpilot. This action enables you to fetch multiple product reviews with powerful filtering options including star ratings, language, tags, and sorting preferences. Ideal for monitoring product feedback trends, generating reports, analyzing customer sentiment across your product catalog, or building review dashboards. Supports pagination for handling large review volumes. [See the documentation](https://developers.trustpilot.com/product-reviews-api#get-private-product-reviews)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
trustpilot,
11+
businessUnitId: {
12+
propDefinition: [
13+
trustpilot,
14+
"businessUnitId",
15+
],
16+
},
17+
stars: {
18+
propDefinition: [
19+
trustpilot,
20+
"stars",
21+
],
22+
},
23+
sortBy: {
24+
propDefinition: [
25+
trustpilot,
26+
"sortBy",
27+
],
28+
},
29+
limit: {
30+
propDefinition: [
31+
trustpilot,
32+
"limit",
33+
],
34+
},
35+
includeReportedReviews: {
36+
propDefinition: [
37+
trustpilot,
38+
"includeReportedReviews",
39+
],
40+
},
41+
tags: {
42+
propDefinition: [
43+
trustpilot,
44+
"tags",
45+
],
46+
},
47+
language: {
48+
propDefinition: [
49+
trustpilot,
50+
"language",
51+
],
52+
},
53+
offset: {
54+
type: "integer",
55+
label: "Offset",
56+
description: "Number of results to skip (for pagination)",
57+
min: 0,
58+
default: 0,
59+
optional: true,
60+
},
61+
},
62+
async run({ $ }) {
63+
const {
64+
businessUnitId,
65+
stars,
66+
sortBy,
67+
limit,
68+
includeReportedReviews,
69+
tags,
70+
language,
71+
offset,
72+
} = this;
73+
74+
try {
75+
const result = await this.trustpilot.getProductReviews({
76+
businessUnitId,
77+
stars,
78+
sortBy,
79+
limit,
80+
includeReportedReviews,
81+
tags,
82+
language,
83+
offset,
84+
});
85+
86+
const {
87+
reviews, pagination,
88+
} = result;
89+
90+
$.export("$summary", `Successfully fetched ${reviews.length} product review(s) for business unit ${businessUnitId}`);
91+
92+
return {
93+
reviews,
94+
pagination,
95+
metadata: {
96+
businessUnitId,
97+
filters: {
98+
stars,
99+
sortBy,
100+
includeReportedReviews,
101+
tags,
102+
language,
103+
},
104+
requestTime: new Date().toISOString(),
105+
},
106+
};
107+
} catch (error) {
108+
throw new Error(`Failed to fetch product reviews: ${error.message}`);
109+
}
110+
},
111+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import trustpilot from "../../trustpilot.app.mjs";
2+
3+
export default {
4+
key: "trustpilot-fetch-service-review-by-id",
5+
name: "Fetch Service Review by ID",
6+
description: "Retrieves detailed information about a specific service review for your business on Trustpilot. Use this action to access comprehensive data about an individual service review, including the customer's rating, review content, date, and any responses. Essential for customer service teams to analyze specific feedback, track review history, or integrate individual review data into CRM systems and support tickets. [See the documentation](https://developers.trustpilot.com/business-units-api#get-business-unit-review)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
trustpilot,
11+
businessUnitId: {
12+
propDefinition: [
13+
trustpilot,
14+
"businessUnitId",
15+
],
16+
},
17+
reviewId: {
18+
propDefinition: [
19+
trustpilot,
20+
"reviewId",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const {
26+
businessUnitId,
27+
reviewId,
28+
} = this;
29+
30+
try {
31+
const review = await this.trustpilot.getServiceReviewById({
32+
businessUnitId,
33+
reviewId,
34+
});
35+
36+
$.export("$summary", `Successfully fetched service review ${reviewId} for business unit ${businessUnitId}`);
37+
38+
return {
39+
review,
40+
metadata: {
41+
businessUnitId,
42+
reviewId,
43+
requestTime: new Date().toISOString(),
44+
},
45+
};
46+
} catch (error) {
47+
throw new Error(`Failed to fetch service review: ${error.message}`);
48+
}
49+
},
50+
};
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import trustpilot from "../../trustpilot.app.mjs";
2+
3+
export default {
4+
key: "trustpilot-fetch-service-reviews",
5+
name: "Fetch Service Reviews",
6+
description: "Fetches service reviews for a specific business unit from Trustpilot with support for filtering by star rating, tags, language, and more. [See the documentation](https://developers.trustpilot.com/business-units-api#get-business-unit-reviews)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
trustpilot,
11+
businessUnitId: {
12+
propDefinition: [
13+
trustpilot,
14+
"businessUnitId",
15+
],
16+
},
17+
stars: {
18+
propDefinition: [
19+
trustpilot,
20+
"stars",
21+
],
22+
},
23+
sortBy: {
24+
propDefinition: [
25+
trustpilot,
26+
"sortBy",
27+
],
28+
},
29+
limit: {
30+
propDefinition: [
31+
trustpilot,
32+
"limit",
33+
],
34+
},
35+
includeReportedReviews: {
36+
propDefinition: [
37+
trustpilot,
38+
"includeReportedReviews",
39+
],
40+
},
41+
tags: {
42+
propDefinition: [
43+
trustpilot,
44+
"tags",
45+
],
46+
},
47+
language: {
48+
propDefinition: [
49+
trustpilot,
50+
"language",
51+
],
52+
},
53+
offset: {
54+
type: "integer",
55+
label: "Offset",
56+
description: "Number of results to skip (for pagination)",
57+
min: 0,
58+
default: 0,
59+
optional: true,
60+
},
61+
},
62+
async run({ $ }) {
63+
const {
64+
businessUnitId,
65+
stars,
66+
sortBy,
67+
limit,
68+
includeReportedReviews,
69+
tags,
70+
language,
71+
offset,
72+
} = this;
73+
74+
try {
75+
const result = await this.trustpilot.getServiceReviews({
76+
businessUnitId,
77+
stars,
78+
sortBy,
79+
limit,
80+
includeReportedReviews,
81+
tags,
82+
language,
83+
offset,
84+
});
85+
86+
const {
87+
reviews, pagination,
88+
} = result;
89+
90+
$.export("$summary", `Successfully fetched ${reviews.length} service review(s) for business unit ${businessUnitId}`);
91+
92+
return {
93+
reviews,
94+
pagination,
95+
metadata: {
96+
businessUnitId,
97+
filters: {
98+
stars,
99+
sortBy,
100+
includeReportedReviews,
101+
tags,
102+
language,
103+
},
104+
requestTime: new Date().toISOString(),
105+
},
106+
};
107+
} catch (error) {
108+
throw new Error(`Failed to fetch service reviews: ${error.message}`);
109+
}
110+
},
111+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import trustpilot from "../../trustpilot.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "trustpilot-reply-to-product-review",
6+
name: "Reply to Product Review",
7+
description: "Posts a public reply to a product review on Trustpilot on behalf of your business. This action allows you to respond to customer feedback, address concerns, thank customers for positive reviews, or provide additional information about products. Replies help demonstrate your commitment to customer satisfaction and can improve your overall reputation. Note that replies are publicly visible and cannot be edited once posted. [See the documentation](https://developers.trustpilot.com/product-reviews-api#reply-to-product-review)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
trustpilot,
12+
reviewId: {
13+
propDefinition: [
14+
trustpilot,
15+
"reviewId",
16+
],
17+
},
18+
message: {
19+
type: "string",
20+
label: "Reply Message",
21+
description: "The message to reply to the review with",
22+
},
23+
},
24+
async run({ $ }) {
25+
const {
26+
reviewId,
27+
message,
28+
} = this;
29+
30+
if (!message || message.trim().length === 0) {
31+
throw new ConfigurationError("Reply message cannot be empty");
32+
}
33+
34+
const result = await this.trustpilot.replyToProductReview({
35+
reviewId,
36+
message: message.trim(),
37+
});
38+
39+
$.export("$summary", `Successfully replied to product review ${reviewId}`);
40+
41+
return {
42+
success: true,
43+
reply: result,
44+
metadata: {
45+
reviewId,
46+
messageLength: message.trim().length,
47+
requestTime: new Date().toISOString(),
48+
},
49+
};
50+
},
51+
};

0 commit comments

Comments
 (0)