Skip to content
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

Hubspot - Create Communication (create a WhatsApp, LinkedIn, or SMS message) #12899

Merged
merged 3 commits into from
Jul 19, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import hubspot from "../../hubspot.app.mjs";

export default {
props: {
hubspot: {
...hubspot,
reloadProps: true,
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import common from "../common/common-create.mjs";
import appProp from "./common-app-prop.mjs";
import { ConfigurationError } from "@pipedream/platform";
import { ASSOCIATION_CATEGORY } from "../../common/constants.mjs";

export default {
...common,
key: "hubspot-create-communication",
name: "Create Communication",
description: "Create a WhatsApp, LinkedIn, or SMS message. [See the documentation](https://developers.hubspot.com/beta-docs/reference/api/crm/engagements/communications/v3#post-%2Fcrm%2Fv3%2Fobjects%2Fcommunications)",
version: "0.0.1",
type: "action",
props: {
...appProp.props,
toObjectType: {
propDefinition: [
appProp.props.hubspot,
"objectType",
],
label: "Associated Object Type",
description: "Type of object the communication is being associated with",
optional: true,
},
toObjectId: {
propDefinition: [
appProp.props.hubspot,
"objectId",
(c) => ({
objectType: c.toObjectType,
}),
],
label: "Associated Object",
description: "ID of object the communication is being associated with",
optional: true,
},
associationType: {
propDefinition: [
appProp.props.hubspot,
"associationType",
(c) => ({
fromObjectType: "communications",
toObjectType: c.toObjectType,
}),
],
description: "A unique identifier to indicate the association type between the communication and the other object",
optional: true,
},
},
methods: {
...common.methods,
getObjectType() {
return "communications";
},
},
async run({ $ }) {
const {
hubspot,
/* eslint-disable no-unused-vars */
toObjectType,
toObjectId,
associationType,
getObjectType,
...properties
} = this;

if ((toObjectId && !associationType) || (!toObjectId && associationType)) {
throw new ConfigurationError("Both `toObjectId` and `associationType` must be entered");
}

const response = await hubspot.createObject({
$,
objectType: getObjectType(),
data: {
associations: toObjectId
? [
{
types: [
{
associationTypeId: associationType,
associationCategory: ASSOCIATION_CATEGORY.HUBSPOT_DEFINED,
},
],
to: {
id: toObjectId,
},
},
]
: undefined,
properties: {
...properties,
hs_communication_logged_from: "CRM",
},
},
});

$.export("$summary", `Successfully created communication with ID ${response.id}`);
return response;
},
};
4 changes: 2 additions & 2 deletions components/hubspot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/hubspot",
"version": "0.8.5",
"version": "0.9.0",
"description": "Pipedream Hubspot Components",
"main": "hubspot.app.mjs",
"keywords": [
Expand All @@ -10,7 +10,7 @@
"homepage": "https://pipedream.com/apps/hubspot",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"dependencies": {
"@pipedream/platform": "^1.6.0",
"@pipedream/platform": "^3.0.0",
"bottleneck": "^2.19.5"
},
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading