From 5e8e0c8917401faeeea1b07323cd1d66b06dfb05 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Thu, 28 Aug 2025 18:10:17 -0300 Subject: [PATCH 1/3] Added actions --- .../actions/send-message/send-message.mjs | 72 +++++++++++++++++ components/topmessage/common/constants.mjs | 6 ++ components/topmessage/package.json | 4 +- components/topmessage/topmessage.app.mjs | 77 +++++++++++++++++-- pnpm-lock.yaml | 6 +- 5 files changed, 154 insertions(+), 11 deletions(-) create mode 100644 components/topmessage/actions/send-message/send-message.mjs create mode 100644 components/topmessage/common/constants.mjs diff --git a/components/topmessage/actions/send-message/send-message.mjs b/components/topmessage/actions/send-message/send-message.mjs new file mode 100644 index 0000000000000..4e19f8df06124 --- /dev/null +++ b/components/topmessage/actions/send-message/send-message.mjs @@ -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; + }, +}; diff --git a/components/topmessage/common/constants.mjs b/components/topmessage/common/constants.mjs new file mode 100644 index 0000000000000..edad139f5a7ee --- /dev/null +++ b/components/topmessage/common/constants.mjs @@ -0,0 +1,6 @@ +export default { + CHANNEL_OPTIONS: [ + "SMS", + "WHATSAPP", + ], +}; diff --git a/components/topmessage/package.json b/components/topmessage/package.json index e9de1dc808c62..eaa42b38d5468 100644 --- a/components/topmessage/package.json +++ b/components/topmessage/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/topmessage", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream TopMessage Components", "main": "topmessage.app.mjs", "keywords": [ @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/topmessage/topmessage.app.mjs b/components/topmessage/topmessage.app.mjs index 7cb5d825955b1..509f59c4f7075 100644 --- a/components/topmessage/topmessage.app.mjs +++ b/components/topmessage/topmessage.app.mjs @@ -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: "Description for shorten 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 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, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a8eb2a7dea305..c76b944c1c835 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10938,8 +10938,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/postbin: - specifiers: {} + components/postbin: {} components/postgresql: dependencies: @@ -14995,8 +14994,7 @@ importers: components/upollo: {} - components/uproc: - specifiers: {} + components/uproc: {} components/upstash_redis: dependencies: From 384a4edaa422f4390a6116c2756ded7e0475a5eb Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 28 Aug 2025 20:01:38 -0400 Subject: [PATCH 2/3] updates --- components/topmessage/package.json | 3 +++ components/topmessage/topmessage.app.mjs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/topmessage/package.json b/components/topmessage/package.json index eaa42b38d5468..f9bba0bc2ac5c 100644 --- a/components/topmessage/package.json +++ b/components/topmessage/package.json @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/components/topmessage/topmessage.app.mjs b/components/topmessage/topmessage.app.mjs index 509f59c4f7075..3b3b7c56b24b2 100644 --- a/components/topmessage/topmessage.app.mjs +++ b/components/topmessage/topmessage.app.mjs @@ -23,7 +23,7 @@ export default { shortenURLs: { type: "boolean", label: "Shorten URLs", - description: "Description for shorten URLs", + description: "Indicates whether HTTPS URLs in the text should be replaced with shortened URLs", optional: true, }, templateId: { @@ -35,7 +35,7 @@ export default { channel: { type: "string", label: "Channel", - description: "The communication channel your message sent through", + description: "The communication channel your message will be sent through", options: constants.CHANNEL_OPTIONS, optional: true, }, From 457ac7412910a85ad1d0b818e26960e7450f38da Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 28 Aug 2025 20:02:09 -0400 Subject: [PATCH 3/3] pnpm-lock.yaml --- pnpm-lock.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c76b944c1c835..a851793ef89ab 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14523,7 +14523,11 @@ importers: specifier: ^0.1.4 version: 0.1.6 - components/topmessage: {} + components/topmessage: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/totango: dependencies: