Skip to content

Commit be053e8

Browse files
authored
New Components - pidj (#11962)
* pidj init * [Components] pidj #11935 Ations - Create Contact - Send Message - Initiate Survey * pnpm update * some adjusts * pnpm update
1 parent 0704cf5 commit be053e8

File tree

7 files changed

+999
-7
lines changed

7 files changed

+999
-7
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
import { TIMEZONE_OPTIONS } from "../../common/constants.mjs";
2+
import pidj from "../../pidj.app.mjs";
3+
4+
export default {
5+
key: "pidj-create-contact",
6+
name: "Create Contact",
7+
description: "Initiates a process to add a new contact to your Pidj account. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
pidj,
12+
phoneNumber: {
13+
type: "string",
14+
label: "Phone Number",
15+
description: "Phone number for the contact. This must be in E.164 format. **e.g., +18885552222**",
16+
},
17+
emailAddress: {
18+
type: "string",
19+
label: "Email Address",
20+
description: "The contact's email address.",
21+
optional: true,
22+
},
23+
firstName: {
24+
type: "string",
25+
label: "First Name",
26+
description: "The contact's first name.",
27+
optional: true,
28+
},
29+
lastName: {
30+
type: "string",
31+
label: "Last Name",
32+
description: "The contact's last name.",
33+
optional: true,
34+
},
35+
businessName: {
36+
type: "string",
37+
label: "Business Name",
38+
description: "The contact's business name.",
39+
optional: true,
40+
},
41+
displayName: {
42+
type: "string",
43+
label: "Display Name",
44+
description: "The contact's display name, if present, and different from first and last name.",
45+
optional: true,
46+
},
47+
groupId: {
48+
propDefinition: [
49+
pidj,
50+
"groupId",
51+
],
52+
optional: true,
53+
},
54+
timezone: {
55+
type: "string",
56+
label: "Timezone",
57+
description: "Timezone identifier for the contact. If omitted, this will default to the account value.",
58+
options: TIMEZONE_OPTIONS,
59+
optional: true,
60+
},
61+
externalId: {
62+
type: "string",
63+
label: "External Id",
64+
description: "The external ID of the contact from your own system. This may be used in any enabled integrations to cross-identify the contact record.",
65+
optional: true,
66+
},
67+
homeAddressStreet1: {
68+
type: "string",
69+
label: "Home Street 1",
70+
description: "The home street address 1.",
71+
optional: true,
72+
},
73+
homeAddressStreet2: {
74+
type: "string",
75+
label: "Home Street 2",
76+
description: "The home street address 2.",
77+
optional: true,
78+
},
79+
homeAddressCity: {
80+
type: "string",
81+
label: "Home City",
82+
description: "The home city address.",
83+
optional: true,
84+
},
85+
homeAddressState: {
86+
type: "string",
87+
label: "Home State",
88+
description: "The home state address. Must be the standard 2 character abbreviation (**ANSI2-letter** or **USPS**). Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations).",
89+
optional: true,
90+
},
91+
homeAddressPostal: {
92+
type: "string",
93+
label: "Home Postal",
94+
description: "Valid 5 or 10 digit zipcode (US addresses). British, Canadian, and Australian postal codes also supported.",
95+
optional: true,
96+
},
97+
homeAddressCountry: {
98+
type: "string",
99+
label: "Home Country",
100+
description: "Must be either **ISO 3166-1 alpha-2** or **ISO 3166-1 alpha-3**. Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/ISO_3166-1).",
101+
optional: true,
102+
},
103+
businessAddressStreet1: {
104+
type: "string",
105+
label: "Business Street 1",
106+
description: "The business street address 1.",
107+
optional: true,
108+
},
109+
businessAddressStreet2: {
110+
type: "string",
111+
label: "Business Street 2",
112+
description: "The business street address 2.",
113+
optional: true,
114+
},
115+
businessAddressCity: {
116+
type: "string",
117+
label: "Business City",
118+
description: "The business city address.",
119+
optional: true,
120+
},
121+
businessAddressState: {
122+
type: "string",
123+
label: "Business State",
124+
description: "The business state address. Must be the standard 2 character abbreviation (**ANSI2-letter** or **USPS**). Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations).",
125+
optional: true,
126+
},
127+
businessAddressPostal: {
128+
type: "string",
129+
label: "Business Postal",
130+
description: "Valid 5 or 10 digit zipcode (US addresses). British, Canadian, and Australian postal codes also supported.",
131+
optional: true,
132+
},
133+
businessAddressCountry: {
134+
type: "string",
135+
label: "Business Country",
136+
description: "Must be either **ISO 3166-1 alpha-2** or **ISO 3166-1 alpha-3**. Any other values will be discarded. [See further information](https://en.wikipedia.org/wiki/ISO_3166-1).",
137+
optional: true,
138+
},
139+
},
140+
async run({ $ }) {
141+
const response = await this.pidj.addContact({
142+
$,
143+
data: {
144+
phone_number: this.phoneNumber,
145+
email_address: this.emailAddress,
146+
first_name: this.firstName,
147+
last_name: this.lastName,
148+
business_name: this.businessName,
149+
display_name: this.displayName,
150+
group: this.groupId,
151+
timezone: this.timezone,
152+
external_id: this.externalId,
153+
addresses: {
154+
home_street_1: this.homeAddressStreet1,
155+
home_street_2: this.homeAddressStreet2,
156+
home_city: this.homeAddressCity,
157+
home_state: this.homeAddressState,
158+
home_postal: this.homeAddressPostal,
159+
home_country: this.homeAddressCountry,
160+
business_street_1: this.businessAddressStreet1,
161+
business_street_2: this.businessAddressStreet2,
162+
business_city: this.businessAddressCity,
163+
business_state: this.businessAddressState,
164+
business_postal: this.businessAddressPostal,
165+
business_country: this.businessAddressCountry,
166+
},
167+
},
168+
});
169+
$.export("$summary", `Successfully added a new contact with Id: ${response.id}`);
170+
return response;
171+
},
172+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import pidj from "../../pidj.app.mjs";
3+
4+
export default {
5+
key: "pidj-initiate-survey",
6+
name: "Initiate Survey",
7+
description: "Triggers a pre-configured text survey to a specific contact. Requires the contact's information and the survey ID. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
pidj,
12+
surveyId: {
13+
propDefinition: [
14+
pidj,
15+
"surveyId",
16+
],
17+
},
18+
contactId: {
19+
propDefinition: [
20+
pidj,
21+
"contactId",
22+
],
23+
},
24+
fromNumber: {
25+
propDefinition: [
26+
pidj,
27+
"fromNumber",
28+
],
29+
optional: true,
30+
},
31+
groupId: {
32+
propDefinition: [
33+
pidj,
34+
"groupId",
35+
],
36+
optional: true,
37+
},
38+
},
39+
async run({ $ }) {
40+
if ((!this.fromNumber && !this.groupId) || (this.fromNumber && this.groupId)) {
41+
throw new ConfigurationError("You must provide either From Number or Group Id.");
42+
}
43+
44+
const response = await this.pidj.triggerSurvey({
45+
$,
46+
data: {
47+
survey_id: this.surveyId,
48+
contact_id: this.contactId,
49+
from_number: this.fromNumber,
50+
group_id: this.groupId,
51+
},
52+
});
53+
54+
$.export("$summary", `Successfully initiated survey for contact ${this.contactId}`);
55+
return response;
56+
},
57+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import pidj from "../../pidj.app.mjs";
3+
4+
export default {
5+
key: "pidj-send-message",
6+
name: "Send Message",
7+
description: "Sends a text message to a specified phone number from your pidj account. [See the documentation](https://pidj.co/wp-content/uploads/2023/06/Pidj-API-Technical-Document-v3-1.pdf).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
pidj,
12+
groupId: {
13+
propDefinition: [
14+
pidj,
15+
"groupId",
16+
],
17+
},
18+
toNumber: {
19+
propDefinition: [
20+
pidj,
21+
"toNumber",
22+
],
23+
},
24+
textBody: {
25+
type: "string",
26+
label: "Text Body",
27+
description: "The text to send. Message lengths greater than 1,600 characters will be truncated. Messages with emoji and special characters may have a smaller limit due to encoding requirements. [See Pidj FAQ for details](https://pidjco.gopidj.com/faq).",
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.pidj.sendMessage({
32+
$,
33+
data: {
34+
group_id: this.groupId,
35+
to_number: this.toNumber,
36+
text_body: this.textBody,
37+
},
38+
});
39+
if (response.status != "success") throw new ConfigurationError(response.message);
40+
41+
$.export("$summary", `Message successfully sent to ${this.toNumber}`);
42+
return response;
43+
},
44+
};

0 commit comments

Comments
 (0)