Skip to content

Implement comprehensive Trustpilot webhooks and review management #17613

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion components/trustpilot/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*.js
*.mjs
dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import trustpilot from "../../app/trustpilot.app.ts";

export default {
key: "trustpilot-fetch-product-review-by-id",
name: "Fetch Product Review by ID",
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)",
version: "0.0.1",
publishedAt: "2025-07-18T00:00:00.000Z",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should remove the 'publishedAt' line from all the components that have it

type: "action",
props: {
trustpilot,
reviewId: {
propDefinition: [
trustpilot,
"reviewId",
],
},
},
async run({ $ }) {
const { reviewId } = this;

try {
const review = await this.trustpilot.getProductReviewById({
reviewId,
});

$.export("$summary", `Successfully fetched product review ${reviewId}`);

return {
review,
metadata: {
reviewId,
requestTime: new Date().toISOString(),
},
};
} catch (error) {
throw new Error(`Failed to fetch product review: ${error.message}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we shouldn't be try/catching here, because @pipedream/platform's axios already handles error responses and emits metadata for the request and response - this would make it harder to debug. The same applies for all components using a try/catch here in the request method

}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import trustpilot from "../../app/trustpilot.app.ts";

export default {
key: "trustpilot-fetch-product-reviews",
name: "Fetch Product Reviews",
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)",
version: "0.0.1",
publishedAt: "2025-07-18T00:00:00.000Z",
type: "action",
props: {
trustpilot,
businessUnitId: {
propDefinition: [
trustpilot,
"businessUnitId",
],
},
stars: {
propDefinition: [
trustpilot,
"stars",
],
},
sortBy: {
propDefinition: [
trustpilot,
"sortBy",
],
},
limit: {
propDefinition: [
trustpilot,
"limit",
],
},
includeReportedReviews: {
propDefinition: [
trustpilot,
"includeReportedReviews",
],
},
tags: {
propDefinition: [
trustpilot,
"tags",
],
},
language: {
propDefinition: [
trustpilot,
"language",
],
},
offset: {
type: "integer",
label: "Offset",
description: "Number of results to skip (for pagination)",
min: 0,
default: 0,
optional: true,
},
},
async run({ $ }) {
const {
businessUnitId,
stars,
sortBy,
limit,
includeReportedReviews,
tags,
language,
offset,
} = this;

try {
const result = await this.trustpilot.getProductReviews({
businessUnitId,
stars,
sortBy,
limit,
includeReportedReviews,
tags,
language,
offset,
});

const {
reviews, pagination,
} = result;

$.export("$summary", `Successfully fetched ${reviews.length} product review(s) for business unit ${businessUnitId}`);

return {
reviews,
pagination,
metadata: {
businessUnitId,
filters: {
stars,
sortBy,
includeReportedReviews,
tags,
language,
},
requestTime: new Date().toISOString(),
},
};
} catch (error) {
throw new Error(`Failed to fetch product reviews: ${error.message}`);
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import trustpilot from "../../app/trustpilot.app.ts";

export default {
key: "trustpilot-fetch-service-review-by-id",
name: "Fetch Service Review by ID",
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)",
version: "0.0.1",
publishedAt: "2025-07-18T00:00:00.000Z",
type: "action",
props: {
trustpilot,
businessUnitId: {
propDefinition: [
trustpilot,
"businessUnitId",
],
},
reviewId: {
propDefinition: [
trustpilot,
"reviewId",
],
},
},
async run({ $ }) {
const {
businessUnitId,
reviewId,
} = this;

try {
const review = await this.trustpilot.getServiceReviewById({
businessUnitId,
reviewId,
});

$.export("$summary", `Successfully fetched service review ${reviewId} for business unit ${businessUnitId}`);

return {
review,
metadata: {
businessUnitId,
reviewId,
requestTime: new Date().toISOString(),
},
};
} catch (error) {
throw new Error(`Failed to fetch service review: ${error.message}`);
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import trustpilot from "../../app/trustpilot.app.ts";

export default {
key: "trustpilot-fetch-service-reviews",
name: "Fetch Service Reviews",
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)",
version: "0.0.1",
type: "action",
publishedAt: "2025-07-18T00:00:00.000Z",
props: {
trustpilot,
businessUnitId: {
propDefinition: [
trustpilot,
"businessUnitId",
],
},
stars: {
propDefinition: [
trustpilot,
"stars",
],
},
sortBy: {
propDefinition: [
trustpilot,
"sortBy",
],
},
limit: {
propDefinition: [
trustpilot,
"limit",
],
},
includeReportedReviews: {
propDefinition: [
trustpilot,
"includeReportedReviews",
],
},
tags: {
propDefinition: [
trustpilot,
"tags",
],
},
language: {
propDefinition: [
trustpilot,
"language",
],
},
offset: {
type: "integer",
label: "Offset",
description: "Number of results to skip (for pagination)",
min: 0,
default: 0,
optional: true,
},
},
async run({ $ }) {
const {
businessUnitId,
stars,
sortBy,
limit,
includeReportedReviews,
tags,
language,
offset,
} = this;

try {
const result = await this.trustpilot.getServiceReviews({
businessUnitId,
stars,
sortBy,
limit,
includeReportedReviews,
tags,
language,
offset,
});

const {
reviews, pagination,
} = result;

$.export("$summary", `Successfully fetched ${reviews.length} service review(s) for business unit ${businessUnitId}`);

return {
reviews,
pagination,
metadata: {
businessUnitId,
filters: {
stars,
sortBy,
includeReportedReviews,
tags,
language,
},
requestTime: new Date().toISOString(),
},
};
} catch (error) {
throw new Error(`Failed to fetch service reviews: ${error.message}`);
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import trustpilot from "../../app/trustpilot.app.ts";

export default {
key: "trustpilot-reply-to-product-review",
name: "Reply to Product Review",
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)",
version: "0.0.1",
publishedAt: "2025-07-18T00:00:00.000Z",
type: "action",
props: {
trustpilot,
reviewId: {
propDefinition: [
trustpilot,
"reviewId",
],
},
message: {
type: "string",
label: "Reply Message",
description: "The message to reply to the review with",
},
},
async run({ $ }) {
const {
reviewId,
message,
} = this;

if (!message || message.trim().length === 0) {
throw new Error("Reply message cannot be empty");
}

try {
const result = await this.trustpilot.replyToProductReview({
reviewId,
message: message.trim(),
});

$.export("$summary", `Successfully replied to product review ${reviewId}`);

return {
success: true,
reply: result,
metadata: {
reviewId,
messageLength: message.trim().length,
requestTime: new Date().toISOString(),
},
};
} catch (error) {
throw new Error(`Failed to reply to product review: ${error.message}`);
}
},
};
Loading