Skip to content

Commit c89a0ed

Browse files
authored
Hubspot - Create Communication (create a WhatsApp, LinkedIn, or SMS message) (#12899)
* new action create-communication * pnpm-lock.yaml * add id to summary
1 parent 89d887c commit c89a0ed

File tree

4 files changed

+113
-4
lines changed

4 files changed

+113
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import hubspot from "../../hubspot.app.mjs";
2+
3+
export default {
4+
props: {
5+
hubspot: {
6+
...hubspot,
7+
reloadProps: true,
8+
},
9+
},
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import common from "../common/common-create.mjs";
2+
import appProp from "./common-app-prop.mjs";
3+
import { ConfigurationError } from "@pipedream/platform";
4+
import { ASSOCIATION_CATEGORY } from "../../common/constants.mjs";
5+
6+
export default {
7+
...common,
8+
key: "hubspot-create-communication",
9+
name: "Create Communication",
10+
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)",
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
...appProp.props,
15+
toObjectType: {
16+
propDefinition: [
17+
appProp.props.hubspot,
18+
"objectType",
19+
],
20+
label: "Associated Object Type",
21+
description: "Type of object the communication is being associated with",
22+
optional: true,
23+
},
24+
toObjectId: {
25+
propDefinition: [
26+
appProp.props.hubspot,
27+
"objectId",
28+
(c) => ({
29+
objectType: c.toObjectType,
30+
}),
31+
],
32+
label: "Associated Object",
33+
description: "ID of object the communication is being associated with",
34+
optional: true,
35+
},
36+
associationType: {
37+
propDefinition: [
38+
appProp.props.hubspot,
39+
"associationType",
40+
(c) => ({
41+
fromObjectType: "communications",
42+
toObjectType: c.toObjectType,
43+
}),
44+
],
45+
description: "A unique identifier to indicate the association type between the communication and the other object",
46+
optional: true,
47+
},
48+
},
49+
methods: {
50+
...common.methods,
51+
getObjectType() {
52+
return "communications";
53+
},
54+
},
55+
async run({ $ }) {
56+
const {
57+
hubspot,
58+
/* eslint-disable no-unused-vars */
59+
toObjectType,
60+
toObjectId,
61+
associationType,
62+
getObjectType,
63+
...properties
64+
} = this;
65+
66+
if ((toObjectId && !associationType) || (!toObjectId && associationType)) {
67+
throw new ConfigurationError("Both `toObjectId` and `associationType` must be entered");
68+
}
69+
70+
const response = await hubspot.createObject({
71+
$,
72+
objectType: getObjectType(),
73+
data: {
74+
associations: toObjectId
75+
? [
76+
{
77+
types: [
78+
{
79+
associationTypeId: associationType,
80+
associationCategory: ASSOCIATION_CATEGORY.HUBSPOT_DEFINED,
81+
},
82+
],
83+
to: {
84+
id: toObjectId,
85+
},
86+
},
87+
]
88+
: undefined,
89+
properties: {
90+
...properties,
91+
hs_communication_logged_from: "CRM",
92+
},
93+
},
94+
});
95+
96+
$.export("$summary", `Successfully created communication with ID ${response.id}`);
97+
return response;
98+
},
99+
};

components/hubspot/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/hubspot",
3-
"version": "0.8.5",
3+
"version": "0.9.0",
44
"description": "Pipedream Hubspot Components",
55
"main": "hubspot.app.mjs",
66
"keywords": [
@@ -10,7 +10,7 @@
1010
"homepage": "https://pipedream.com/apps/hubspot",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^1.6.0",
13+
"@pipedream/platform": "^3.0.0",
1414
"bottleneck": "^2.19.5"
1515
},
1616
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",

pnpm-lock.yaml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)