Skip to content

Commit c671c73

Browse files
authored
Salesloft new components (#16954)
* Salesloft app (AI-generated with improvements) * pnpm * Adjustments * pnpm * Adjustments * Webhook adjustments * removing log * ESLint fix
1 parent ceea1c8 commit c671c73

File tree

10 files changed

+461
-7
lines changed

10 files changed

+461
-7
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import salesloft from "../../salesloft.app.mjs";
2+
3+
export default {
4+
key: "salesloft-add-person-to-cadence",
5+
name: "Add Person to Cadence",
6+
description: "Adds a person to a cadence in Salesloft. [See the documentation](https://developers.salesloft.com/docs/api/cadence-memberships-create/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
salesloft,
11+
personId: {
12+
propDefinition: [
13+
salesloft,
14+
"personId",
15+
],
16+
},
17+
cadenceId: {
18+
propDefinition: [
19+
salesloft,
20+
"cadenceId",
21+
],
22+
},
23+
userId: {
24+
propDefinition: [
25+
salesloft,
26+
"userId",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.salesloft.addPersonToCadence({
32+
$,
33+
data: {
34+
person_id: this.personId,
35+
cadence_id: this.cadenceId,
36+
user_id: this.userId,
37+
},
38+
});
39+
40+
$.export("$summary", `Successfully added person ${this.personId} to cadence ${this.cadenceId}`);
41+
42+
return response;
43+
},
44+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import salesloft from "../../salesloft.app.mjs";
2+
3+
export default {
4+
key: "salesloft-create-note",
5+
name: "Create Note",
6+
description: "Creates a new note in Salesloft. [See the documentation](https://developers.salesloft.com/docs/api/notes-create/)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
salesloft,
11+
content: {
12+
type: "string",
13+
label: "Content",
14+
description: "The content of the note",
15+
},
16+
associatedWithType: {
17+
type: "string",
18+
label: "Associated Record Type",
19+
description: "The type of record this note is associated with",
20+
options: [
21+
"person",
22+
"account",
23+
],
24+
},
25+
associatedWithId: {
26+
propDefinition: [
27+
salesloft,
28+
"recordId",
29+
({ associatedWithType }) => ({
30+
recordType: associatedWithType,
31+
}),
32+
],
33+
},
34+
skipActivities: {
35+
type: "boolean",
36+
label: "Skip Activities",
37+
description: "If true, no activities will be created for this note",
38+
optional: true,
39+
default: false,
40+
},
41+
},
42+
async run({ $ }) {
43+
const response = await this.salesloft.createNote({
44+
$,
45+
data: {
46+
content: this.content,
47+
associated_with_id: this.associatedWithId,
48+
associated_with_type: this.associatedWithType,
49+
skip_activities: this.skipActivities,
50+
},
51+
});
52+
53+
$.export("$summary", `Successfully created note for ${this.associatedWithType.toLowerCase()} ${this.associatedWithId}`);
54+
55+
return response;
56+
},
57+
};
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import salesloft from "../../salesloft.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "salesloft-create-person",
6+
name: "Create Person",
7+
description: "Creates a new person in Salesloft. [See the documentation](https://developers.salesloft.com/docs/api/people-create/)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
salesloft,
12+
info: {
13+
type: "alert",
14+
alertType: "info",
15+
content: "Either `Email Address` or both `Phone` and `Last Name` must be provided.",
16+
},
17+
email: {
18+
type: "string",
19+
label: "Email",
20+
description: "The email address of the person",
21+
optional: true,
22+
},
23+
firstName: {
24+
type: "string",
25+
label: "First Name",
26+
description: "The first name of the person",
27+
optional: true,
28+
},
29+
lastName: {
30+
type: "string",
31+
label: "Last Name",
32+
description: "The last name of the person",
33+
optional: true,
34+
},
35+
phone: {
36+
type: "string",
37+
label: "Phone",
38+
description: "The phone number of the person",
39+
optional: true,
40+
},
41+
title: {
42+
type: "string",
43+
label: "Title",
44+
description: "The job title of the person",
45+
optional: true,
46+
},
47+
company: {
48+
type: "string",
49+
label: "Company",
50+
description: "The company name of the person",
51+
optional: true,
52+
},
53+
},
54+
async run({ $ }) {
55+
if (!this.email && !(this.phone && this.lastName)) {
56+
throw new ConfigurationError("Either `Email Address` or both `Phone` and `Last Name` must be provided");
57+
}
58+
59+
const response = await this.salesloft.createPerson({
60+
$,
61+
data: {
62+
email_address: this.email,
63+
first_name: this.firstName,
64+
last_name: this.lastName,
65+
phone: this.phone,
66+
title: this.title,
67+
company_name: this.company,
68+
},
69+
});
70+
71+
$.export("$summary", `Successfully created person (ID: ${response.id})`);
72+
73+
return response;
74+
},
75+
};

