Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion components/intercom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/intercom",
"version": "0.6.0",
"version": "0.6.1",
"description": "Pipedream Intercom Components",
"main": "intercom.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ export default {
key: "intercom-new-conversation-rating-added",
name: "New Conversation Rating Added",
description: "Emit new event each time a new rating is added to a conversation.",
version: "0.0.3",
version: "0.0.4",
type: "source",
dedupe: "unique",
props: {
...common.props,
newConversationsOnly: {
type: "boolean",
label: "New Conversations Only",
description: "Set to `true` to only emit events for new conversations",
optional: true,
},
},
methods: {
...common.methods,
generateMeta(conversation) {
Expand All @@ -20,7 +29,8 @@ export default {
},
},
async run() {
let lastRatingCreatedAt = this._getLastUpdate();
const lastRatingCreatedAt = this._getLastUpdate();
let maxLastRatingCreatedAt = lastRatingCreatedAt;
const data = {
query: {
field: "conversation_rating.requested_at",
Expand All @@ -32,12 +42,14 @@ export default {
const results = await this.intercom.searchConversations(data);
for (const conversation of results) {
const createdAt = conversation.conversation_rating.created_at;
if (createdAt > lastRatingCreatedAt)
lastRatingCreatedAt = createdAt;
const meta = this.generateMeta(conversation);
this.$emit(conversation, meta);
if (createdAt > maxLastRatingCreatedAt)
maxLastRatingCreatedAt = createdAt;
if (!this.newConversationsOnly || conversation.created_at > lastRatingCreatedAt) {
const meta = this.generateMeta(conversation);
this.$emit(conversation, meta);
}
}

this._setLastUpdate(lastRatingCreatedAt);
this._setLastUpdate(maxLastRatingCreatedAt);
},
};
Loading