Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
export default {
key: "hubspot-batch-upsert-companies",
name: "Batch Upsert Companies",
description:
"Upsert a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupsert)",
version: "0.0.6",
description: "Upsert a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupsert)",
version: "0.0.5",
type: "action",
props: {
hubspot,
infoAlert: {

Check warning on line 14 in components/hubspot/actions/batch-upsert-companies/batch-upsert-companies.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop infoAlert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 14 in components/hubspot/actions/batch-upsert-companies/batch-upsert-companies.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop infoAlert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content:
Expand Down
43 changes: 43 additions & 0 deletions components/hubspot/actions/create-workflow/create-workflow.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { parseObject } from "../../common/utils.mjs";
import hubspot from "../../hubspot.app.mjs";

export default {
key: "hubspot-create-workflow",
name: "Create a New Workflow",
description: "Create a new workflow. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/post-automation-v3-workflows)",
version: "0.0.1",
type: "action",
props: {
hubspot,
name: {
type: "string",
label: "Workflow Name",
description: "The name of the workflow to create",
},
type: {
propDefinition: [
hubspot,
"type",
],
},
actions: {
propDefinition: [
hubspot,
"actions",
],
},
},
async run({ $ }) {
const response = await this.hubspot.createWorkflow({
data: {
name: this.name,
type: this.type,
actions: parseObject(this.actions),
},
$,
});

$.export("$summary", `Successfully created workflow: ${this.name}`);
return response;
},
};
28 changes: 28 additions & 0 deletions components/hubspot/actions/delete-workflow/delete-workflow.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import hubspot from "../../hubspot.app.mjs";

export default {
key: "hubspot-delete-workflow",
name: "Delete a Workflow",
description: "Delete a workflow by ID. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/delete-automation-v3-workflows-workflowId)",
version: "0.0.1",
type: "action",
props: {
hubspot,
workflowId: {
propDefinition: [
hubspot,
"workflow",
],
description: "The ID of the workflow to delete",
},
},
async run({ $ }) {
const response = await this.hubspot.deleteWorkflow({
workflowId: this.workflowId,
$,
});

$.export("$summary", `Successfully deleted workflow ${this.workflowId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { parseObject } from "../../common/utils.mjs";
import hubspot from "../../hubspot.app.mjs";

export default {
key: "hubspot-retrieve-migrated-workflow-mappings",
name: "Retrieve Migrated Workflow Mappings",
description: "Retrieve the IDs of v3 workflows that have been migrated to the v4 API. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/workflow-id-mappings/post-automation-v4-workflow-id-mappings-batch-read)",
version: "0.0.1",
type: "action",
props: {
hubspot,
flowIds: {
propDefinition: [
hubspot,
"workflow",
() => ({
version: "V4",
}),
],
type: "string[]",
label: "Flow IDs",
description: "A list of flowIds from the V4 API.",
optional: true,
},
workflow: {
propDefinition: [
hubspot,
"workflow",
() => ({
version: "V3",
}),
],
type: "string[]",
label: "Workflow IDs",
description: "A list of workflowIds from the V3 API.",
optional: true,
},
},
async run({ $ }) {
const parsedFlowIds = parseObject(this.flowIds) || [];
const parsedWorkflowIds = parseObject(this.workflowIds) || [];

const flowIds = [];
const workflowIds = [];

for (const flowId of parsedFlowIds) {
flowIds.push({
flowMigrationStatuses: `${flowId}`,
type: "FLOW_ID",
});
}
for (const workflowId of parsedWorkflowIds) {
workflowIds.push({
flowMigrationStatusForClassicWorkflows: `${workflowId}`,
type: "WORKFLOW_ID",
});
}

const response = await this.hubspot.getMigratedWorkflowMappings({
$,
data: {
inputs: [
...flowIds,
...workflowIds,
],
},
});

$.export("$summary", `Successfully retrieved ${response.results.length} migrated result(s) with ${response.errors?.length || 0} error(s)`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import hubspot from "../../hubspot.app.mjs";

export default {
key: "hubspot-retrieve-workflow-details",
name: "Retrieve Workflow Details",
description: "Retrieve detailed information about a specific workflow. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/get-automation-v3-workflows-workflowId)",
version: "0.0.1",
type: "action",
props: {
hubspot,
workflowId: {
propDefinition: [
hubspot,
"workflow",
],
label: "Workflow ID",
description: "The ID of the workflow you wish to see details for.",
},
},
async run({ $ }) {
const response = await this.hubspot.getWorkflowDetails({
workflowId: this.workflowId,
$,
});

$.export("$summary", `Successfully retrieved details for workflow ${this.workflowId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import hubspot from "../../hubspot.app.mjs";

export default {
key: "hubspot-retrieve-workflow-emails",
name: "Retrieve Workflow Emails",
description: "Retrieve emails sent by a workflow by ID. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/email-campaigns/get-automation-v4-flows-email-campaigns)",
version: "0.0.1",
type: "action",
props: {
hubspot,
workflowId: {
propDefinition: [
hubspot,
"workflow",
],
},
after: {
type: "string",
label: "After",
description: "The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results.",
optional: true,
},
before: {
type: "string",
label: "Before",
description: "The paging cursor token of the last successfully read resource will be returned as the `paging.next.before` JSON property of a paged response containing more results.",
optional: true,
},
limit: {
type: "integer",
label: "Limit",
description: "The maximum number of results to display per page.",
default: 100,
optional: true,
},
},
async run({ $ }) {
const response = await this.hubspot.getWorkflowEmails({
$,
params: {
flowId: this.workflowId,
after: this.after,
before: this.before,
limit: this.limit,
},
});

$.export("$summary", `Successfully retrieved ${response.results.length} emails for workflow ${this.workflowId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import hubspot from "../../hubspot.app.mjs";

export default {
key: "hubspot-retrieve-workflows",
name: "Retrieve Workflows",
description: "Retrieve a list of all workflows. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/get-automation-v3-workflows)",
version: "0.0.1",
type: "action",
props: {
hubspot,
},
async run({ $ }) {
const response = await this.hubspot.listWorkflows({
$,
});

$.export("$summary", `Successfully retrieved ${response.results.length} workflows`);
return response;
},
};
1 change: 1 addition & 0 deletions components/hubspot/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const API_PATH = {
CRMV4: "/crm/v4",
CMS: "/cms/v3",
AUTOMATION: "/automation/v2",
AUTOMATIONV3: "/automation/v3",
AUTOMATIONV4: "/automation/v4",
DEAL: "/deals/v1",
BUSINESS_UNITS: "/business-units/v3",
Expand Down
70 changes: 69 additions & 1 deletion components/hubspot/hubspot.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export default {
description: "The ID of the workflow you wish to see metadata for.",
async options() {
const { workflows } = await this.listWorkflows();

return {
options: workflows.map(({
name: label, id: value,
Expand Down Expand Up @@ -676,6 +677,31 @@ export default {
};
},
},
type: {
type: "string",
label: "Type",
description: "The type of workflow to create",
options: [
{
label: "Drip Delay",
value: "DRIP_DELAY",
},
{
label: "Static Anchor",
value: "STATIC_ANCHOR",
},
{
label: "Property Anchor",
value: "PROPERTY_ANCHOR",
},
],
},
actions: {
type: "string[]",
label: "Actions",
description: "A list of objects representing the workflow actions. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/guide#action-types) for more information.",
optional: true,
},
},
methods: {
_getHeaders() {
Expand Down Expand Up @@ -1208,7 +1234,7 @@ export default {
},
listWorkflows(opts = {}) {
return this.makeRequest({
api: API_PATH.AUTOMATION,
api: API_PATH["AUTOMATIONV3"],
endpoint: "/workflows",
...opts,
});
Expand All @@ -1223,6 +1249,48 @@ export default {
...opts,
});
},
getWorkflowEmails(opts = {}) {
return this.makeRequest({
api: API_PATH.AUTOMATIONV4,
endpoint: "/flows/email-campaigns",
...opts,
});
},
getWorkflowDetails({
workflowId, ...opts
}) {
return this.makeRequest({
api: API_PATH.AUTOMATIONV3,
endpoint: `/workflows/${workflowId}`,
...opts,
});
},
createWorkflow(opts = {}) {
return this.makeRequest({
method: "POST",
api: API_PATH.AUTOMATIONV3,
endpoint: "/workflows",
...opts,
});
},
deleteWorkflow({
workflowId, ...opts
}) {
return this.makeRequest({
method: "DELETE",
api: API_PATH.AUTOMATIONV3,
endpoint: `/workflows/${workflowId}`,
...opts,
});
},
getMigratedWorkflowMappings(opts = {}) {
return this.makeRequest({
api: API_PATH.AUTOMATIONV4,
endpoint: "/workflow-id-mappings/batch/read",
method: "POST",
...opts,
});
},
batchCreateContacts(opts = {}) {
return this.makeRequest({
api: API_PATH.CRMV3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export default {
...common,
key: "hubspot-new-company-property-change",
name: "New Company Property Change",
description:
"Emit new event when a specified property is provided or updated on a company. [See the documentation](https://developers.hubspot.com/docs/api/crm/companies)",
description: "Emit new event when a specified property is provided or updated on a company. [See the documentation](https://developers.hubspot.com/docs/api/crm/companies)",
version: "0.0.22",
dedupe: "unique",
type: "source",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export default {
...common,
key: "hubspot-new-contact-property-change",
name: "New Contact Property Change",
description:
"Emit new event when a specified property is provided or updated on a contact. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts)",
description: "Emit new event when a specified property is provided or updated on a contact. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts)",
version: "0.0.24",
dedupe: "unique",
type: "source",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export default {
...common,
key: "hubspot-new-deal-property-change",
name: "New Deal Property Change",
description:
"Emit new event when a specified property is provided or updated on a deal. [See the documentation](https://developers.hubspot.com/docs/api/crm/deals)",
description: "Emit new event when a specified property is provided or updated on a deal. [See the documentation](https://developers.hubspot.com/docs/api/crm/deals)",
version: "0.0.23",
dedupe: "unique",
type: "source",
Expand Down
Loading
Loading