Skip to content

Commit 992792a

Browse files
committed
Fix required changes
1 parent dd9dcbd commit 992792a

File tree

8 files changed

+42
-135
lines changed

8 files changed

+42
-135
lines changed

components/drift/actions/delete-contact/delete-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import drift from "../../drift.app.mjs";
33
export default {
44
key: "drift-delete-contact",
55
name: "Delete Contact",
6-
description: "Deletes a contact in Drift by ID or email. [See the docs](https://devdocs.drift.com/docs/removing-a-contact).",
6+
description: "Deletes a contact in Drift by ID or email. [See the documentation](https://devdocs.drift.com/docs/removing-a-contact).",
77
version: "0.0.1",
88
type: "action",
99
props: {

components/drift/actions/get-contact/get-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import drift from "../../drift.app.mjs";
33
export default {
44
key: "drift-get-contact",
55
name: "Get Contact",
6-
description: "Retrieves a contact in Drift by ID or email. [See the docs](https://devdocs.drift.com/docs/retrieving-contact)",
6+
description: "Retrieves a contact in Drift by ID or email. [See the documentation](https://devdocs.drift.com/docs/retrieving-contact)",
77
version: "0.0.1",
88
type: "action",
99
props: {

components/drift/actions/update-contact/update-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { removeNullEntries } from "../../common/utils.mjs";
44
export default {
55
key: "drift-update-contact",
66
name: "Update Contact",
7-
description: "Updates a contact in Drift using ID or email. Only changed attributes will be updated. [See Drift API docs](https://devdocs.drift.com/docs/updating-a-contact)",
7+
description: "Updates a contact in Drift using ID or email. Only changed attributes will be updated. [See the documentation](https://devdocs.drift.com/docs/updating-a-contact)",
88
version: "0.0.1",
99
type: "action",
1010
props: {

components/drift/sources/new-contact-update/new-contact-update.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import drift from "../../drift.app.mjs";
33
export default {
44
key: "drift-new-contact-update",
55
name: "New Contact Update",
6-
description: "Emit new event when a contact is updated in Drift. [See the docs](https://devdocs.drift.com/docs/webhook-events-1).",
6+
description: "Emit new event when a contact is updated in Drift. [See the documentation](https://devdocs.drift.com/docs/webhook-events-1).",
77
version: "0.0.1",
88
type: "source",
99
props: {

components/drift/sources/new-conversation-instant/new-conversation-instant.mjs

Lines changed: 0 additions & 111 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import drift from "../../drift.app.mjs";
2+
3+
export default {
4+
key: "drift-new-conversation",
5+
name: "New Conversation",
6+
description: "Emit new event when a new convesation is started in Drift. [See the documentation](https://devdocs.drift.com/docs/webhook-events-1).",
7+
version: "0.0.1",
8+
type: "source",
9+
props: {
10+
drift,
11+
http: "$.interface.http",
12+
},
13+
async run(event) {
14+
15+
const { body } = event;
16+
17+
if (body?.type !== "new_conversation") {
18+
console.log("Ignored non-new_conversation event:", body?.type);
19+
return;
20+
}
21+
22+
this.$emit(body, {
23+
summary: `New conversation from contact ID "${body.data?.contactId}"`,
24+
id: body.data?.contactId,
25+
ts: body.data?.createdAt,
26+
});
27+
},
28+
};
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import drift from "../../drift.app.mjs";
22

33
export default {
4-
key: "drift-new-lead-instance",
4+
key: "drift-new-lead",
55
name: "New Lead",
6-
description: "Emit new event when a contact adds their email in chat. [See the docs](https://devdocs.drift.com/docs/webhook-events-1).",
6+
description: "Emit new event when a contact adds their email in chat. [See the documentation](https://devdocs.drift.com/docs/webhook-events-1).",
77
version: "0.0.1",
88
type: "source",
99
props: {
@@ -19,20 +19,10 @@ export default {
1919
return;
2020
}
2121

22-
const contactId = body.data.endUserId;
23-
24-
const result = await this.drift.getContactById({
25-
contactId,
26-
});
27-
28-
const email = result.data.attributes.email;
29-
30-
body.data.attributes = result.data.attributes; //inject more data
31-
3222
this.$emit(body, {
33-
summary: `Contact "${email}" ID "${contactId}"`,
34-
id: body.data.endUserId,
35-
ts: body.timeStamp,
23+
summary: `New lead. Contact ID "${body.id}" proveded their email`,
24+
id: body.id,
25+
ts: body.createdAt,
3626
});
3727
},
3828
};

components/drift/sources/new-message-instant/new-message-instant.mjs renamed to components/drift/sources/new-message/new-message.mjs

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

33
export default {
4-
key: "drift-new-message-instant",
4+
key: "drift-new-message",
55
name: "New Message",
6-
description: "Emit new event when a new message is received in Drift. [See the docs](https://devdocs.drift.com/docs/webhook-events-1).",
6+
description: "Emit new event when a new message is received in Drift. [See the documentation](https://devdocs.drift.com/docs/webhook-events-1).",
77
version: "0.0.1",
88
type: "source",
99
props: {
1010
drift,
1111
http: "$.interface.http",
1212
conversationId: {
13-
type: "integer",
13+
type: "string",
1414
label: "Conversation ID",
1515
description: "The ID of the conversation to monitor. Emits events for all new messages if not provided.",
1616
optional: true,
@@ -45,7 +45,7 @@ export default {
4545
contactId,
4646
});
4747

48-
const email = result.data?.attributes?.email || "unknown";
48+
const email = result.data?.attributes?.email || "an unregistered contact";
4949

5050
if (this.emailOrId &&
5151
!(email === this.emailOrId || Number(contactId) === Number(this.emailOrId))) {
@@ -56,7 +56,7 @@ export default {
5656
body.data.attributes = result.data.attributes;
5757

5858
this.$emit(body, {
59-
summary: `New message from contact "${email} " ID "${contactId || "unknown"}"`,
59+
summary: `New message from "${email}" ID "${contactId || "unknown"}"`,
6060
id: body.data.endUserId,
6161
ts: body.timeStamp,
6262
});

0 commit comments

Comments
 (0)