Skip to content

Commit d514b8d

Browse files
luancazarinemichelle0927
authored andcommitted
New Components - smstools (#14378)
* smstools init * [Components] smstools #14370 Sources - New Inbound Message Actions - Add Contact - Add Contact Opt Out - Send SMS * pnpm update * Update components/smstools/smstools.app.mjs --------- Co-authored-by: michelle0927 <[email protected]>
1 parent 8f89ee2 commit d514b8d

File tree

8 files changed

+511
-59
lines changed

8 files changed

+511
-59
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import smstools from "../../smstools.app.mjs";
3+
4+
export default {
5+
key: "smstools-add-contact-opt-out",
6+
name: "Add Contact to Opt-Out List",
7+
description: "Adds a selected contact to the opt-out list, stopping further communications. [See the documentation](https://www.smstools.com/en/sms-gateway-api/add_optout)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
smstools,
12+
contactNumber: {
13+
propDefinition: [
14+
smstools,
15+
"contactNumber",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
try {
21+
const response = await this.smstools.addOptOut({
22+
$,
23+
data: {
24+
number: this.contactNumber,
25+
},
26+
});
27+
28+
$.export("$summary", `Successfully added contact number ${this.contactNumber} to the opt-out list.`);
29+
return response;
30+
} catch (e) {
31+
throw new ConfigurationError("The number is already opted-out or does not exist in the database.");
32+
}
33+
},
34+
};
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import smstools from "../../smstools.app.mjs";
3+
4+
export default {
5+
key: "smstools-add-contact",
6+
name: "Add Contact to Group",
7+
description: "Adds a new contact to an existing contact list. [See the documentation](https://www.smstools.com/en/sms-gateway-api/add_contact)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
smstools,
12+
phone: {
13+
type: "string",
14+
label: "Phone Number",
15+
description: "The phone number of the contact.",
16+
},
17+
groupid: {
18+
propDefinition: [
19+
smstools,
20+
"groupId",
21+
],
22+
},
23+
firstName: {
24+
type: "string",
25+
label: "First Name",
26+
description: "First name of the contact.",
27+
optional: true,
28+
},
29+
lastName: {
30+
type: "string",
31+
label: "Last Name",
32+
description: "Last name of the contact.",
33+
optional: true,
34+
},
35+
birthday: {
36+
type: "string",
37+
label: "Birthday",
38+
description: "Birthday of the contact. **Format: YYYY-MM-DD**.",
39+
optional: true,
40+
},
41+
extra1: {
42+
type: "string",
43+
label: "Extra 1",
44+
description: "Extra field 1 for the contact.",
45+
optional: true,
46+
},
47+
extra2: {
48+
type: "string",
49+
label: "Extra 2",
50+
description: "Extra field 2 for the contact.",
51+
optional: true,
52+
},
53+
extra3: {
54+
type: "string",
55+
label: "Extra 3",
56+
description: "Extra field 3 for the contact.",
57+
optional: true,
58+
},
59+
extra4: {
60+
type: "string",
61+
label: "Extra 4",
62+
description: "Extra field 4 for the contact.",
63+
optional: true,
64+
},
65+
extra5: {
66+
type: "string",
67+
label: "Extra 5",
68+
description: "Extra field 5 for the contact.",
69+
optional: true,
70+
},
71+
extra6: {
72+
type: "string",
73+
label: "Extra 6",
74+
description: "Extra field 6 for the contact.",
75+
optional: true,
76+
},
77+
extra7: {
78+
type: "string",
79+
label: "Extra 7",
80+
description: "Extra field 7 for the contact.",
81+
optional: true,
82+
},
83+
extra8: {
84+
type: "string",
85+
label: "Extra 8",
86+
description: "Extra field 8 for the contact.",
87+
optional: true,
88+
},
89+
unsubscribed: {
90+
type: "boolean",
91+
label: "Unsubscribed",
92+
description: "Indicates if the contact is unsubscribed.",
93+
optional: true,
94+
},
95+
},
96+
async run({ $ }) {
97+
try {
98+
const {
99+
smstools,
100+
...data
101+
} = this;
102+
103+
const response = await smstools.addContact({
104+
$,
105+
data,
106+
});
107+
108+
$.export("$summary", `Successfully added contact with ID: ${response.ID}`);
109+
return response;
110+
} catch (e) {
111+
throw new ConfigurationError(e.response.data.errorMsg);
112+
}
113+
},
114+
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import smstools from "../../smstools.app.mjs";
2+
3+
export default {
4+
key: "smstools-send-sms",
5+
name: "Send SMS or WhatsApp Message",
6+
description: "Sends a SMS or WhatsApp message to a specified contact. [See the documentation](https://www.smstools.com/en/sms-gateway-api/send_message)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
smstools,
11+
message: {
12+
type: "string",
13+
label: "Message",
14+
description: "The message to be sent.",
15+
},
16+
to: {
17+
propDefinition: [
18+
smstools,
19+
"contactNumber",
20+
],
21+
type: "string[]",
22+
description: "The contact(s) to send the message to.",
23+
},
24+
sender: {
25+
propDefinition: [
26+
smstools,
27+
"sender",
28+
],
29+
},
30+
date: {
31+
type: "string",
32+
label: "Scheduled Date",
33+
description: "The date to send the message. **Format: yyyy-MM-dd HH:mm**. If not provided, the message will be sent as soon as possible.",
34+
optional: true,
35+
},
36+
reference: {
37+
type: "string",
38+
label: "Reference",
39+
description: "Reference for the message.",
40+
optional: true,
41+
},
42+
test: {
43+
type: "boolean",
44+
label: "Test",
45+
description: "Test mode for the message.",
46+
optional: true,
47+
},
48+
subId: {
49+
propDefinition: [
50+
smstools,
51+
"subId",
52+
],
53+
optional: true,
54+
},
55+
},
56+
async run({ $ }) {
57+
const response = await this.smstools.sendMessage({
58+
$,
59+
data: {
60+
message: this.message,
61+
to: this.to,
62+
sender: this.sender,
63+
date: this.date,
64+
reference: this.reference,
65+
test: this.test,
66+
subId: this.subId,
67+
},
68+
});
69+
$.export("$summary", `Message sent successfully with ID: ${response.messageid}`);
70+
return response;
71+
},
72+
};

components/smstools/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/smstools",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream SMSTools Components",
55
"main": "smstools.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

0 commit comments

Comments
 (0)