Skip to content

Salesforge new components #17525

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
65 changes: 65 additions & 0 deletions components/salesforge/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import app from "../../salesforge.app.mjs";

export default {
key: "salesforge-create-contact",
name: "Create Contact",
description: "Create a new contact in Salesforge. [See the documentation](https://api.salesforge.ai/public/v2/swagger/index.html)",
version: "0.0.1",
type: "action",
props: {
app,
workspaceId: {
propDefinition: [
app,
"workspaceId",
],
},
email: {
type: "string",
label: "Email",
description: "The email address of the contact",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the contact",
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the contact",
},
company: {
type: "string",
label: "Company",
description: "The company name of the contact",
optional: true,
},
linkedinUrl: {
type: "string",
label: "LinkedIn URL",
description: "The LinkedIn profile URL of the contact",
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "One or more tags to assign to the contact",
optional: true,
},
},
async run({ $ }) {
const {
app, workspaceId, ...data
} = this;

const response = await app.createContact({
$,
workspaceId,
data,
});

$.export("$summary", `Successfully created contact (ID: ${response.id})`);
return response;
},
};
7 changes: 5 additions & 2 deletions components/salesforge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/salesforge",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Salesforge Components",
"main": "salesforge.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
72 changes: 68 additions & 4 deletions components/salesforge/salesforge.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,75 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "salesforge",
propDefinitions: {},
propDefinitions: {
workspaceId: {
type: "string",
label: "Workspace ID",
description: "Select a workspace or provide a workspace ID",
async options({ page }) {
const response = await this.listWorkspaces({
params: {
offset: page,
},
});
return response.data?.map((workspace) => ({
label: workspace.name,
value: workspace.id,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_apiUrl() {
return "https://api.salesforge.ai/public/v2";
},
async _makeRequest({
$ = this,
path,
...args
}) {
return axios($, {
url: `${this._apiUrl()}${path}`,
headers: {
"Authorization": `${this.$auth.api_key}`,
},
...args,
});
},
async listWorkspaces(args = {}) {
return this._makeRequest({
path: "/workspaces",
...args,
});
},
async createWebhook({
workspaceId, ...args
}) {
return this._makeRequest({
path: `/workspaces/${workspaceId}/integrations/webhooks`,
method: "POST",
...args,
});
},
async deleteWebhook({
workspaceId, webhookId, ...args
}) {
return this._makeRequest({
path: `/workspaces/${workspaceId}/integrations/webhooks/${webhookId}`,
method: "DELETE",
...args,
});
},
async createContact({
workspaceId, ...args
}) {
return this._makeRequest({
path: `/workspaces/${workspaceId}/contacts`,
method: "POST",
...args,
});
},
},
};
56 changes: 56 additions & 0 deletions components/salesforge/sources/common/webhook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import salesforge from "../../salesforge.app.mjs";

export default {
props: {
salesforge,
db: "$.service.db",
http: "$.interface.http",
workspaceId: {
propDefinition: [
salesforge,
"workspaceId",
],
},
},
methods: {
_getWebhookId() {
return this.db.get("webhookId");
},
_setWebhookId(webhookId) {
this.db.set("webhookId", webhookId);
},
generateMeta(data) {
const { webhookInfo } = data;
const ts = webhookInfo?.eventTime
? new Date(webhookInfo.eventTime).valueOf()
: Date.now();
const id = `${this.getEventType()}-${ts}`;
return {
id,
summary: this.getSummary(data),
ts,
};
},
},
hooks: {
async activate() {
const response = await this.salesforge.createWebhook({
workspaceId: this.workspaceId,
data: {
name: `Pipedream ${this.getEventType()} webhook`,
type: this.getEventType(),
url: this.http.endpoint,
},
});
this._setWebhookId(response.id);
},
// Salesforge does not seem to support deactivating/deleting webhooks via the API
},
async run(event) {
const { body } = event;
if (body) {
const meta = this.generateMeta(body);
this.$emit(body, meta);
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import common from "../common/webhook.mjs";

export default {
...common,
key: "salesforge-contact-unsubscribed-instant",
name: "Contact Unsubscribed (Instant)",

Check warning on line 6 in components/salesforge/sources/contact-unsubscribed-instant/contact-unsubscribed-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a contact unsubscribes in Salesforge. [See the documentation](https://help.salesforge.ai/en/articles/8680365-how-to-use-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEventType() {
return "contact_unsubscribed";
},
getSummary({ contact }) {
return `Contact unsubscribed: ${contact?.email || "unknown contact"}`;
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import common from "../common/webhook.mjs";

export default {
...common,
key: "salesforge-email-bounced-instant",
name: "Email Bounced (Instant)",

Check warning on line 6 in components/salesforge/sources/email-bounced-instant/email-bounced-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when an email bounces in Salesforge. [See the documentation](https://help.salesforge.ai/en/articles/8680365-how-to-use-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEventType() {
return "email_bounced";
},
getSummary({ contact }) {
return `Email bounced to ${contact?.email || "unknown recipient"}`;
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import common from "../common/webhook.mjs";

export default {
...common,
key: "salesforge-email-opened-instant",
name: "Email Opened (Instant)",

Check warning on line 6 in components/salesforge/sources/email-opened-instant/email-opened-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when an email is opened in Salesforge. [See the documentation](https://help.salesforge.ai/en/articles/8680365-how-to-use-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEventType() {
return "email_opened";
},
getSummary({ sequenceEmail }) {
return `Email opened: "${sequenceEmail?.subject}"`;
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import common from "../common/webhook.mjs";

export default {
...common,
key: "salesforge-email-replied-instant",
name: "Email Reply Received (Instant)",

Check warning on line 6 in components/salesforge/sources/email-replied-instant/email-replied-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when an email reply is received in Salesforge. [See the documentation](https://help.salesforge.ai/en/articles/8680365-how-to-use-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEventType() {
return "email_replied";
},
getSummary({ sequenceEmail }) {
return `Email reply received: "${sequenceEmail?.subject}"`;
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import common from "../common/webhook.mjs";

export default {
...common,
key: "salesforge-email-sent-instant",
name: "Email Sent (Instant)",

Check warning on line 6 in components/salesforge/sources/email-sent-instant/email-sent-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when an email is sent in Salesforge. [See the documentation](https://help.salesforge.ai/en/articles/8680365-how-to-use-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEventType() {
return "email_sent";
},
getSummary({ sequenceEmail }) {
return `Email sent: "${sequenceEmail?.subject}"`;
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import common from "../common/webhook.mjs";

export default {
...common,
key: "salesforge-link-clicked-instant",
name: "Link Clicked (Instant)",

Check warning on line 6 in components/salesforge/sources/link-clicked-instant/link-clicked-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a link is clicked in Salesforge. [See the documentation](https://help.salesforge.ai/en/articles/8680365-how-to-use-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEventType() {
return "link_clicked";
},
getSummary({
sequenceEmail, linkUrl,
}) {
return `Link clicked: ${linkUrl} in "${sequenceEmail?.subject}"`;
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import common from "../common/webhook.mjs";

export default {
...common,
key: "salesforge-negative-reply-instant",
name: "Negative Reply Received (Instant)",

Check warning on line 6 in components/salesforge/sources/negative-reply-instant/negative-reply-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a negative reply is received in Salesforge. [See the documentation](https://help.salesforge.ai/en/articles/8680365-how-to-use-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEventType() {
return "negative_reply";
},
getSummary({ contact }) {
return `Negative reply received from ${contact?.email || "unknown contact"}`;
},
},
};
Loading
Loading