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
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import intercom from "../../intercom.app.mjs";

export default {
key: "intercom-add-tag-to-contact",
name: "Add Tag To Contact",
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).",
version: "0.0.1",
type: "action",
props: {
intercom,
contactId: {
type: "string",
label: "Contact ID",
description: "The unique identifier for the contact which is given by Intercom. Eg. `63a07ddf05a32042dffac965`.",
propDefinition: [
intercom,
"userIds",
() => ({
data: {
query: {
operator: "OR",
value: [
{
field: "role",
operator: "=",
value: "user",
},
{
field: "role",
operator: "=",
value: "lead",
},
],
},
},
}),
],
},
tagId: {
propDefinition: [
intercom,
"tagId",
],
},
},
methods: {
addTagToContact({
contactId, ...args
} = {}) {
return this.intercom.makeRequest({
method: "POST",
endpoint: `contacts/${contactId}/tags`,
...args,
});
},
},
async run({ $ }) {
const {
addTagToContact,
contactId,
tagId,
} = this;

const response = await addTagToContact({
$,
contactId,
data: {
id: tagId,
},
});

$.export("$summary", `Successfully added tag to contact with ID \`${response.id}\`.`);
return response;
},
};
2 changes: 1 addition & 1 deletion components/intercom/actions/create-note/create-note.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "intercom-create-note",
name: "Create Note",
description: "Creates a note for a specific user. [See the docs here](https://developers.intercom.com/intercom-api-reference/reference/create-note-for-contact)",
version: "0.0.4",
version: "0.0.5",
type: "action",
props: {
intercom,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
import intercom from "../../intercom.app.mjs";

export default {
key: "intercom-reply-to-conversation",
name: "Reply To Conversation",
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).",
version: "0.0.1",
type: "action",
props: {
intercom,
conversationId: {
propDefinition: [
intercom,
"conversationId",
],
},
replyType: {
type: "string",
label: "Reply Type",
description: "The type of the reply.",
options: [
{
label: "Contact Reply",
value: "user",
},
{
label: "Admin Reply",
value: "admin",
},
],
reloadProps: true,
},
messageType: {
propDefinition: [
intercom,
"messageType",
({ replyType: type }) => ({
type,
}),
],
},
body: {
type: "string",
label: "Body",
description: "The text body of the comment.",
},
attachmentUrls: {
type: "string[]",
label: "Attachment URLs",
description: "A list of image URLs that will be added as attachments. You can include up to 10 URLs.",
optional: true,
},
},
additionalProps() {
const {
replyType,
replyOnBehalfOf,
} = this;

if (replyType === "admin") {
return {
adminId: {
type: "string",
label: "Admin ID",
description: "The id of the admin who is authoring the comment.",
options: async () => {
const { admins } = await this.intercom.listAdmins();
return admins.map((admin) => ({
label: admin.name,
value: admin.id,
}));
},
},
};
}

return {
replyOnBehalfOf: {
type: "string",
label: "Reply On Behalf Of",
description: "The user ID of the user on whose behalf the reply is being made.",
options: [
{
label: "Intercom User ID",
value: "intercom_user_id",
},
{
label: "Email",
value: "email",
},
{
label: "User ID",
value: "user_id",
},
],
reloadProps: true,
},
...(replyOnBehalfOf === "intercom_user_id" && {
intercomUserId: {
type: "string",
label: "Intercom User ID",
description: "The identifier for the contact as given by Intercom.",
options: async () => {
const results = await this.intercom.searchContacts({
query: {
field: "role",
operator: "=",
value: "user",
},
});
return results.map((user) => ({
label: user.name || user.id,
value: user.id,
}));
},
},
}),
...(replyOnBehalfOf === "email" && {
email: {
type: "string",
label: "Email",
description: "The email you have defined for the user.",
options: async () => {
const results = await this.intercom.searchContacts({
query: {
field: "role",
operator: "=",
value: "user",
},
});
return results.map((user) => ({
label: user.name || user.id,
value: user.email,
}));
},
},
}),
...(replyOnBehalfOf === "user_id" && {
userId: {
type: "string",
label: "User ID",
description: "The external ID you have defined for the contact.",
options: async () => {
const results = await this.intercom.searchContacts({
query: {
field: "role",
operator: "=",
value: "user",
},
});
return results.map((user) => ({
label: user.name || user.id,
value: user.external_id,
}));
},
},
}),
};
},
methods: {
replyToConversation({
conversationId, ...args
} = {}) {
return this.intercom.makeRequest({
method: "POST",
endpoint: `conversations/${conversationId}/parts`,
...args,
});
},
},
async run({ $ }) {
const {
replyToConversation,
conversationId,
body,
attachmentUrls,
replyType,
adminId,
intercomUserId,
email,
userId,
messageType,
} = this;

const response = await replyToConversation({
$,
conversationId,
data: {
body,
attachment_urls: attachmentUrls,
admin_id: adminId,
intercom_user_id: intercomUserId,
email,
user_id: userId,
message_type: messageType,
type: replyType,
},
});

$.export("$summary", "Reply or note added successfully");
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "intercom-send-incoming-message",
name: "Send Incoming Message",
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)",
version: "0.0.4",
version: "0.0.5",
type: "action",
props: {
intercom,
Expand Down
Loading
Loading