Skip to content

Commit 697baf7

Browse files
Add Adversus actions: Create/Update Lead, Add Note/Activity, Change Lead Status, Assign to Campaign
- Added Create or Update Lead action - Added Add Note or Activity action - Added Change Lead Status action - Added Assign Lead to Campaign action - Updated adversus.app.mjs with API methods, authentication, and JSDoc comments - Updated README.md with API documentation link - Added comprehensive JSDoc documentation to all methods (meets 80% coverage requirement) - Fixed data merging in changeLeadStatus and assignLeadToCampaign methods - Used propDefinition pattern for consistency across all actions
1 parent ca39807 commit 697baf7

File tree

6 files changed

+424
-4
lines changed

6 files changed

+424
-4
lines changed

components/adversus/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Adversus is a powerful dialer and CRM platform tailored to streamline outbound call center operations and enhance sales processes. Leveraging the Adversus API with Pipedream opens up immense possibilities for automating call workflows, syncing lead data, and crafting custom triggers based on call outcomes or performance metrics. By creating serverless workflows on Pipedream, you can connect Adversus to a myriad of other apps and services to optimize lead management, automate repetitive tasks, and gain real-time insights into your sales funnel.
44

5+
# API Documentation
6+
7+
For detailed API documentation, please refer to: https://solutions.adversus.io/api
8+
59
# Example Use Cases
610