components/salesloft/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/salesloft",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Salesloft Components",
55
"main": "salesloft.app.mjs",
66
"keywords": [
@@ -9,7 +9,10 @@
99
],
1010
"homepage": "https://pipedream.com/apps/salesloft",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"dependencies": {
13+
"@pipedream/platform": "^3.0.3"
14+
},
1215
"publishConfig": {
1316
"access": "public"
1417
}
15-
}
18+
}
Lines changed: 164 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,171 @@
1+
import {
2+
axios, ConfigurationError,
3+
} from "@pipedream/platform";
4+
15
export default {
26
type: "app",
37
app: "salesloft",
4-
propDefinitions: {},
8+
propDefinitions: {
9+
personId: {
10+
type: "string",
11+
label: "Person ID",
12+
description: "Select a person to add to the cadence or provide a person ID",
13+
async options({ page }) {
14+
const people = await this.listPeople({
15+
params: {
16+
per_page: 100,
17+
page: page + 1,
18+
},
19+
});
20+
return people?.map((person) => ({
21+
label: person.full_email_address ?? person.email_address ?? person.display_name,
22+
value: person.id,
23+
}));
24+
},
25+
},
26+
recordId: {
27+
type: "string",
28+
label: "Associated Record ID",
29+
description: "Select a record (a person or account) to associate this note with",
30+
async options({
31+
page, recordType,
32+
}) {
33+
if (recordType === "person") {
34+
const people = await this.listPeople({
35+
params: {
36+
per_page: 100,
37+
page: page + 1,
38+
},
39+
});
40+
return people?.map((person) => ({
41+
label: person.full_email_address ?? person.email_address ?? person.display_name,
42+
value: person.id,
43+
}));
44+
} else if (recordType === "account") {
45+
const accounts = await this.listAccounts({
46+
params: {
47+
per_page: 100,
48+
page: page + 1,
49+
},
50+
});
51+
return accounts?.map((account) => ({
52+
label: account.name,
53+
value: account.id,
54+
}));
55+
} else throw new ConfigurationError("Invalid record type, select either `person` or `account`");
56+
},
57+
},
58+
cadenceId: {
59+
type: "string",
60+
label: "Cadence ID",
61+
description: "Select a cadence or provide a cadence ID",
62+
async options({ page }) {
63+
const cadences = await this.listCadences({
64+
params: {
65+
per_page: 100,
66+
page: page + 1,
67+
},
68+
});
69+
return cadences?.map((cadence) => ({
70+
label: cadence.name,
71+
value: cadence.id,
72+
}));
73+
},
74+
},
75+
userId: {
76+
type: "string",
77+
label: "User ID",
78+
description: "Select a user who will own this cadence membership or provide a user ID. Defaults to the authenticated user if not provided.",
79+
optional: true,
80+
async options({ page }) {
81+
const users = await this.listUsers({
82+
params: {
83+
per_page: 100,
84+
page: page + 1,
85+
},
86+
});
87+
return users?.map((user) => ({
88+
label: user.name ?? user.email,
89+
value: user.id,
90+
}));
91+
},
92+
},
93+
},
594
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
95+
_apiUrl() {
96+
return "https://api.salesloft.com/v2";
97+
},
98+
async _makeRequest({
99+
$ = this,
100+
path,
101+
...args
102+
}) {
103+
const response = await axios($, {
104+
url: `${this._apiUrl()}${path}`,
105+
headers: {
106+
Authorization: `Bearer ${this.$auth.api_key}`,
107+
},
108+
...args,
109+
});
110+
return response.data;
111+
},
112+
async createPerson(args = {}) {
113+
return this._makeRequest({
114+
path: "/people",
115+
method: "POST",
116+
...args,
117+
});
118+
},
119+
async addPersonToCadence(args = {}) {
120+
return this._makeRequest({
121+
path: "/cadence_memberships",
122+
method: "POST",
123+
...args,
124+
});
125+
},
126+
async createNote(args = {}) {
127+
return this._makeRequest({
128+
path: "/notes",
129+
method: "POST",
130+
...args,
131+
});
132+
},
133+
async createWebhookSubscription(args = {}) {
134+
return this._makeRequest({
135+
path: "/webhook_subscriptions",
136+
method: "POST",
137+
...args,
138+
});
139+
},
140+
async deleteWebhookSubscription(subscriptionId) {
141+
return this._makeRequest({
142+
path: `/webhook_subscriptions/${subscriptionId}`,
143+
method: "DELETE",
144+
});
145+
},
146+
async listPeople(args = {}) {
147+
return this._makeRequest({
148+
path: "/people",
149+
...args,
150+
});
151+
},
152+
async listCadences(args = {}) {
153+
return this._makeRequest({
154+
path: "/cadences",
155+
...args,
156+
});
157+
},
158+
async listUsers(args = {}) {
159+
return this._makeRequest({
160+
path: "/users",
161+
...args,
162+
});
163+
},
164+
async listAccounts(args = {}) {
165+
return this._makeRequest({
166+
path: "/accounts",
167+
...args,
168+
});
9169
},
10170
},
11171
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import common from "../common/webhook.mjs";
2+
3+
export default {
4+
...common,
5+
key: "salesloft-cadence-updated-instant",
6+
name: "Cadence Updated (Instant)",
7+
description: "Emit new event when a cadence is updated in Salesloft. [See the documentation](https://developers.salesloft.com/docs/api/webhook-subscriptions/)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
methods: {
12+
...common.methods,
13+
getEventType() {
14+
return "cadence_updated";
15+
},
16+
getSummary(data) {
17+
return `Cadence updated: ${data.name || data.id}`;
18+
},
19+
},
20+
};

0 commit comments

Comments
 (0)