-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Merged
michelle0927
merged 15 commits into
PipedreamHQ:master
from
seynadio:trustpilot-webhooks-and-reviews
Jul 28, 2025
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
47cee75
Implement comprehensive Trustpilot integration with polling sources
seynadio 404d68f
Apply patches: Update pnpm-lock.yaml and fix security vulnerabilities…
Afstkla c685925
Address PR feedback: Update dependencies, improve code quality, and f…
Afstkla a75316b
Fix CI/CD failures: bump component version, update lockfile, fix Type…
Afstkla e53b455
typescript issues
Afstkla 2111a22
Update components/trustpilot/app/trustpilot.app.ts
Afstkla 5e68182
Update components/trustpilot/app/trustpilot.app.ts
Afstkla c1c55f7
Update trustpilot.app.ts
Afstkla b48d6b5
Rename app
Afstkla e530686
add back app
Afstkla bce521a
ts --> js
Afstkla b770dea
fixes
Afstkla 6046c49
Merge branch 'master' into trustpilot-webhooks-and-reviews
Afstkla c9e9081
delete .gitignore, update package.json
michelle0927 4e811a1
pnpm-lock.yaml
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
*.js | ||
*.mjs | ||
dist |
39 changes: 39 additions & 0 deletions
39
components/trustpilot/actions/fetch-product-review-by-id/fetch-product-review-by-id.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import trustpilot from "../../app/trustpilot.app.ts"; | ||
|
||
export default { | ||
key: "trustpilot-fetch-product-review-by-id", | ||
name: "Fetch Product Review by ID", | ||
description: "Fetch a specific product review by its ID. [See the documentation](https://developers.trustpilot.com/product-reviews-api#get-private-product-review)", | ||
version: "0.0.1", | ||
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}`); | ||
} | ||
}, | ||
}; |
109 changes: 109 additions & 0 deletions
109
components/trustpilot/actions/fetch-product-reviews/fetch-product-reviews.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import trustpilot from "../../app/trustpilot.app.ts"; | ||
|
||
export default { | ||
key: "trustpilot-fetch-product-reviews", | ||
name: "Fetch Product Reviews", | ||
description: "Fetch product reviews for a business unit. [See the documentation](https://developers.trustpilot.com/product-reviews-api#get-private-product-reviews)", | ||
version: "0.0.1", | ||
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}`); | ||
} | ||
}, | ||
}; |
50 changes: 50 additions & 0 deletions
50
components/trustpilot/actions/fetch-service-review-by-id/fetch-service-review-by-id.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import trustpilot from "../../app/trustpilot.app.ts"; | ||
|
||
export default { | ||
key: "trustpilot-fetch-service-review-by-id", | ||
name: "Fetch Service Review by ID", | ||
description: "Fetch a specific service review by its ID. [See the documentation](https://developers.trustpilot.com/business-units-api#get-business-unit-review)", | ||
version: "0.0.1", | ||
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}`); | ||
} | ||
}, | ||
}; |
109 changes: 109 additions & 0 deletions
109
components/trustpilot/actions/fetch-service-reviews/fetch-service-reviews.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import trustpilot from "../../app/trustpilot.app.ts"; | ||
|
||
export default { | ||
key: "trustpilot-fetch-service-reviews", | ||
name: "Fetch Service Reviews", | ||
description: "Fetch service reviews for a business unit. [See the documentation](https://developers.trustpilot.com/business-units-api#get-business-unit-reviews)", | ||
version: "0.0.1", | ||
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.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}`); | ||
} | ||
}, | ||
}; |
54 changes: 54 additions & 0 deletions
54
components/trustpilot/actions/reply-to-product-review/reply-to-product-review.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import trustpilot from "../../app/trustpilot.app.ts"; | ||
|
||
export default { | ||
key: "trustpilot-reply-to-product-review", | ||
name: "Reply to Product Review", | ||
description: "Reply to a product review on behalf of your business. [See the documentation](https://developers.trustpilot.com/product-reviews-api#reply-to-product-review)", | ||
version: "0.0.1", | ||
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}`); | ||
} | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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