711
- **Automated Lead Syncing with CRM**: Whenever a new lead is added to Adversus, the workflow automatically syncs this lead to your chosen CRM, such as Salesforce or HubSpot. It ensures that any updates made by the sales team in Adversus reflect in the CRM, keeping both systems in harmony and up-to-date.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import adversus from "../../adversus.app.mjs";
2+
3+
export default {
4+
key: "adversus-add-note-activity",
5+
name: "Add Note or Activity",
6+
description: "Add a note or activity to a lead in Adversus. [See the API documentation](https://solutions.adversus.io/api).",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
adversus,
16+
leadId: {
17+
propDefinition: [
18+
adversus,
19+
"leadId",
20+
],
21+
},
22+
note: {
23+
type: "string",
24+
label: "Note",
25+
description: "The note text to add to the lead",
26+
optional: true,
27+
},
28+
activityType: {
29+
type: "string",
30+
label: "Activity Type",
31+
description: "The type of activity (e.g., 'call', 'email', 'meeting')",
32+
optional: true,
33+
},
34+
activityDescription: {
35+
type: "string",
36+
label: "Activity Description",
37+
description: "The description of the activity",
38+
optional: true,
39+
},
40+
additionalFields: {
41+
type: "object",
42+
label: "Additional Fields",
43+
description: "Additional fields to include in the note or activity",
44+
optional: true,
45+
},
46+
},
47+
/**
48+
* Execute the action to add a note or activity to a lead
49+
* @param {Object} $ - Pipedream context
50+
* @returns {Promise} The response from adding note/activity
51+
*/
52+
async run({ $ }) {
53+
const promises = [];
54+
55+
if (this.note) {
56+
promises.push(
57+
this.adversus.addNoteToLead(this.leadId, {
58+
data: {
59+
note: this.note,
60+
...(this.additionalFields || {}),
61+
},
62+
})
63+
);
64+
}
65+
66+
if (this.activityType || this.activityDescription) {
67+
promises.push(
68+
this.adversus.addActivityToLead(this.leadId, {
69+
data: {
70+
...(this.activityType && { type: this.activityType }),
71+
...(this.activityDescription && { description: this.activityDescription }),
72+
...(this.additionalFields || {}),
73+
},
74+
})
75+
);
76+
}
77+
78+
if (promises.length === 0) {
79+
throw new Error("Either 'Note' or 'Activity Type'/'Activity Description' must be provided");
80+
}
81+
82+
const results = await Promise.all(promises);
83+
84+
$.export("$summary", `Successfully added ${promises.length} item(s) to lead ${this.leadId}`);
85+
86+
return results.length === 1 ? results[0] : results;
87+
},
88+
};
89+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import adversus from "../../adversus.app.mjs";
2+
3+
export default {
4+
key: "adversus-assign-to-campaign",
5+
name: "Assign Lead to Campaign",
6+
description: "Assign a lead to a campaign in Adversus. [See the API documentation](https://solutions.adversus.io/api).",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: true,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
adversus,
16+
leadId: {
17+
propDefinition: [
18+
adversus,
19+
"leadId",
20+
],
21+
},
22+
campaignId: {
23+
propDefinition: [
24+
adversus,
25+
"campaignId",
26+
],
27+
},
28+
additionalFields: {
29+
type: "object",
30+
label: "Additional Fields",
31+
description: "Additional fields to include when assigning to campaign",
32+
optional: true,
33+
},
34+
},
35+
/**
36+
* Execute the action to assign a lead to a campaign
37+
* @param {Object} $ - Pipedream context
38+
* @returns {Promise} The response from assigning the lead to campaign
39+
*/
40+
async run({ $ }) {
41+
const response = await this.adversus.assignLeadToCampaign(this.leadId, this.campaignId, {
42+
data: {
43+
...(this.additionalFields || {}),
44+
},
45+
});
46+
47+
$.export("$summary", `Successfully assigned lead ${this.leadId} to campaign ${this.campaignId}`);
48+
49+
return response;
50+
},
51+
};
52+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import adversus from "../../adversus.app.mjs";
2+
3+
export default {
4+
key: "adversus-change-lead-status",
5+
name: "Change Lead Status",
6+
description: "Change the status of a lead in Adversus. [See the API documentation](https://solutions.adversus.io/api).",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: true,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
adversus,
16+
leadId: {
17+
propDefinition: [
18+
adversus,
19+
"leadId",
20+
],
21+
},
22+
statusId: {
23+
propDefinition: [
24+
adversus,
25+
"statusId",
26+
],
27+
},
28+
additionalFields: {
29+
type: "object",
30+
label: "Additional Fields",
31+
description: "Additional fields to include when changing the status",
32+
optional: true,
33+
},
34+
},
35+
/**
36+
* Execute the action to change a lead's status
37+
* @param {Object} $ - Pipedream context
38+
* @returns {Promise} The response from changing the lead status
39+
*/
40+
async run({ $ }) {
41+
const response = await this.adversus.changeLeadStatus(this.leadId, this.statusId, {
42+
data: {
43+
...(this.additionalFields || {}),
44+
},
45+
});
46+
47+
$.export("$summary", `Successfully changed status of lead ${this.leadId} to status ${this.statusId}`);
48+
49+
return response;
50+
},
51+
};
52+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import adversus from "../../adversus.app.mjs";
2+
3+
export default {
4+
key: "adversus-create-or-update-lead",
5+
name: "Create or Update Lead",
6+
description: "Create a new lead or update an existing lead in Adversus. [See the API documentation](https://solutions.adversus.io/api).",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: true,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
adversus,
16+
firstName: {
17+
type: "string",
18+
label: "First Name",
19+
description: "The first name of the lead",
20+
optional: true,
21+
},
22+
lastName: {
23+
type: "string",
24+
label: "Last Name",
25+
description: "The last name of the lead",
26+
optional: true,
27+
},
28+
email: {
29+
type: "string",
30+
label: "Email",
31+
description: "The email address of the lead",
32+
optional: true,
33+
},
34+
phone: {
35+
type: "string",
36+
label: "Phone",
37+
description: "The phone number of the lead",
38+
optional: true,
39+
},
40+
leadId: {
41+
propDefinition: [
42+
adversus,
43+
"leadId",
44+
],
45+
description: "The ID of the lead to update (leave empty to create a new lead)",
46+
optional: true,
47+
},
48+
additionalFields: {
49+
type: "object",
50+
label: "Additional Fields",
51+
description: "Additional fields to include in the lead data",
52+
optional: true,
53+
},
54+
},
55+
/**
56+
* Execute the action to create or update a lead
57+
* @param {Object} $ - Pipedream context
58+
* @returns {Promise} The created or updated lead response
59+
*/
60+
async run({ $ }) {
61+
const data = {
62+
...(this.firstName && { firstName: this.firstName }),
63+
...(this.lastName && { lastName: this.lastName }),
64+
...(this.email && { email: this.email }),
65+
...(this.phone && { phone: this.phone }),
66+
...(this.additionalFields || {}),
67+
};
68+
69+
const response = this.leadId
70+
? await this.adversus.updateLead(this.leadId, { data })
71+
: await this.adversus.createLead({ data });
72+
73+
$.export("$summary", this.leadId
74+
? `Successfully updated lead ${this.leadId}`
75+
: "Successfully created new lead");
76+
77+
return response;
78+
},
79+
};
80+

0 commit comments

Comments
 (0)