Skip to content

New Components - nextlead #16752

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

Merged
merged 5 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
29 changes: 29 additions & 0 deletions components/nextlead/actions/search-leads/search-leads.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import nextlead from "../../nextlead.app.mjs";

export default {
key: "nextlead-search-leads",
name: "Search Leads",
description: "Search for leads by email in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#find)",
version: "0.0.1",
type: "action",
props: {
nextlead,
email: {
type: "string",
label: "Email",
description: "The email address to search for",
},
},
async run({ $ }) {
const response = await this.nextlead.searchLeads({
$,
data: {
email: this.email,
},
});
$.export("$summary", `Found ${response.length && response[0].found
? response.length
: 0} lead(s) for email: ${this.email}`);
return response;
},
};
45 changes: 41 additions & 4 deletions components/nextlead/nextlead.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "nextlead",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return this.$auth.api_url;
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
Authorization: `Bearer ${this.$auth.api_key}`,
},
...opts,
});
},
searchLeads(opts = {}) {
return this._makeRequest({
path: "/receive/contact/find-contact",
method: "POST",
...opts,
});
},
getNewlyCreatedLeads(opts = {}) {
return this._makeRequest({
path: "/polling/contact/user-created",
...opts,
});
},
getNewlyUpdatedLeads(opts = {}) {
return this._makeRequest({
path: "/polling/contact/user-edited",
...opts,
});
},
getContactsAddedToList(opts = {}) {
return this._makeRequest({
path: "/polling/email/added-to-list",
...opts,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/nextlead/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/nextlead",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Nextlead Components",
"main": "nextlead.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
14 changes: 14 additions & 0 deletions components/nextlead/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import nextlead from "../../nextlead.app.mjs";
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";

export default {
props: {
nextlead,
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "nextlead-new-lead-added-to-list",
name: "New Lead Added to List",
description: "Emit new event when a lead is added to a list in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#addedToList)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
generateMeta(lead) {
return {
id: lead.id,
summary: "Lead Added to List",
ts: Date.parse(lead.result.created_at),
};
},
},
async run() {
const leads = await this.nextlead.getContactsAddedToList();
for (const lead of leads) {
const meta = this.generateMeta(lead);
this.$emit(lead, meta);
}
},
sampleEmit,
};
16 changes: 16 additions & 0 deletions components/nextlead/sources/new-lead-added-to-list/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
"id": "cmay8b4jx0001ky04yb204e5b",
"result": {
"created_at": "2025-05-21T17:40:39.501Z",
"organization_id": "cmay3tgaa0002jr04l5tga7my",
"email": null,
"first_name": "Jane",
"last_name": "Doe",
"phone": null,
"address": null,
"civility": "NEUTRAL",
"status": null,
"opt_in_marketing": true,
"opt_in_newsletter": true
}
}
29 changes: 29 additions & 0 deletions components/nextlead/sources/new-lead-created/new-lead-created.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "nextlead-new-lead-created",
name: "New Lead Created",
description: "Emit new event when a new lead is captured in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#created)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
generateMeta(lead) {
return {
id: lead.id,
summary: "New Lead Created",
ts: Date.now(),
};
},
},
async run() {
const leads = await this.nextlead.getNewlyCreatedLeads();
for (const lead of leads) {
const meta = this.generateMeta(lead);
this.$emit(lead, meta);
}
},
sampleEmit,
};
19 changes: 19 additions & 0 deletions components/nextlead/sources/new-lead-created/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default {
"id": "cmay7x5ou0001k10442mgpngp",
"type": "CLIENT",
"civility": "NEUTRAL",
"first_name": null,
"last_name": null,
"birth_date": null,
"sector": null,
"activity": null,
"status": null,
"conversion_status": null,
"lead_score": null,
"phone": null,
"mobile": null,
"phone_pro": null,
"email": null,
"email2": null,
"email_verified": null
}
29 changes: 29 additions & 0 deletions components/nextlead/sources/new-lead-updated/new-lead-updated.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "nextlead-new-lead-updated",
name: "New Lead Updated",
description: "Emit new event when a lead is updated in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#edited)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
generateMeta(lead) {
return {
id: lead.id,
summary: "Lead Updated",
ts: Date.now(),
};
},
},
async run() {
const leads = await this.nextlead.getNewlyUpdatedLeads();
for (const lead of leads) {
const meta = this.generateMeta(lead);
this.$emit(lead, meta);
}
},
sampleEmit,
};
19 changes: 19 additions & 0 deletions components/nextlead/sources/new-lead-updated/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default {
"id": "cmay7zwqw000fib046wynimr1",
"type": "CLIENT",
"civility": "NEUTRAL",
"first_name": "Jane",
"last_name": "Doe",
"birth_date": null,
"sector": null,
"activity": null,
"status": null,
"conversion_status": null,
"lead_score": null,
"phone": null,
"mobile": null,
"phone_pro": null,
"email": null,
"email2": null,
"email_verified": null
}
11 changes: 8 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading