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
2 changes: 1 addition & 1 deletion components/ringg_ai/ringg_ai.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/rumi_ai/rumi_ai.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { ConfigurationError } from "@pipedream/platform";
import fs from "fs";
import { checkTmp } from "../../common/utils.mjs";
import syncmateByAssitro from "../../syncmate_by_assitro.app.mjs";

export default {
key: "syncmate_by_assitro-send-bulk-messages",
name: "Send Bulk Messages",
description: "Send multiple WhatsApp messages in bulk. [See the documentation](https://assistro.co/user-guide/bulk-messaging-at-a-scheduled-time-using-syncmate-2/)",
version: "0.0.1",
type: "action",
props: {
syncmateByAssitro,
messagesNumber: {
type: "integer",
label: "Messages Number",
description: "The quantity of messages you want to send.",
reloadProps: true,
},
},
async additionalProps() {
const props = {};
for (let i = 1; i <= this.messagesNumber; i++) {
props[`number${i}`] = {
type: "string",
label: `Number ${i}`,
description: "WhatsApp number with country code",
};
props[`message${i}`] = {
type: "string",
label: `Message ${i}`,
description: "The text message to be sent",
};
props[`media${i}`] = {
type: "string",
label: `Media ${i}`,
description: "The the path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).",
optional: true,
};
props[`fileName${i}`] = {
type: "string",
label: `File Name ${i}`,
description: "The name of the file.",
optional: true,
};
}

return props;
},
async run({ $ }) {
const msgs = [];

for (let i = 1; i <= this.messagesNumber; i++) {
if (this[`media${i}`] && !this[`fileName${i}`]) {
throw new ConfigurationError(`You must provide the File Name ${i}.`);
}
const data = {
number: this[`number${i}`],
message: this[`message${i}`],
};

if (this[`media${i}`]) {
const file = fs.readFileSync(checkTmp(this[`media${i}`]), {
encoding: "base64",
});
data.media = [
{
media_base64: file,
file_name: this[`fileName${i}`],
},
];
}

msgs.push(data);
}

const response = await this.syncmateByAssitro.sendBulkMessages({
$,
data: {
msgs,
},
});

$.export("$summary", `Successfully sent ${this.messagesNumber} messages.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { ConfigurationError } from "@pipedream/platform";
import fs from "fs";
import { checkTmp } from "../../common/utils.mjs";
import syncmateByAssitro from "../../syncmate_by_assitro.app.mjs";

export default {
key: "syncmate_by_assitro-send-message",
name: "Send WhatsApp Message",
description: "Send a single WhatsApp message using SyncMate by Assistro. [See the documentation](https://assistro.co/user-guide/connect-your-custom-app-with-syncmate/)",
version: "0.0.1",
type: "action",
props: {
syncmateByAssitro,
number: {
type: "string",
label: "Number",
description: "WhatsApp number with country code",
},
message: {
type: "string",
label: "Message",
description: "The text message to be sent",
},
media: {
type: "string",
label: "Media",
description: "The the path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).",
optional: true,
},
fileName: {
type: "string",
label: "File Name",
description: "The name of the file.",
optional: true,
},
},
async run({ $ }) {
if (this.media && !this.fileName) {
throw new ConfigurationError("You must provide the file name.");
}

const msgs = [
{
number: this.number,
message: this.message,
},
];

if (this.media) {
const file = fs.readFileSync(checkTmp(this.media), {
encoding: "base64",
});

msgs[0].media = [
{
media_base64: file,
file_name: this.fileName,
},
];
}

const response = await this.syncmateByAssitro.sendSingleMessage({
$,
data: {
msgs,
},
});

$.export("$summary", `Successfully sent message to ${this.number}`);
return response;
},
};
6 changes: 6 additions & 0 deletions components/syncmate_by_assitro/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const checkTmp = (filename) => {
if (!filename.startsWith("/tmp")) {
return `/tmp/${filename}`;
}
return filename;
};
7 changes: 5 additions & 2 deletions components/syncmate_by_assitro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/syncmate_by_assitro",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream SyncMate by Assitro Components",
"main": "syncmate_by_assitro.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"
}
}
}
39 changes: 34 additions & 5 deletions components/syncmate_by_assitro/syncmate_by_assitro.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "syncmate_by_assitro",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://app.assistro.co/api/v1/wapushplus";
},
_headers() {
return {
"Authorization": `Bearer ${this.$auth.api_key}`,
"Content-Type": "application/json",
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
sendSingleMessage(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/single/message",
...opts,
});
},
sendBulkMessages(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/bulk/message",
...opts,
});
},
},
};
};
17 changes: 6 additions & 11 deletions pnpm-lock.yaml

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

Loading