Skip to content

Commit b1030aa

Browse files
committed
[Components] intercom - new components
1 parent 427b0bf commit b1030aa

File tree

25 files changed

+477
-26
lines changed

25 files changed

+477
-26
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import intercom from "../../intercom.app.mjs";
2+
3+
export default {
4+
key: "intercom-add-tag-to-contact",
5+
name: "Add Tag To Contact",
6+
description: "Adds a specific tag to a contact in Intercom. [See the documentation](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/contacts/attachtagtocontact).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
intercom,
11+
contactId: {
12+
type: "string",
13+
label: "Contact ID",
14+
description: "The unique identifier for the contact which is given by Intercom. Eg. `63a07ddf05a32042dffac965`.",
15+
propDefinition: [
16+
intercom,
17+
"userIds",
18+
() => ({
19+
data: {
20+
query: {
21+
operator: "OR",
22+
value: [
23+
{
24+
field: "role",
25+
operator: "=",
26+
value: "user",
27+
},
28+
{
29+
field: "role",
30+
operator: "=",
31+
value: "lead",
32+
},
33+
],
34+
},
35+
},
36+
}),
37+
],
38+
},
39+
tagId: {
40+
propDefinition: [
41+
intercom,
42+
"tagId",
43+
],
44+
},
45+
},
46+
methods: {
47+
addTagToContact({
48+
contactId, ...args
49+
} = {}) {
50+
return this.intercom.makeRequest({
51+
method: "POST",
52+
endpoint: `contacts/${contactId}/tags`,
53+
...args,
54+
});
55+
},
56+
},
57+
async run({ $ }) {
58+
const {
59+
addTagToContact,
60+
contactId,
61+
tagId,
62+
} = this;
63+
64+
const response = await addTagToContact({
65+
$,
66+
contactId,
67+
data: {
68+
id: tagId,
69+
},
70+
});
71+
72+
$.export("$summary", `Successfully added tag to contact with ID \`${response.id}\`.`);
73+
return response;
74+
},
75+
};

components/intercom/actions/create-note/create-note.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "intercom-create-note",
55
name: "Create Note",
66
description: "Creates a note for a specific user. [See the docs here](https://developers.intercom.com/intercom-api-reference/reference/create-note-for-contact)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
intercom,
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import intercom from "../../intercom.app.mjs";
2+
3+
export default {
4+
key: "intercom-reply-to-conversation",
5+
name: "Reply To Conversation",
6+
description: "Add a reply or a note to an existing conversation thread. [See the documentation](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/conversations/replyconversation).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
intercom,
11+
conversationId: {
12+
propDefinition: [
13+
intercom,
14+
"conversationId",
15+
],
16+
},
17+
replyType: {
18+
type: "string",
19+
label: "Reply Type",
20+
description: "The type of the reply.",
21+
options: [
22+
{
23+
label: "Contact Reply",
24+
value: "user",
25+
},
26+
{
27+
label: "Admin Reply",
28+
value: "admin",
29+
},
30+
],
31+
reloadProps: true,
32+
},
33+
messageType: {
34+
propDefinition: [
35+
intercom,
36+
"messageType",
37+
({ replyType: type }) => ({
38+
type,
39+
}),
40+
],
41+
},
42+
body: {
43+
type: "string",
44+
label: "Body",
45+
description: "The text body of the comment.",
46+
},
47+
attachmentUrls: {
48+
type: "string[]",
49+
label: "Attachment URLs",
50+
description: "A list of image URLs that will be added as attachments. You can include up to 10 URLs.",
51+
optional: true,
52+
},
53+
},
54+
additionalProps() {
55+
const {
56+
replyType,
57+
replyOnBehalfOf,
58+
} = this;
59+
60+
if (replyType === "admin") {
61+
return {
62+
adminId: {
63+
type: "string",
64+
label: "Admin ID",
65+
description: "The id of the admin who is authoring the comment.",
66+
},
67+
};
68+
}
69+
70+
return {
71+
replyOnBehalfOf: {
72+
type: "string",
73+
label: "Reply On Behalf Of",
74+
description: "The user ID of the user on whose behalf the reply is being made.",
75+
options: [
76+
{
77+
label: "Intercom User ID",
78+
value: "intercom_user_id",
79+
},
80+
{
81+
label: "Email",
82+
value: "email",
83+
},
84+
{
85+
label: "User ID",
86+
value: "user_id",
87+
},
88+
],
89+
reloadProps: true,
90+
},
91+
...(replyOnBehalfOf === "intercom_user_id" && {
92+
intercomUserId: {
93+
type: "string",
94+
label: "Intercom User ID",
95+
description: "The identifier for the contact as given by Intercom.",
96+
},
97+
}),
98+
...(replyOnBehalfOf === "email" && {
99+
email: {
100+
type: "string",
101+
label: "Email",
102+
description: "The email you have defined for the user.",
103+
},
104+
}),
105+
...(replyOnBehalfOf === "user_id" && {
106+
userId: {
107+
type: "string",
108+
label: "User ID",
109+
description: "The external ID you have defined for the contact.",
110+
},
111+
}),
112+
};
113+
},
114+
methods: {
115+
replyToConversation({
116+
conversationId, ...args
117+
} = {}) {
118+
return this.intercom._makeRequest({
119+
method: "POST",
120+
endpoint: `conversations/${conversationId}/parts`,
121+
...args,
122+
});
123+
},
124+
},
125+
async run({ $ }) {
126+
const {
127+
replyToConversation,
128+
conversationId,
129+
body,
130+
attachmentUrls,
131+
replyType,
132+
adminId,
133+
intercomUserId,
134+
email,
135+
userId,
136+
messageType,
137+
} = this;
138+
139+
const response = await replyToConversation({
140+
$,
141+
conversationId,
142+
data: {
143+
body,
144+
attachment_urls: attachmentUrls,
145+
admin_id: adminId,
146+
intercom_user_id: intercomUserId,
147+
email,
148+
user_id: userId,
149+
message_type: messageType,
150+
type: replyType,
151+
},
152+
});
153+
154+
$.export("$summary", "Reply or note added successfully");
155+
return response;
156+
},
157+
};

