Skip to content

Commit 7fa4e07

Browse files
authored
Intercom - new-conversation-rating-added source (#14456)
* new-conversation-rating-added * pnpm-lock.yaml
1 parent 5abc207 commit 7fa4e07

File tree

17 files changed

+125
-82
lines changed

17 files changed

+125
-82
lines changed

components/intercom/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/intercom",
3-
"version": "0.3.9",
3+
"version": "0.4.0",
44
"description": "Pipedream Intercom Components",
55
"main": "intercom.app.mjs",
66
"keywords": [
@@ -14,7 +14,7 @@
1414
"access": "public"
1515
},
1616
"dependencies": {
17-
"@pipedream/platform": "^1.2.0",
17+
"@pipedream/platform": "^3.0.3",
1818
"crypto": "^1.0.1"
1919
}
2020
}

components/intercom/sources/common.mjs renamed to components/intercom/sources/common/common.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import intercom from "../intercom.app.mjs";
1+
import intercom from "../../intercom.app.mjs";
22
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
33

44
export default {

components/intercom/sources/conversation-closed/conversation-closed.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
55
key: "intercom-conversation-closed",
66
name: "New Closed Conversation",
77
description: "Emit new event each time a conversation is closed.",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/intercom/sources/lead-added-email/lead-added-email.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
55
key: "intercom-lead-added-email",
66
name: "Lead Added Email",
77
description: "Emit new event each time a lead adds their email address.",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/intercom/sources/new-admin-reply/new-admin-reply.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
55
key: "intercom-new-admin-reply",
66
name: "New Reply From Admin",
77
description: "Emit new event each time an admin replies to a conversation.",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/intercom/sources/new-company/new-company.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
55
key: "intercom-new-company",
66
name: "New Companies",
77
description: "Emit new event each time a new company is added.",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import common from "../common/common.mjs";
2+
3+
export default {
4+
...common,
5+
key: "intercom-new-conversation-rating-added",
6+
name: "New Conversation Rating Added",
7+
description: "Emit new event each time a new rating is added to a conversation.",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
methods: {
12+
...common.methods,
13+
generateMeta(conversation) {
14+
const ts = conversation.conversation_rating.created_at;
15+
return {
16+
id: `${conversation.id}-${ts}`,
17+
summary: `New rating added to conversation with ID: ${conversation.id}`,
18+
ts,
19+
};
20+
},
21+
},
22+
async run() {
23+
let lastRatingCreatedAt = this._getLastUpdate();
24+
const data = {
25+
query: {
26+
field: "conversation_rating.requested_at",
27+
operator: ">",
28+
value: lastRatingCreatedAt,
29+
},
30+
};
31+
32+
const results = await this.intercom.searchConversations(data);
33+
for (const conversation of results) {
34+
const createdAt = conversation.conversation_rating.created_at;
35+
if (createdAt > lastRatingCreatedAt)
36+
lastRatingCreatedAt = createdAt;
37+
const meta = this.generateMeta(conversation);
38+
this.$emit(conversation, meta);
39+
}
40+
41+
this._setLastUpdate(lastRatingCreatedAt);
42+
},
43+
};

components/intercom/sources/new-conversation/new-conversation.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
55
key: "intercom-new-conversation",
66
name: "New Conversations",
77
description: "Emit new event each time a new conversation is added.",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/intercom/sources/new-event/new-event.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
55
key: "intercom-new-event",
66
name: "New Event",
77
description: "Emit new event for each new Intercom event for a user.",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "source",
1010
dedupe: "unique",
1111
props: {

components/intercom/sources/new-lead/new-lead.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import common from "../common.mjs";
1+
import common from "../common/common.mjs";
22

33
export default {
44
...common,
55
key: "intercom-new-lead",
66
name: "New Leads",
77
description: "Emit new event each time a new lead is added.",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

0 commit comments

Comments
 (0)