-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
GTFalcao
wants to merge
5
commits into
master
Choose a base branch
from
17392-salesforge-new-components
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Salesforge new components #17525
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
components/salesforge/actions/create-contact/create-contact.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}, | ||
}; |
20 changes: 20 additions & 0 deletions
20
components/salesforge/sources/contact-unsubscribed-instant/contact-unsubscribed-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
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"}`; | ||
}, | ||
}, | ||
}; |
20 changes: 20 additions & 0 deletions
20
components/salesforge/sources/email-bounced-instant/email-bounced-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
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"}`; | ||
}, | ||
}, | ||
}; |
20 changes: 20 additions & 0 deletions
20
components/salesforge/sources/email-opened-instant/email-opened-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
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}"`; | ||
}, | ||
}, | ||
}; |
20 changes: 20 additions & 0 deletions
20
components/salesforge/sources/email-replied-instant/email-replied-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
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}"`; | ||
}, | ||
}, | ||
}; |
20 changes: 20 additions & 0 deletions
20
components/salesforge/sources/email-sent-instant/email-sent-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
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}"`; | ||
}, | ||
}, | ||
}; |
22 changes: 22 additions & 0 deletions
22
components/salesforge/sources/link-clicked-instant/link-clicked-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
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}"`; | ||
}, | ||
}, | ||
}; |
20 changes: 20 additions & 0 deletions
20
components/salesforge/sources/negative-reply-instant/negative-reply-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)", | ||
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"}`; | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.