components/intercom/actions/send-incoming-message/send-incoming-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "intercom-send-incoming-message",
55
name: "Send Incoming Message",
66
description: "Send a message from a user into your Intercom app. [See the docs here](https://developers.intercom.com/intercom-api-reference/reference/create-a-conversation)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
intercom,
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import intercom from "../../intercom.app.mjs";
2+
3+
export default {
4+
key: "intercom-send-message-to-contact",
5+
name: "Send Message To Contact",
6+
description: "Send a message to a contact in Intercom. [See the documentation](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/messages/createmessage).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
intercom,
11+
messageType: {
12+
type: "string",
13+
label: "Message Type",
14+
description: "The kind of message being created.",
15+
options: [
16+
"in_app",
17+
"email",
18+
],
19+
},
20+
subject: {
21+
type: "string",
22+
label: "Subject",
23+
description: "The title of the email.",
24+
},
25+
body: {
26+
description: "The content of the message. HTML and plaintext are supported.",
27+
propDefinition: [
28+
intercom,
29+
"body",
30+
],
31+
},
32+
template: {
33+
type: "string",
34+
label: "Template",
35+
description: "The style of the outgoing message.",
36+
options: [
37+
"plain",
38+
"personal",
39+
],
40+
},
41+
fromId: {
42+
type: "string",
43+
label: "From ID",
44+
description: "The sender of the message. The identifier for the admin which is given by Intercom. If not provided, the default sender will be used.",
45+
optional: true,
46+
},
47+
toType: {
48+
type: "string",
49+
label: "To Type",
50+
description: "The type of the recipient of the message.",
51+
options: [
52+
"user",
53+
"lead",
54+
],
55+
},
56+
toId: {
57+
type: "string",
58+
label: "To ID",
59+
description: "The recipient of the message. The identifier for the contact which is given by Intercom. Eg. `536e564f316c83104c000020`.",
60+
propDefinition: [
61+
intercom,
62+
"userIds",
63+
],
64+
},
65+
},
66+
methods: {
67+
sendMessage(args = {}) {
68+
return this.intercom.makeRequest({
69+
method: "POST",
70+
endpoint: "messages",
71+
...args,
72+
});
73+
},
74+
},
75+
async run({ $ }) {
76+
const {
77+
sendMessage,
78+
messageType,
79+
subject,
80+
body,
81+
template,
82+
fromId,
83+
toType,
84+
toId,
85+
} = this;
86+
87+
const response = await sendMessage({
88+
$,
89+
data: {
90+
message_type: messageType,
91+
subject,
92+
body,
93+
template,
94+
...(fromId && {
95+
from: {
96+
type: "admin",
97+
id: fromId,
98+
},
99+
}),
100+
to: {
101+
type: toType,
102+
id: toId,
103+
},
104+
},
105+
});
106+
107+
$.export("$summary", `Successfully sent message with ID \`${response.id}\`.`);
108+
return response;
109+
},
110+
};

components/intercom/actions/upsert-contact/upsert-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "intercom-upsert-contact",
66
name: "Upsert Contact",
77
description: "Create a new contact. If there is already a contact with the email provided, the existing contact will be updated. [See the docs here](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/contacts/createcontact)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
intercom,

0 commit comments

Comments
 (0)