Skip to content

Commit e878c02

Browse files
Merging pull request #18214
* Added actions * updates * pnpm-lock.yaml --------- Co-authored-by: Michelle Bergeron <[email protected]>
1 parent 4acb5e2 commit e878c02

File tree

5 files changed

+160
-8
lines changed

5 files changed

+160
-8
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import app from "../../topmessage.app.mjs";
2+
3+
export default {
4+
key: "topmessage-send-message",
5+
name: "Send Message",
6+
description: "Send messages via Whatsapp or SMS. [See the documentation](https://topmessage.com/documentation-api/send-message)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
from: {
12+
propDefinition: [
13+
app,
14+
"from",
15+
],
16+
},
17+
to: {
18+
propDefinition: [
19+
app,
20+
"to",
21+
],
22+
},
23+
text: {
24+
propDefinition: [
25+
app,
26+
"text",
27+
],
28+
},
29+
shortenURLs: {
30+
propDefinition: [
31+
app,
32+
"shortenURLs",
33+
],
34+
},
35+
templateId: {
36+
propDefinition: [
37+
app,
38+
"templateId",
39+
],
40+
},
41+
channel: {
42+
propDefinition: [
43+
app,
44+
"channel",
45+
],
46+
},
47+
schedule: {
48+
propDefinition: [
49+
app,
50+
"schedule",
51+
],
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = await this.app.sendMessage({
56+
$,
57+
data: {
58+
data: {
59+
from: this.from,
60+
to: this.to,
61+
text: this.text,
62+
shorten_URLs: this.shortenURLs,
63+
template_id: this.templateId,
64+
channel: this.channel,
65+
schedule: this.schedule,
66+
},
67+
},
68+
});
69+
$.export("$summary", "Successfully sent the message request");
70+
return response;
71+
},
72+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
CHANNEL_OPTIONS: [
3+
"SMS",
4+
"WHATSAPP",
5+
],
6+
};

components/topmessage/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/topmessage",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream TopMessage Components",
55
"main": "topmessage.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.1.0"
1417
}
15-
}
18+
}
Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,78 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "topmessage",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
from: {
9+
type: "string",
10+
label: "From",
11+
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",
12+
},
13+
to: {
14+
type: "string[]",
15+
label: "To",
16+
description: "The recipient's mobile phone number(s) in international format",
17+
},
18+
text: {
19+
type: "string",
20+
label: "Text",
21+
description: "Your message text to be sent to the recipient(s)",
22+
},
23+
shortenURLs: {
24+
type: "boolean",
25+
label: "Shorten URLs",
26+
description: "Indicates whether HTTPS URLs in the text should be replaced with shortened URLs",
27+
optional: true,
28+
},
29+
templateId: {
30+
type: "string",
31+
label: "Template ID",
32+
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",
33+
optional: true,
34+
},
35+
channel: {
36+
type: "string",
37+
label: "Channel",
38+
description: "The communication channel your message will be sent through",
39+
options: constants.CHANNEL_OPTIONS,
40+
optional: true,
41+
},
42+
schedule: {
43+
type: "string",
44+
label: "Schedule",
45+
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",
46+
optional: true,
47+
},
48+
},
549
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
50+
_baseUrl() {
51+
return "https://api.topmessage.com/v1";
52+
},
53+
async _makeRequest(opts = {}) {
54+
const {
55+
$ = this,
56+
path,
57+
headers,
58+
...otherOpts
59+
} = opts;
60+
return axios($, {
61+
...otherOpts,
62+
url: this._baseUrl() + path,
63+
headers: {
64+
"x-topmessage-key": `${this.$auth.api_key}`,
65+
...headers,
66+
},
67+
});
68+
},
69+
70+
async sendMessage(args = {}) {
71+
return this._makeRequest({
72+
path: "/messages",
73+
method: "POST",
74+
...args,
75+
});
976
},
1077
},
11-
};
78+
};

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)