Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Components - clickfunnels #12577

Merged
merged 6 commits into from
Jun 27, 2024
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,58 @@
import clickfunnels from "../../clickfunnels.app.mjs";

export default {
key: "clickfunnels-apply-tag-contact",
name: "Apply Tag to Contact",
description: "Applies a tag to a contact. [See the documentation](https://developers.myclickfunnels.com/reference/createcontactsappliedtags)",
version: "0.0.1",
type: "action",
props: {
clickfunnels,
teamId: {
propDefinition: [
clickfunnels,
"teamId",
],
},
workspaceId: {
propDefinition: [
clickfunnels,
"workspaceId",
({ teamId }) => ({
teamId,
}),
],
},
contactId: {
propDefinition: [
clickfunnels,
"contactId",
({ workspaceId }) => ({
workspaceId,
}),
],
},
tagId: {
propDefinition: [
clickfunnels,
"tagId",
({ workspaceId }) => ({
workspaceId,
}),
],
},
},
async run({ $ }) {
const response = await this.clickfunnels.applyTagToContact({
$,
contactId: this.contactId,
data: {
contacts_applied_tag: {
tag_id: this.tagId,
},
},
});
$.export("$summary", `Successfully applied tag with Id: ${this.tagId} to contact with Id: ${this.contactId}`);
return response;
},
};
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import clickfunnels from "../../clickfunnels.app.mjs";
luancazarine marked this conversation as resolved.
Show resolved Hide resolved

export default {
key: "clickfunnels-remove-tag-contact",
name: "Remove Tag from Contact",
description: "Removes a specified tag from a contact. This action will take no effect if the specified tag doesn't exist on the contact. [See the documentation](https://developers.myclickfunnels.com/reference/removecontactsappliedtags)",
version: "0.0.1",
type: "action",
props: {
clickfunnels,
teamId: {
propDefinition: [
clickfunnels,
"teamId",
],
},
workspaceId: {
propDefinition: [
clickfunnels,
"workspaceId",
({ teamId }) => ({
teamId,
}),
],
},
contactId: {
propDefinition: [
clickfunnels,
"contactId",
({ workspaceId }) => ({
workspaceId,
}),
],
},
tagId: {
propDefinition: [
clickfunnels,
"tagId",
({ workspaceId }) => ({
workspaceId,
}),
],
},
},
async run({ $ }) {
const { tags } = await this.clickfunnels.getContact({
contactId: this.contactId,
});

const filteredTags = tags.filter((tag) => tag.id != this.tagId).map((tag) => tag.id);
const response = await this.clickfunnels.updateContact({
contactId: this.contactId,
data: {
contact: {
tag_ids: filteredTags,
},
},
});

$.export("$summary", `Successfully removed tag ${this.tagId} from contact ${this.contactId}`);
return response;
},
};
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import clickfunnels from "../../clickfunnels.app.mjs";
import {
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
clearObj, parseObject,
} from "../../common/utils.mjs";

export default {
key: "clickfunnels-update-create-contact",
name: "Update or Create Contact",
description: "Searches for a contact by email and updates it, or creates a new one if not found. [See the documentation](https://developers.myclickfunnels.com/reference/upsertcontact)",
version: "0.0.1",
type: "action",
props: {
clickfunnels,
teamId: {
propDefinition: [
clickfunnels,
"teamId",
],
},
workspaceId: {
propDefinition: [
clickfunnels,
"workspaceId",
({ teamId }) => ({
teamId,
}),
],
},
email: {
propDefinition: [
clickfunnels,
"email",
],
},
firstName: {
type: "string",
label: "First Name",
description: "The contact's first name.",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The contact's last name.",
optional: true,
},
phoneNumber: {
type: "string",
label: "Phone Number",
description: "The contact's phone number.",
optional: true,
},
timeZone: {
type: "string",
label: "Time Zone",
description: "The contact's time zone.",
optional: true,
},
fbUrl: {
type: "string",
label: "FB URL",
description: "The contact's Facebook URL.",
optional: true,
},
twitterUrl: {
type: "string",
label: "Twitter URL",
description: "The contact's twitter URL.",
optional: true,
},
instagramUrl: {
type: "string",
label: "Instagram URL",
description: "The contact's instagram URL.",
optional: true,
},
linkedinUrl: {
type: "string",
label: "Linkedin URL",
description: "The contact's linkedin URL.",
optional: true,
},
websiteUrl: {
type: "string",
label: "Website URL",
description: "The contact's website URL.",
optional: true,
},
tagIds: {
propDefinition: [
clickfunnels,
"tagId",
({ workspaceId }) => ({
workspaceId,
}),
],
optional: true,
type: "string[]",
label: "Tag Ids",
description: "An empty array is ignored here. If you wish to remove all tags for a Contact, use the Update Contact endpoint. A non-empty array overwrites the existing array.",
},
customAttributes: {
type: "object",
label: "Custom Attributes",
description: `Custom attributes are usually added in ClickFunnels to a contact when they submit forms that contain custom contact attributes. Here you can directly create them during contact modification.
Custom attributes are provided as key-value pairs:
A key that does not exist, will create a new custom contact attribute.
A key that already exists, will update the value of an existing custom contact attribute.
Empty or null values, will set the custom attribute values to empty strings. A key that has special characters or spaces will be automatically converted to snake_case (For example, 'Favorite Food! 🥑' will be converted to 'favorite_food').
Empty keys will trigger a bad request response. Also, non-object inputs for custom_attributes(e.g. an array or string), it will be ignored.
Keys that are default properties on the Contact resource or variations of it will result in an error. E.g., 'first_name', 'First Name', etc. are not valid inputs.
`,
optional: true,
},
},
async run({ $ }) {
const {
data, status,
} = await this.clickfunnels.upsertContact({
$,
returnFullResponse: true,
workspaceId: this.workspaceId,
data: {
contact: clearObj({
email_address: this.email,
first_name: this.firstName,
last_name: this.lastName,
phone_number: this.phoneNumber,
time_zone: this.timeZone,
fb_url: this.fbUrl,
twitter_url: this.twitterUrl,
instagram_url: this.instagramUrl,
linkedin_url: this.linkedinUrl,
website_url: this.websiteUrl,
tag_ids: parseObject(this.tagIds),
custom_attributes: parseObject(this.customAttributes),
}),
},
});

$.export("$summary", `Contact with Id: ${data.id} has been ${status === 200
? "updated"
: "created"} successfully.`);
return data;
},

};
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading