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
Expand Up @@ -3,16 +3,16 @@ import instantly from "../../instantly.app.mjs";

export default {
key: "instantly-add-lead-campaign",
name: "Add Lead to Campaign",
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)",
version: "0.0.1",
name: "Add Leads to Campaign",
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)",
version: "0.0.2",
type: "action",
props: {
instantly,
leads: {
leadIds: {
propDefinition: [
instantly,
"leads",
"leadIds",
],
},
campaignId: {
Expand All @@ -21,30 +21,42 @@ export default {
"campaignId",
],
},
skipIfInWorkspace: {
type: "boolean",
label: "Skip if in Workspace",
description: "Skip lead if it exists in any campaigns in the workspace",
optional: true,
},
skipIfInCampaign: {
type: "boolean",
label: "Skip if in Campaign",
description: "Skip lead if it exists in the campaign",
optional: true,
},
waitForCompletion: {
type: "boolean",
label: "Wait for Completion",
description: "Set to `true` to poll the API in 3-second intervals until the background job is completed",
optional: true,
},
},
async run({ $ }) {
const response = await this.instantly.addLeadsToCampaign({
let response = await this.instantly.addLeadsToCampaign({
$,
data: {
leads: parseObject(this.leads),
campaign_id: this.campaignId,
skip_if_in_workspace: this.skipIfInWorkspace,
skip_if_in_campaign: this.skipIfInCampaign,
ids: parseObject(this.leadIds),
to_campaign_id: this.campaignId,
check_duplicates_in_campaigns: this.skipIfInCampaign,
},
});
$.export("$summary", `Added ${response.leads_uploaded} leads to campaign ${this.campaignId}`);

if (this.waitForCompletion) {
const jobId = response.id;
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
while (response.status === "pending" || response.status === "in-progress") {
response = await this.instantly.getBackgroundJob({
$,
jobId,
});
await timer(3000);
}
}

$.export("$summary", `Added ${this.leadIds.length} lead(s) to campaign ${this.campaignId}`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import instantly from "../../instantly.app.mjs";
export default {
key: "instantly-add-tags-campaign",
name: "Add Tags to Campaign",
description: "Adds tags to a specific campaign. [See the documentation](https://developer.instantly.ai/tags/assign-or-unassign-a-tag)",
version: "0.0.1",
description: "Adds tags to a specific campaign. [See the documentation](https://developer.instantly.ai/api/v2/customtag/toggletagresource)",
version: "0.0.2",
type: "action",
props: {
instantly,
Expand All @@ -15,6 +15,7 @@ export default {
"campaignId",
],
type: "string[]",
description: "The campaign IDs to assign tags to",
},
tagIds: {
propDefinition: [
Expand All @@ -34,7 +35,7 @@ export default {
resource_ids: parseObject(this.campaignIds),
},
});
$.export("$summary", response.message);
$.export("$summary", "Successfully added tags to campaign(s)");
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import instantly from "../../instantly.app.mjs";
export default {
key: "instantly-update-lead-status",
name: "Update Lead Status",
description: "Updates the status of a lead in a campaign. [See the documentation](https://developer.instantly.ai/lead/update-lead-status)",
version: "0.0.1",
description: "Updates the interest status of a lead in a campaign. [See the documentation](https://developer.instantly.ai/api/v2/customtag/toggletagresource)",
version: "0.0.2",
type: "action",
props: {
instantly,
Expand All @@ -18,8 +18,14 @@ export default {
email: {
propDefinition: [
instantly,
"email",
"leadIds",
() => ({
valueKey: "email",
}),
],
type: "string",
label: "Lead Email",
description: "Email address of the lead to update",
},
newStatus: {
propDefinition: [
Expand All @@ -33,12 +39,12 @@ export default {
const response = await this.instantly.updateLeadStatus({
$,
data: {
email: this.email,
new_status: this.newStatus,
lead_email: this.email,
interest_value: this.newStatus,
campaign_id: this.campaignId,
},
});
$.export("$summary", `Updated lead ${this.email} to status '${this.newStatus}'`);
$.export("$summary", `Updated status of lead: ${this.email}`);
return response;
} catch ({ response }) {
throw new ConfigurationError(response.data.error);
Expand Down
75 changes: 17 additions & 58 deletions components/instantly/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -1,77 +1,36 @@
export const LIMIT = 100;

export const EVENT_TYPE_OPTIONS = [
{
label: "Email Sent",
value: "email_sent",
},
{
label: "Email Bounced",
value: "email_bounced",
},
{
label: "Email Opened",
value: "email_opened",
},
{
label: "Email Link Clicked",
value: "email_link_clicked",
},
{
label: "Reply Received",
value: "reply_received",
},
{
label: "Lead Unsubscribed",
value: "lead_unsubscribed",
},
{
label: "Campaign Completed",
value: "campaign_completed",
},
export const NEW_STATUS_OPTIONS = [
{
label: "Account Error",
value: "account_error",
label: "Out of Office",
value: "0",
},
{
label: "Lead Not Interested",
value: "lead_not_interested",
label: "Interested",
value: "1",
},
{
label: "Lead Neutral",
value: "lead_neutral",
label: "Meeting Booked",
value: "2",
},
{
label: "Lead Meeting Booked",
value: "lead_meeting_booked",
label: "Meeting Completed",
value: "3",
},
{
label: "Lead Meeting Completed",
value: "lead_meeting_completed",
label: "Closed",
value: "4",
},
{
label: "Lead Closed",
value: "lead_closed",
label: "Not Interested",
value: "-1",
},
{
label: "Lead Out of Office",
value: "lead_out_of_office",
label: "Wrong Person",
value: "-2",
},
{
label: "Lead Wrong Person",
value: "lead_wrong_person",
label: "Lost",
value: "-3",
},
];

export const NEW_STATUS_OPTIONS = [
"Active",
"Completed",
"Unsubscribed",
"Interested",
"Meeting Booked",
"Meeting Completed",
"Closed",
"Out of Office",
"Not Interested",
"Wrong Person",
];
Loading
Loading