Skip to content

Commit 428b6ee

Browse files
committed
new actions
1 parent 47c4872 commit 428b6ee

File tree

4 files changed

+83
-54
lines changed

4 files changed

+83
-54
lines changed

components/slybroadcast/actions/start-campaign-audio-file/start-campaign-audio-file.mjs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import slybroadcast from "../../slybroadcast.app.mjs";
33
export default {
44
key: "slybroadcast-start-campaign-audio-file",
55
name: "Start Campaign with Audio File",
6-
description: "Start a new voicemail campaign using an audio file uploaded to your slybroadcast account.",
7-
version: "0.0.{{ts}}",
6+
description: "Start a new voicemail campaign using an audio file uploaded to your slybroadcast account. [See the documentation](https://www.slybroadcast.com/documentation.php)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
slybroadcast,
11-
audioFileId: {
11+
audioFile: {
1212
propDefinition: [
1313
slybroadcast,
14-
"audioFileId",
14+
"audioFile",
1515
],
1616
},
1717
recipients: {
@@ -20,13 +20,23 @@ export default {
2020
"recipients",
2121
],
2222
},
23+
date: {
24+
propDefinition: [
25+
slybroadcast,
26+
"date",
27+
],
28+
},
2329
},
2430
async run({ $ }) {
25-
const response = await this.slybroadcast.startCampaignWithFileId({
26-
audioFileId: this.audioFileId,
27-
recipients: this.recipients,
31+
const response = await this.slybroadcast.startCampaign({
32+
$,
33+
data: {
34+
c_record_audio: this.audioFile,
35+
c_phone: this.recipients.join(),
36+
c_date: this.date,
37+
},
2838
});
29-
$.export("$summary", `Started campaign with audio file ID: ${this.audioFileId}`);
39+
$.export("$summary", `Started campaign with audio file ID: ${this.audioFile}`);
3040
return response;
3141
},
3242
};

components/slybroadcast/actions/start-campaign-audio-url/start-campaign-audio-url.mjs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,48 @@ import slybroadcast from "../../slybroadcast.app.mjs";
33
export default {
44
key: "slybroadcast-start-campaign-audio-url",
55
name: "Start Campaign With Audio URL",
6-
description: "Launch a new voicemail campaign to an individual or a group using an audio file url",
7-
version: "0.0.{{ts}}",
6+
description: "Launch a new voicemail campaign to an individual or a group using an audio file url. [See the documentation](https://www.slybroadcast.com/documentation.php)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
slybroadcast,
11+
audioFileUrl: {
12+
type: "string",
13+
label: "Audio File URL",
14+
description: "The URL of the audio file for the voicemail campaign",
15+
},
16+
audioFileType: {
17+
type: "string",
18+
label: "Audio File Type",
19+
description: "WAV, Mp3 or M4a",
20+
options: [
21+
"WAV",
22+
"Mp3",
23+
"M4a",
24+
],
25+
},
1126
recipients: {
1227
propDefinition: [
1328
slybroadcast,
1429
"recipients",
1530
],
16-
description: "List of recipients for the voicemail campaign",
1731
},
18-
audioFileUrl: {
32+
date: {
1933
propDefinition: [
2034
slybroadcast,
21-
"audioFileUrl",
35+
"date",
2236
],
23-
description: "The URL of the audio file for the voicemail campaign",
2437
},
2538
},
2639
async run({ $ }) {
27-
const response = await this.slybroadcast.startCampaignWithFileUrl({
28-
audioFileUrl: this.audioFileUrl,
29-
recipients: this.recipients,
40+
const response = await this.slybroadcast.startCampaign({
41+
$,
42+
data: {
43+
c_url: this.audioFileUrl,
44+
c_audio: this.audioFileType,
45+
c_phone: this.recipients.join(),
46+
c_date: this.date,
47+
},
3048
});
3149
$.export("$summary", "Campaign started successfully");
3250
return response;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"name": "@pipedream/slybroadcast",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"description": "Pipedream Slybroadcast Components",
5-
"main": "dist/app/slybroadcast.app.mjs",
5+
"main": "slybroadcast.app.mjs",
66
"keywords": [
77
"pipedream",
88
"slybroadcast"
99
],
10-
"files": ["dist"],
1110
"homepage": "https://pipedream.com/apps/slybroadcast",
1211
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1312
"publishConfig": {
1413
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1517
}
1618
}

components/slybroadcast/slybroadcast.app.mjs

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,66 @@ export default {
44
type: "app",
55
app: "slybroadcast",
66
propDefinitions: {
7-
audioFileId: {
7+
audioFile: {
88
type: "string",
9-
label: "Audio File ID",
10-
description: "The ID of the audio file uploaded to your slybroadcast account",
9+
label: "Audio File",
10+
description: "The audio file uploaded to your slybroadcast account",
11+
async options() {
12+
const files = await this.listAudioFiles();
13+
const filenames = [
14+
...files.matchAll(/"\|"(.*?)"\|"/g),
15+
].map((match) => match[1]);
16+
return filenames;
17+
},
1118
},
1219
recipients: {
1320
type: "string[]",
1421
label: "Recipients",
15-
description: "List of recipients for the voicemail campaign",
22+
description: "Array of recipients' phone numbers for the voicemail campaign",
1623
},
17-
audioFileUrl: {
24+
date: {
1825
type: "string",
19-
label: "Audio File URL",
20-
description: "The URL of the audio file for the voicemail campaign",
26+
label: "Date",
27+
description: "Date/Time of delivery in Eastern Time. YYYY-MM-DD HH:MM:SS *Must use 24-hour time format. Example: 5:00pm = 17:00:00",
28+
default: "now",
29+
optional: true,
2130
},
2231
},
2332
methods: {
2433
_baseUrl() {
25-
return "https://www.mobile-sphere.com/gateway/vmb.php";
34+
return "https://www.mobile-sphere.com/gateway/";
2635
},
27-
async _makeRequest(opts = {}) {
36+
_makeRequest(opts = {}) {
2837
const {
29-
$ = this, method = "POST", path, headers, ...otherOpts
30-
} = opts;
38+
$ = this, method = "POST", path, data, ...otherOpts
39+
} = opts; console.log(data);
3140
return axios($, {
3241
...otherOpts,
3342
method,
34-
url: this._baseUrl() + path,
43+
url: `${this._baseUrl()}${path}`,
44+
data: {
45+
...data,
46+
c_uid: `${this.$auth.email}`,
47+
c_password: `${this.$auth.password}`,
48+
},
3549
headers: {
36-
...headers,
3750
"Content-Type": "application/x-www-form-urlencoded",
3851
},
3952
});
4053
},
41-
async startCampaignWithFileId({
42-
audioFileId, recipients,
43-
}) {
54+
listAudioFiles(opts = {}) {
4455
return this._makeRequest({
56+
path: "/vmb.aflist.php",
4557
data: {
46-
c_uid: this.$auth.c_uid,
47-
c_password: this.$auth.c_password,
48-
c_callerID: this.$auth.c_callerID,
49-
c_phone: recipients.join(","),
50-
c_date: "now",
51-
c_record_audio: audioFileId,
58+
c_method: "get_audio_list",
5259
},
60+
...opts,
5361
});
5462
},
55-
async startCampaignWithFileUrl({
56-
audioFileUrl, recipients,
57-
}) {
63+
startCampaign(opts = {}) {
5864
return this._makeRequest({
59-
data: {
60-
c_uid: this.$auth.c_uid,
61-
c_password: this.$auth.c_password,
62-
c_callerID: this.$auth.c_callerID,
63-
c_phone: recipients.join(","),
64-
c_date: "now",
65-
c_url: audioFileUrl,
66-
c_audio: audioFileUrl.split(".").pop(),
67-
},
65+
path: "/vmb.php",
66+
...opts,
6867
});
6968
},
7069
},

0 commit comments

Comments
 (0)