Skip to content
Closed
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,76 @@
import app from "../../apollo_io_oauth.app.mjs";

export default {
key: "apollo_io_oauth-add-contacts-to-sequence",
name: "Add Contacts to Sequence",
description: "Adds one or more contacts to a sequence in Apollo.io. [See the documentation](https://apolloio.github.io/apollo-api-docs/?shell#add-contacts-to-sequence)",
type: "action",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
app,
sequenceId: {
propDefinition: [
app,
"sequenceId",
],
},
contactIds: {
propDefinition: [
app,
"contactId",
],
type: "string[]",
label: "Contact IDs",
description: "Identifiers of the contacts to add to sequence",
},
emailAccountId: {
propDefinition: [
app,
"emailAccountId",
],
},
sequenceNoEmail: {
type: "boolean",
label: "Sequence No Email",
description: " Whether to still sequence the contact if he/she does not have an email address",
optional: true,
},
sequenceActiveInOtherCampaigns: {
type: "boolean",
label: "Sequence Active in Other Campaigns",
description: "Whether to still sequence the contact if he/she is active or paused in another sequence",
optional: true,
},
sequenceFinishedInOtherCampaigns: {
type: "boolean",
label: "Sequence Finished in Other Campaigns",
description: "Whether to still sequence the contact if he/she already finished another sequence",
optional: true,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
},
async run({ $ }) {
const { contacts } = await this.app.addContactsToSequence({
$,
sequenceId: this.sequenceId,
data: {
contact_ids: this.contactIds,
emailer_campaign_id: this.sequenceId,
send_email_from_email_account_id: this.emailAccountId,
sequence_no_email: this.sequenceNoEmail,
sequence_active_in_other_campaigns: this.sequenceActiveInOtherCampaigns,
sequence_finished_in_other_campaigns: this.sequenceFinishedInOtherCampaigns,
},
});

$.export("$summary", `Successfully added ${contacts.length} contact${contacts.length === 1
? ""
: "s"} to sequence.`);

return contacts;
},
Comment on lines +57 to +75
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard summary construction against missing contacts.

If the API response shape changes or omits contacts, this will throw at runtime when reading contacts.length. Default to an empty array before exporting $summary and returning data.

Suggested fix
-    const { contacts } = await this.app.addContactsToSequence({
+    const { contacts = [] } = await this.app.addContactsToSequence({
       $,
       sequenceId: this.sequenceId,
       data: {
         contact_ids: this.contactIds,
         emailer_campaign_id: this.sequenceId,
         send_email_from_email_account_id: this.emailAccountId,
         sequence_no_email: this.sequenceNoEmail,
         sequence_active_in_other_campaigns: this.sequenceActiveInOtherCampaigns,
         sequence_finished_in_other_campaigns: this.sequenceFinishedInOtherCampaigns,
       },
     });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { contacts } = await this.app.addContactsToSequence({
$,
sequenceId: this.sequenceId,
data: {
contact_ids: this.contactIds,
emailer_campaign_id: this.sequenceId,
send_email_from_email_account_id: this.emailAccountId,
sequence_no_email: this.sequenceNoEmail,
sequence_active_in_other_campaigns: this.sequenceActiveInOtherCampaigns,
sequence_finished_in_other_campaigns: this.sequenceFinishedInOtherCampaigns,
},
});
$.export("$summary", `Successfully added ${contacts.length} contact${contacts.length === 1
? ""
: "s"} to sequence.`);
return contacts;
},
const { contacts = [] } = await this.app.addContactsToSequence({
$,
sequenceId: this.sequenceId,
data: {
contact_ids: this.contactIds,
emailer_campaign_id: this.sequenceId,
send_email_from_email_account_id: this.emailAccountId,
sequence_no_email: this.sequenceNoEmail,
sequence_active_in_other_campaigns: this.sequenceActiveInOtherCampaigns,
sequence_finished_in_other_campaigns: this.sequenceFinishedInOtherCampaigns,
},
});
$.export("$summary", `Successfully added ${contacts.length} contact${contacts.length === 1
? ""
: "s"} to sequence.`);
return contacts;
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/apollo_io_oauth/actions/add-contacts-to-sequence/add-contacts-to-sequence.mjs`
around lines 57 - 75, The response may omit contacts, so guard against undefined
before using contacts.length and before returning; after calling
this.app.addContactsToSequence in the add-contacts-to-sequence action, coerce or
default the returned contacts to an empty array (e.g., const contacts =
resp.contacts || []) and then use that contacts variable in the
$.export("$summary", ...) and in the return to avoid runtime errors when
contacts is missing.

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import app from "../../apollo_io_oauth.app.mjs";

export default {
key: "apollo_io_oauth-create-account",
name: "Create Account",
description: "Creates a new account in Apollo.io. [See the documentation](https://apolloio.github.io/apollo-api-docs/?shell#create-an-account)",
type: "action",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
app,
name: {
propDefinition: [
app,
"name",
],
},
domain: {
propDefinition: [
app,
"domain",
],
},
address: {
propDefinition: [
app,
"address",
],
description: "The address string for this account, Apollo will intelligently infer the city, state, country, and time zone from your address",
},
phone: {
propDefinition: [
app,
"phone",
],
description: "The corporate phone for this account",
},
},
async run({ $ }) {
const { account } = await this.app.createAccount({
$,
data: {
name: this.name,
domain: this.domain,
raw_address: this.address,
phone_number: this.phone,
},
});

$.export("$summary", `Successfully created account with ID ${account.id}`);

return account;
},
};
100 changes: 100 additions & 0 deletions components/apollo_io_oauth/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import app from "../../apollo_io_oauth.app.mjs";

export default {
key: "apollo_io_oauth-create-contact",
name: "Create Contact",
description: "Creates a new contact in Apollo.io. [See the documentation](https://apolloio.github.io/apollo-api-docs/?shell#create-a-contact)",
type: "action",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
app,
email: {
propDefinition: [
app,
"email",
],
},
firstName: {
propDefinition: [
app,
"firstName",
],
},
lastName: {
propDefinition: [
app,
"lastName",
],
},
title: {
propDefinition: [
app,
"title",
],
},
accountId: {
propDefinition: [
app,
"accountId",
],
optional: true,
},
websiteUrl: {
propDefinition: [
app,
"websiteUrl",
],
},
labelNames: {
propDefinition: [
app,
"labelNames",
],
},
contactStageId: {
propDefinition: [
app,
"contactStageId",
],
optional: true,
},
address: {
propDefinition: [
app,
"address",
],
},
phone: {
propDefinition: [
app,
"phone",
],
},
},
async run({ $ }) {
const { contact } = await this.app.createContact({
$,
data: {
email: this.email,
first_name: this.firstName,
last_name: this.lastName,
title: this.title,
account_id: this.accountId,
website_url: this.websiteUrl,
label_names: this.labelNames,
contact_stage_id: this.contactStageId,
present_raw_address: this.address,
direct_phone: this.phone,
},
});
Comment thread
volcano303 marked this conversation as resolved.

$.export("$summary", `Successfully created contact with ID ${contact.id}`);

return contact;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import app from "../../apollo_io_oauth.app.mjs";

export default {
key: "apollo_io_oauth-create-opportunity",
name: "Create Opportunity",
description: "Creates a new opportunity in Apollo.io. [See the documentation](https://apolloio.github.io/apollo-api-docs/?shell#create-opportunity)",
type: "action",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
app,
ownerId: {
propDefinition: [
app,
"ownerId",
],
optional: true,
},
name: {
propDefinition: [
app,
"name",
],
description: "The name of the opportunity.",
},
amount: {
type: "integer",
label: "Amount",
description: "The amount of money involved in the opportunity/deal.",
optional: true,
},
opportunityStageId: {
propDefinition: [
app,
"opportunityStageId",
],
},
closedDate: {
type: "string",
label: "Closed Date",
description: "The date the opportunity was closed.",
},
accountId: {
propDefinition: [
app,
"accountId",
],
},
},
async run({ $ }) {
const { opportunity } = await this.app.createOpportunity({
$,
data: {
owner_id: this.ownerId,
name: this.name,
amount: this.amount,
opportunity_stage_id: this.opportunityStageId,
closed_date: this.closedDate,
account_id: this.accountId,
},
});

$.export("$summary", `Successfully created opportunity with ID ${opportunity.id}`);

return opportunity;
},
};
Loading