Skip to content

Commit 74dd14f

Browse files
Instantly - upgrade to API V2 (#16298)
* actions updates * source updates * pnpm-lock.yaml * fix pagination * update pagination * Fix source desc --------- Co-authored-by: Leo Vu <vunguyenhung@outlook.com>
1 parent 99c9257 commit 74dd14f

File tree

12 files changed

+364
-237
lines changed

12 files changed

+364
-237
lines changed

components/instantly/actions/add-lead-campaign/add-lead-campaign.mjs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import instantly from "../../instantly.app.mjs";
33

44
export default {
55
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",
6+
name: "Add Leads to Campaign",
7+
description: "Adds a lead or leads to a campaign for tracking or further actions. [See the documentation](https://developer.instantly.ai/api/v2/lead/moveleads)",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
instantly,
12-
leads: {
12+
leadIds: {
1313
propDefinition: [
1414
instantly,
15-
"leads",
15+
"leadIds",
1616
],
1717
},
1818
campaignId: {
@@ -21,30 +21,42 @@ export default {
2121
"campaignId",
2222
],
2323
},
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-
},
3024
skipIfInCampaign: {
3125
type: "boolean",
3226
label: "Skip if in Campaign",
3327
description: "Skip lead if it exists in the campaign",
3428
optional: true,
3529
},
30+
waitForCompletion: {
31+
type: "boolean",
32+
label: "Wait for Completion",
33+
description: "Set to `true` to poll the API in 3-second intervals until the background job is completed",
34+
optional: true,
35+
},
3636
},
3737
async run({ $ }) {
38-
const response = await this.instantly.addLeadsToCampaign({
38+
let response = await this.instantly.addLeadsToCampaign({
3939
$,
4040
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,
41+
ids: parseObject(this.leadIds),
42+
to_campaign_id: this.campaignId,
43+
check_duplicates_in_campaigns: this.skipIfInCampaign,
4544
},
4645
});
47-
$.export("$summary", `Added ${response.leads_uploaded} leads to campaign ${this.campaignId}`);
46+
47+
if (this.waitForCompletion) {
48+
const jobId = response.id;
49+
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
50+
while (response.status === "pending" || response.status === "in-progress") {
51+
response = await this.instantly.getBackgroundJob({
52+
$,
53+
jobId,
54+
});
55+
await timer(3000);
56+
}
57+
}
58+
59+
$.export("$summary", `Added ${this.leadIds.length} lead(s) to campaign ${this.campaignId}`);
4860
return response;
4961
},
5062
};

components/instantly/actions/add-tags-campaign/add-tags-campaign.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import instantly from "../../instantly.app.mjs";
44
export default {
55
key: "instantly-add-tags-campaign",
66
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",
7+
description: "Adds tags to a specific campaign. [See the documentation](https://developer.instantly.ai/api/v2/customtag/toggletagresource)",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
instantly,
@@ -15,6 +15,7 @@ export default {
1515
"campaignId",
1616
],
1717
type: "string[]",
18+
description: "The campaign IDs to assign tags to",
1819
},
1920
tagIds: {
2021
propDefinition: [
@@ -34,7 +35,7 @@ export default {
3435
resource_ids: parseObject(this.campaignIds),
3536
},
3637
});
37-
$.export("$summary", response.message);
38+
$.export("$summary", "Successfully added tags to campaign(s)");
3839
return response;
3940
},
4041
};

components/instantly/actions/update-lead-status/update-lead-status.mjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import instantly from "../../instantly.app.mjs";
44
export default {
55
key: "instantly-update-lead-status",
66
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",
7+
description: "Updates the interest status of a lead in a campaign. [See the documentation](https://developer.instantly.ai/api/v2/customtag/toggletagresource)",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
instantly,
@@ -18,8 +18,14 @@ export default {
1818
email: {
1919
propDefinition: [
2020
instantly,
21-
"email",
21+
"leadIds",
22+
() => ({
23+
valueKey: "email",
24+
}),
2225
],
26+
type: "string",
27+
label: "Lead Email",
28+
description: "Email address of the lead to update",
2329
},
2430
newStatus: {
2531
propDefinition: [
@@ -33,12 +39,12 @@ export default {
3339
const response = await this.instantly.updateLeadStatus({
3440
$,
3541
data: {
36-
email: this.email,
37-
new_status: this.newStatus,
42+
lead_email: this.email,
43+
interest_value: this.newStatus,
3844
campaign_id: this.campaignId,
3945
},
4046
});
41-
$.export("$summary", `Updated lead ${this.email} to status '${this.newStatus}'`);
47+
$.export("$summary", `Updated status of lead: ${this.email}`);
4248
return response;
4349
} catch ({ response }) {
4450
throw new ConfigurationError(response.data.error);
Lines changed: 17 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,36 @@
11
export const LIMIT = 100;
22

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-
},
3+
export const NEW_STATUS_OPTIONS = [
324
{
33-
label: "Account Error",
34-
value: "account_error",
5+
label: "Out of Office",
6+
value: "0",
357
},
368
{
37-
label: "Lead Not Interested",
38-
value: "lead_not_interested",
9+
label: "Interested",
10+
value: "1",
3911
},
4012
{
41-
label: "Lead Neutral",
42-
value: "lead_neutral",
13+
label: "Meeting Booked",
14+
value: "2",
4315
},
4416
{
45-
label: "Lead Meeting Booked",
46-
value: "lead_meeting_booked",
17+
label: "Meeting Completed",
18+
value: "3",
4719
},
4820
{
49-
label: "Lead Meeting Completed",
50-
value: "lead_meeting_completed",
21+
label: "Closed",
22+
value: "4",
5123
},
5224
{
53-
label: "Lead Closed",
54-
value: "lead_closed",
25+
label: "Not Interested",
26+
value: "-1",
5527
},
5628
{
57-
label: "Lead Out of Office",
58-
value: "lead_out_of_office",
29+
label: "Wrong Person",
30+
value: "-2",
5931
},
6032
{
61-
label: "Lead Wrong Person",
62-
value: "lead_wrong_person",
33+
label: "Lost",
34+
value: "-3",
6335
},
6436
];
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-
];

0 commit comments

Comments
 (0)