Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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,34 @@
import { ConfigurationError } from "@pipedream/platform";
import smstools from "../../smstools.app.mjs";

export default {
key: "smstools-add-contact-opt-out",
name: "Add Contact to Opt-Out List",
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)",
version: "0.0.1",
type: "action",
props: {
smstools,
contactNumber: {
propDefinition: [
smstools,
"contactNumber",
],
},
},
async run({ $ }) {
try {
const response = await this.smstools.addOptOut({
$,
data: {
number: this.contactNumber,
},
});

$.export("$summary", `Successfully added contact number ${this.contactNumber} to the opt-out list.`);
return response;
} catch (e) {
throw new ConfigurationError("The number is already opted-out or does not exist in the database.");
}
},
};
114 changes: 114 additions & 0 deletions components/smstools/actions/add-contact/add-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { ConfigurationError } from "@pipedream/platform";
import smstools from "../../smstools.app.mjs";

export default {
key: "smstools-add-contact",
name: "Add Contact to Group",
description: "Adds a new contact to an existing contact list. [See the documentation](https://www.smstools.com/en/sms-gateway-api/add_contact)",
version: "0.0.1",
type: "action",
props: {
smstools,
phone: {
type: "string",
label: "Phone Number",
description: "The phone number of the contact.",
},
groupid: {
propDefinition: [
smstools,
"groupId",
],
},
firstName: {
type: "string",
label: "First Name",
description: "First name of the contact.",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "Last name of the contact.",
optional: true,
},
birthday: {
type: "string",
label: "Birthday",
description: "Birthday of the contact. **Format: YYYY-MM-DD**.",
optional: true,
},
extra1: {
type: "string",
label: "Extra 1",
description: "Extra field 1 for the contact.",
optional: true,
},
extra2: {
type: "string",
label: "Extra 2",
description: "Extra field 2 for the contact.",
optional: true,
},
extra3: {
type: "string",
label: "Extra 3",
description: "Extra field 3 for the contact.",
optional: true,
},
extra4: {
type: "string",
label: "Extra 4",
description: "Extra field 4 for the contact.",
optional: true,
},
extra5: {
type: "string",
label: "Extra 5",
description: "Extra field 5 for the contact.",
optional: true,
},
extra6: {
type: "string",
label: "Extra 6",
description: "Extra field 6 for the contact.",
optional: true,
},
extra7: {
type: "string",
label: "Extra 7",
description: "Extra field 7 for the contact.",
optional: true,
},
extra8: {
type: "string",
label: "Extra 8",
description: "Extra field 8 for the contact.",
optional: true,
},
unsubscribed: {
type: "boolean",
label: "Unsubscribed",
description: "Indicates if the contact is unsubscribed.",
optional: true,
},
},
async run({ $ }) {
try {
const {
smstools,
...data
} = this;

const response = await smstools.addContact({
$,
data,
});

$.export("$summary", `Successfully added contact with ID: ${response.ID}`);
return response;
} catch (e) {
throw new ConfigurationError(e.response.data.errorMsg);
}
},
};
72 changes: 72 additions & 0 deletions components/smstools/actions/send-sms/send-sms.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import smstools from "../../smstools.app.mjs";

export default {
key: "smstools-send-sms",
name: "Send SMS or WhatsApp Message",
description: "Sends a SMS or WhatsApp message to a specified contact. [See the documentation](https://www.smstools.com/en/sms-gateway-api/send_message)",
version: "0.0.1",
type: "action",
props: {
smstools,
message: {
type: "string",
label: "Message",
description: "The message to be sent.",
},
to: {
propDefinition: [
smstools,
"contactNumber",
],
type: "string[]",
description: "The contact(s) to send the message to.",
},
sender: {
propDefinition: [
smstools,
"sender",
],
},
date: {
type: "string",
label: "Scheduled Date",
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.",
optional: true,
},
reference: {
type: "string",
label: "Reference",
description: "Reference for the message.",
optional: true,
},
test: {
type: "boolean",
label: "Test",
description: "Test mode for the message.",
optional: true,
},
subId: {
propDefinition: [
smstools,
"subId",
],
optional: true,
},
},
async run({ $ }) {
const response = await this.smstools.sendMessage({
$,
data: {
message: this.message,
to: this.to,
sender: this.sender,
date: this.date,
reference: this.reference,
test: this.test,
subId: this.subId,
},
});
$.export("$summary", `Message sent successfully with ID: ${response.messageid}`);
return response;
},
};
7 changes: 5 additions & 2 deletions components/smstools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/smstools",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream SMSTools Components",
"main": "smstools.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
Loading
Loading