@pipedream/twilio 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/check-verification-token/check-verification-token.mjs +38 -0
- package/actions/delete-call/delete-call.mjs +1 -1
- package/actions/delete-message/delete-message.mjs +1 -1
- package/actions/download-recording-media/download-recording-media.mjs +1 -1
- package/actions/get-call/get-call.mjs +1 -1
- package/actions/get-message/get-message.mjs +1 -1
- package/actions/list-calls/list-calls.mjs +1 -1
- package/actions/list-message-media/list-message-media.mjs +1 -1
- package/actions/list-messages/list-messages.mjs +12 -3
- package/actions/list-recording-transcriptions/list-recording-transcriptions.mjs +1 -1
- package/actions/make-phone-call/make-phone-call.mjs +8 -3
- package/actions/send-mms/send-mms.mjs +8 -3
- package/actions/send-sms/send-sms.mjs +8 -3
- package/actions/send-sms-verification/send-sms-verification.mjs +29 -0
- package/package.json +1 -1
- package/sources/new-call/new-call.mjs +1 -1
- package/sources/new-incoming-sms/new-incoming-sms.mjs +1 -1
- package/sources/new-phone-number/new-phone-number.mjs +1 -1
- package/sources/new-recording/new-recording.mjs +1 -1
- package/sources/new-transcription/new-transcription.mjs +1 -1
- package/twilio.app.mjs +53 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import app from "../../twilio.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "twilio-check-verification-token",
|
|
5
|
+
name: "Check Verification Token",
|
|
6
|
+
description: "Check if user-provided token is correct. [See the documentation](https://www.twilio.com/docs/verify/api) for more information",
|
|
7
|
+
type: "action",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
props: {
|
|
10
|
+
app,
|
|
11
|
+
serviceSid: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
app,
|
|
14
|
+
"serviceSid",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
to: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
app,
|
|
20
|
+
"to",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
code: {
|
|
24
|
+
type: "string",
|
|
25
|
+
label: "Code",
|
|
26
|
+
description: "The code to check",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async run({ $ }) {
|
|
30
|
+
const res = await this.app.checkVerificationToken(
|
|
31
|
+
this.serviceSid,
|
|
32
|
+
this.to,
|
|
33
|
+
this.code,
|
|
34
|
+
);
|
|
35
|
+
$.export("$summary", `Successfully fetched SMS verification of "${this.to}"`);
|
|
36
|
+
return res;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "twilio-delete-call",
|
|
5
5
|
name: "Delete Call",
|
|
6
6
|
description: "Remove a call record from your account. [See the docs](https://www.twilio.com/docs/voice/api/call-resource#delete-a-call-resource) for more information",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
twilio,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "twilio-delete-message",
|
|
5
5
|
name: "Delete Message",
|
|
6
6
|
description: "Delete a message record from your account. [See the docs](https://www.twilio.com/docs/sms/api/message-resource#delete-a-message-resource) for more information",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
twilio,
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "twilio-download-recording-media",
|
|
9
9
|
name: "Download Recording Media",
|
|
10
10
|
description: "Download a recording media file. [See the docs](https://www.twilio.com/docs/voice/api/recording#fetch-a-recording-media-file) for more information",
|
|
11
|
-
version: "0.1.
|
|
11
|
+
version: "0.1.2",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
twilio,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "twilio-get-call",
|
|
6
6
|
name: "Get Call",
|
|
7
7
|
description: "Return call resource of an individual call. [See the docs](https://www.twilio.com/docs/voice/api/call-resource#fetch-a-call-resource) for more information",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
twilio,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "twilio-get-message",
|
|
6
6
|
name: "Get Message",
|
|
7
7
|
description: "Return details of a message. [See the docs](https://www.twilio.com/docs/sms/api/message-resource#fetch-a-message-resource) for more information",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
twilio,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "twilio-list-calls",
|
|
6
6
|
name: "List Calls",
|
|
7
7
|
description: "Return a list of calls associated with your account. [See the docs](https://www.twilio.com/docs/voice/api/call-resource#read-multiple-call-resources) for more information",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
twilio,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "twilio-list-message-media",
|
|
6
6
|
name: "List Message Media",
|
|
7
7
|
description: "Return a list of media associated with your message. [See the docs](https://www.twilio.com/docs/sms/api/media-resource#read-multiple-media-resources) for more information",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
twilio,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "twilio-list-messages",
|
|
7
7
|
name: "List Messages",
|
|
8
8
|
description: "Return a list of messages associated with your account. [See the docs](https://www.twilio.com/docs/sms/api/message-resource#read-multiple-message-resources) for more information",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.3",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
twilio,
|
|
@@ -42,14 +42,23 @@ export default {
|
|
|
42
42
|
if (this.to) {
|
|
43
43
|
const toParsed = phone(this.to);
|
|
44
44
|
if (!toParsed || !toParsed.phoneNumber) {
|
|
45
|
-
throw new Error(`Phone number ${this.to}
|
|
45
|
+
throw new Error(`Phone number ${this.to} could not be parsed as a valid number.`);
|
|
46
46
|
}
|
|
47
47
|
to = toParsed.phoneNumber;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
let from = this.from;
|
|
51
|
+
if (this.from) {
|
|
52
|
+
const fromParsed = phone(this.from);
|
|
53
|
+
if (!fromParsed || !fromParsed.phoneNumber) {
|
|
54
|
+
throw new Error(`Phone number ${this.from} could not be parsed as a valid number.`);
|
|
55
|
+
}
|
|
56
|
+
from = fromParsed.phoneNumber;
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
const resp = await this.twilio.listMessages(omitEmptyStringValues({
|
|
51
60
|
to,
|
|
52
|
-
from
|
|
61
|
+
from,
|
|
53
62
|
limit: this.limit,
|
|
54
63
|
}));
|
|
55
64
|
/* eslint-disable multiline-ternary */
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "twilio-list-recording-transcriptions",
|
|
6
6
|
name: "List Recording Transcriptions",
|
|
7
7
|
description: "Return a set of transcriptions available for a recording. [See the docs](https://www.twilio.com/docs/voice/api/recording#fetch-a-recordings-transcriptions) for more information",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
twilio,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "twilio-make-phone-call",
|
|
7
7
|
name: "Make a Phone Call",
|
|
8
8
|
description: "Make a phone call, passing text that Twilio will speak to the recipient of the call. [See the docs](https://www.twilio.com/docs/voice/api/call-resource#create-a-call-resource) for more information",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.3",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
twilio,
|
|
@@ -36,12 +36,17 @@ export default {
|
|
|
36
36
|
const toParsed = phone(this.to);
|
|
37
37
|
console.log(toParsed);
|
|
38
38
|
if (!toParsed || !toParsed.phoneNumber) {
|
|
39
|
-
throw new Error(`Phone number ${this.to}
|
|
39
|
+
throw new Error(`Phone number ${this.to} could not be parsed as a valid number.`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const fromParsed = phone(this.from);
|
|
43
|
+
if (!fromParsed || !fromParsed.phoneNumber) {
|
|
44
|
+
throw new Error(`Phone number ${this.from} could not be parsed as a valid number.`);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
const data = {
|
|
43
48
|
to: toParsed.phoneNumber,
|
|
44
|
-
from:
|
|
49
|
+
from: fromParsed.phoneNumber,
|
|
45
50
|
twiml: `<Response><Say>${this.text}</Say></Response>`,
|
|
46
51
|
};
|
|
47
52
|
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "Send MMS",
|
|
8
8
|
description: "Send an SMS with text and media files. [See the docs](https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource) for more information",
|
|
9
9
|
type: "action",
|
|
10
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.3",
|
|
11
11
|
props: {
|
|
12
12
|
twilio,
|
|
13
13
|
from: {
|
|
@@ -42,12 +42,17 @@ export default {
|
|
|
42
42
|
// See https://www.npmjs.com/package/phone
|
|
43
43
|
const toParsed = phone(this.to);
|
|
44
44
|
if (!toParsed || !toParsed.phoneNumber) {
|
|
45
|
-
throw new Error(`Phone number ${this.to}
|
|
45
|
+
throw new Error(`Phone number ${this.to} could not be parsed as a valid number.`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const fromParsed = phone(this.from);
|
|
49
|
+
if (!fromParsed || !fromParsed.phoneNumber) {
|
|
50
|
+
throw new Error(`Phone number ${this.from} could not be parsed as a valid number.`);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
const data = {
|
|
49
54
|
to: toParsed.phoneNumber,
|
|
50
|
-
from:
|
|
55
|
+
from: fromParsed.phoneNumber,
|
|
51
56
|
body: this.body,
|
|
52
57
|
mediaUrl: this.mediaUrl,
|
|
53
58
|
};
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
name: "Send SMS",
|
|
8
8
|
description: "Send a simple text-only SMS. [See the docs](https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource) for more information",
|
|
9
9
|
type: "action",
|
|
10
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.3",
|
|
11
11
|
props: {
|
|
12
12
|
twilio,
|
|
13
13
|
from: {
|
|
@@ -36,12 +36,17 @@ export default {
|
|
|
36
36
|
// See https://www.npmjs.com/package/phone
|
|
37
37
|
const toParsed = phone(this.to);
|
|
38
38
|
if (!toParsed || !toParsed.phoneNumber) {
|
|
39
|
-
throw new Error(`Phone number ${this.to}
|
|
39
|
+
throw new Error(`Phone number ${this.to} could not be parsed as a valid number.`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const fromParsed = phone(this.from);
|
|
43
|
+
if (!fromParsed || !fromParsed.phoneNumber) {
|
|
44
|
+
throw new Error(`Phone number ${this.from} could not be parsed as a valid number.`);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
const data = {
|
|
43
48
|
to: toParsed.phoneNumber,
|
|
44
|
-
from:
|
|
49
|
+
from: fromParsed.phoneNumber,
|
|
45
50
|
body: this.body,
|
|
46
51
|
};
|
|
47
52
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import app from "../../twilio.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "twilio-send-sms-verification",
|
|
5
|
+
name: "Send SMS Verification",
|
|
6
|
+
description: "Send an SMS verification to a phone number. [See the documentation](https://www.twilio.com/docs/verify/api) for more information",
|
|
7
|
+
type: "action",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
props: {
|
|
10
|
+
app,
|
|
11
|
+
serviceSid: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
app,
|
|
14
|
+
"serviceSid",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
to: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
app,
|
|
20
|
+
"to",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ $ }) {
|
|
25
|
+
const res = await this.app.sendSmsVerificationCode(this.serviceSid, this.to);
|
|
26
|
+
$.export("$summary", `Successfully sent an SMS verification to "${this.to}"`);
|
|
27
|
+
return res;
|
|
28
|
+
},
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "twilio-new-call",
|
|
7
7
|
name: "New Call (Instant)",
|
|
8
8
|
description: "Emit new event each time a call to the phone number is completed. Configures a webhook in Twilio, tied to a phone number.",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.3",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
key: "twilio-new-incoming-sms",
|
|
10
10
|
name: "New Incoming SMS (Instant)",
|
|
11
11
|
description: "Emit new event every time an SMS is sent to the phone number set. Configures a webhook in Twilio, tied to an incoming phone number.",
|
|
12
|
-
version: "0.1.
|
|
12
|
+
version: "0.1.3",
|
|
13
13
|
type: "source",
|
|
14
14
|
dedupe: "unique",
|
|
15
15
|
props: {
|
package/twilio.app.mjs
CHANGED
|
@@ -154,6 +154,18 @@ export default {
|
|
|
154
154
|
"no-answer",
|
|
155
155
|
],
|
|
156
156
|
},
|
|
157
|
+
serviceSid: {
|
|
158
|
+
type: "string",
|
|
159
|
+
label: "Service SID",
|
|
160
|
+
description: "The SID of the service to which the verification belongs",
|
|
161
|
+
async options() {
|
|
162
|
+
const services = await this.listServices();
|
|
163
|
+
return services.map((service) => ({
|
|
164
|
+
label: service.friendlyName,
|
|
165
|
+
value: service.sid,
|
|
166
|
+
}));
|
|
167
|
+
},
|
|
168
|
+
},
|
|
157
169
|
},
|
|
158
170
|
methods: {
|
|
159
171
|
validateRequest({
|
|
@@ -345,5 +357,46 @@ export default {
|
|
|
345
357
|
const client = this.getClient();
|
|
346
358
|
return client.recordings(sid).transcriptions.list(params);
|
|
347
359
|
},
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Send a verification code via sms
|
|
363
|
+
*
|
|
364
|
+
* @param {String} serviceSid Service SID
|
|
365
|
+
* @param {String} to Number to send the code to
|
|
366
|
+
* @returns {Promise<*>} Twilio response object
|
|
367
|
+
*/
|
|
368
|
+
async sendSmsVerificationCode(serviceSid, to) {
|
|
369
|
+
const client = this.getClient();
|
|
370
|
+
return client.verify.v2.services(serviceSid).verifications.create({
|
|
371
|
+
to,
|
|
372
|
+
channel: "sms",
|
|
373
|
+
});
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* List all services
|
|
378
|
+
*
|
|
379
|
+
* @returns {Promise<*>} List of services
|
|
380
|
+
*/
|
|
381
|
+
async listServices() {
|
|
382
|
+
const client = this.getClient();
|
|
383
|
+
return client.verify.v2.services.list();
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Check whether the verification token is valid
|
|
388
|
+
*
|
|
389
|
+
* @param {String} serviceSid Service SID
|
|
390
|
+
* @param {String} to The number to check the token for
|
|
391
|
+
* @param {String} code The Code to check against
|
|
392
|
+
* @returns {Promise<*>} Twilio response object
|
|
393
|
+
*/
|
|
394
|
+
async checkVerificationToken(serviceSid, to, code) {
|
|
395
|
+
const client = this.getClient();
|
|
396
|
+
return client.verify.v2.services(serviceSid).verificationChecks.create({
|
|
397
|
+
to,
|
|
398
|
+
code,
|
|
399
|
+
});
|
|
400
|
+
},
|
|
348
401
|
},
|
|
349
402
|
};
|