Skip to content
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
72 changes: 72 additions & 0 deletions components/topmessage/actions/send-message/send-message.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import app from "../../topmessage.app.mjs";

export default {
key: "topmessage-send-message",
name: "Send Message",
description: "Send messages via Whatsapp or SMS. [See the documentation](https://topmessage.com/documentation-api/send-message)",
version: "0.0.1",
type: "action",
props: {
app,
from: {
propDefinition: [
app,
"from",
],
},
to: {
propDefinition: [
app,
"to",
],
},
text: {
propDefinition: [
app,
"text",
],
},
shortenURLs: {
propDefinition: [
app,
"shortenURLs",
],
},
templateId: {
propDefinition: [
app,
"templateId",
],
},
channel: {
propDefinition: [
app,
"channel",
],
},
schedule: {
propDefinition: [
app,
"schedule",
],
},
},
async run({ $ }) {
const response = await this.app.sendMessage({
$,
data: {
data: {
from: this.from,
to: this.to,
text: this.text,
shorten_URLs: this.shortenURLs,
template_id: this.templateId,
channel: this.channel,
schedule: this.schedule,
},
},
});
$.export("$summary", "Successfully sent the message request");
return response;
},
};
6 changes: 6 additions & 0 deletions components/topmessage/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
CHANNEL_OPTIONS: [
"SMS",
"WHATSAPP",
],
};
7 changes: 5 additions & 2 deletions components/topmessage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/topmessage",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream TopMessage Components",
"main": "topmessage.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
77 changes: 72 additions & 5 deletions components/topmessage/topmessage.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,78 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "topmessage",
propDefinitions: {},
propDefinitions: {
from: {
type: "string",
label: "From",
description: "The name your message will appear to be sent from. You can customize it with your company name (up to 11 characters) or use a virtual number",
},
to: {
type: "string[]",
label: "To",
description: "The recipient's mobile phone number(s) in international format",
},
text: {
type: "string",
label: "Text",
description: "Your message text to be sent to the recipient(s)",
},
shortenURLs: {
type: "boolean",
label: "Shorten URLs",
description: "Indicates whether HTTPS URLs in the text should be replaced with shortened URLs",
optional: true,
},
templateId: {
type: "string",
label: "Template ID",
description: "Unique identifier of your sent template. You can check the available templates or create a new one from your account in the templates page",
optional: true,
},
channel: {
type: "string",
label: "Channel",
description: "The communication channel your message will be sent through",
options: constants.CHANNEL_OPTIONS,
optional: true,
},
schedule: {
type: "string",
label: "Schedule",
description: "Specifies the time when the message should be sent, i.e.: `2024-12-01T18:00:00Z`. The scheduled time cannot be set for more than 1 year in the future",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.topmessage.com/v1";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
"x-topmessage-key": `${this.$auth.api_key}`,
...headers,
},
});
},

async sendMessage(args = {}) {
return this._makeRequest({
path: "/messages",
method: "POST",
...args,
});
},
},
};
};
12 changes: 7 additions & 5 deletions pnpm-lock.yaml

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

Loading