Skip to content

Commit 2e729e5

Browse files
authored
New Components - instantly (#15228)
* instantly init * [Components] instantly #15226 Sources - New Event (Instant) Actions - Add Tags Campaign - Add Lead Campaign - Update Lead Status * pnpm update * pnpm update * fix description * add documentation URL * pnpm update
1 parent 8b4c746 commit 2e729e5

File tree

13 files changed

+539
-100
lines changed

13 files changed

+539
-100
lines changed

components/charthop/charthop.app.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import instantly from "../../instantly.app.mjs";
3+
4+
export default {
5+
key: "instantly-add-lead-campaign",
6+
name: "Add Lead to Campaign",
7+
description: "Adds a lead to a campaign for tracking or further actions. [See the documentation](https://developer.instantly.ai/lead/add-leads-to-a-campaign)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
instantly,
12+
leads: {
13+
propDefinition: [
14+
instantly,
15+
"leads",
16+
],
17+
},
18+
campaignId: {
19+
propDefinition: [
20+
instantly,
21+
"campaignId",
22+
],
23+
},
24+
skipIfInWorkspace: {
25+
type: "boolean",
26+
label: "Skip if in Workspace",
27+
description: "Skip lead if it exists in any campaigns in the workspace",
28+
optional: true,
29+
},
30+
skipIfInCampaign: {
31+
type: "boolean",
32+
label: "Skip if in Campaign",
33+
description: "Skip lead if it exists in the campaign",
34+
optional: true,
35+
},
36+
},
37+
async run({ $ }) {
38+
const response = await this.instantly.addLeadsToCampaign({
39+
$,
40+
data: {
41+
leads: parseObject(this.leads),
42+
campaign_id: this.campaignId,
43+
skip_if_in_workspace: this.skipIfInWorkspace,
44+
skip_if_in_campaign: this.skipIfInCampaign,
45+
},
46+
});
47+
$.export("$summary", `Added ${response.leads_uploaded} leads to campaign ${this.campaignId}`);
48+
return response;
49+
},
50+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import instantly from "../../instantly.app.mjs";
3+
4+
export default {
5+
key: "instantly-add-tags-campaign",
6+
name: "Add Tags to Campaign",
7+
description: "Adds tags to a specific campaign. [See the documentation](https://developer.instantly.ai/tags/assign-or-unassign-a-tag)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
instantly,
12+
campaignIds: {
13+
propDefinition: [
14+
instantly,
15+
"campaignId",
16+
],
17+
type: "string[]",
18+
},
19+
tagIds: {
20+
propDefinition: [
21+
instantly,
22+
"tagIds",
23+
],
24+
},
25+
},
26+
async run({ $ }) {
27+
const response = await this.instantly.addTagsToCampaign({
28+
$,
29+
data: {
30+
campaign_id: this.campaignId,
31+
tag_ids: parseObject(this.tagIds),
32+
resource_type: 2,
33+
assign: true,
34+
resource_ids: parseObject(this.campaignIds),
35+
},
36+
});
37+
$.export("$summary", response.message);
38+
return response;
39+
},
40+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import instantly from "../../instantly.app.mjs";
3+
4+
export default {
5+
key: "instantly-update-lead-status",
6+
name: "Update Lead Status",
7+
description: "Updates the status of a lead in a campaign. [See the documentation](https://developer.instantly.ai/lead/update-lead-status)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
instantly,
12+
campaignId: {
13+
propDefinition: [
14+
instantly,
15+
"campaignId",
16+
],
17+
},
18+
email: {
19+
propDefinition: [
20+
instantly,
21+
"email",
22+
],
23+
},
24+
newStatus: {
25+
propDefinition: [
26+
instantly,
27+
"newStatus",
28+
],
29+
},
30+
},
31+
async run({ $ }) {
32+
try {
33+
const response = await this.instantly.updateLeadStatus({
34+
$,
35+
data: {
36+
email: this.email,
37+
new_status: this.newStatus,
38+
campaign_id: this.campaignId,
39+
},
40+
});
41+
$.export("$summary", `Updated lead ${this.email} to status '${this.newStatus}'`);
42+
return response;
43+
} catch ({ response }) {
44+
throw new ConfigurationError(response.data.error);
45+
}
46+
},
47+
};
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
export const LIMIT = 100;
2+
3+
export const EVENT_TYPE_OPTIONS = [
4+
{
5+
label: "Email Sent",
6+
value: "email_sent",
7+
},
8+
{
9+
label: "Email Bounced",
10+
value: "email_bounced",
11+
},
12+
{
13+
label: "Email Opened",
14+
value: "email_opened",
15+
},
16+
{
17+
label: "Email Link Clicked",
18+
value: "email_link_clicked",
19+
},
20+
{
21+
label: "Reply Received",
22+
value: "reply_received",
23+
},
24+
{
25+
label: "Lead Unsubscribed",
26+
value: "lead_unsubscribed",
27+
},
28+
{
29+
label: "Campaign Completed",
30+
value: "campaign_completed",
31+
},
32+
{
33+
label: "Account Error",
34+
value: "account_error",
35+
},
36+
{
37+
label: "Lead Not Interested",
38+
value: "lead_not_interested",
39+
},
40+
{
41+
label: "Lead Neutral",
42+
value: "lead_neutral",
43+
},
44+
{
45+
label: "Lead Meeting Booked",
46+
value: "lead_meeting_booked",
47+
},
48+
{
49+
label: "Lead Meeting Completed",
50+
value: "lead_meeting_completed",
51+
},
52+
{
53+
label: "Lead Closed",
54+
value: "lead_closed",
55+
},
56+
{
57+
label: "Lead Out of Office",
58+
value: "lead_out_of_office",
59+
},
60+
{
61+
label: "Lead Wrong Person",
62+
value: "lead_wrong_person",
63+
},
64+
];
65+
66+
export const NEW_STATUS_OPTIONS = [
67+
"Active",
68+
"Completed",
69+
"Unsubscribed",
70+
"Interested",
71+
"Meeting Booked",
72+
"Meeting Completed",
73+
"Closed",
74+
"Out of Office",
75+
"Not Interested",
76+
"Wrong Person",
77+
];

components/instantly/common/utils.mjs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

0 commit comments

Comments
 (0)