@activepieces/piece-twilio 0.4.6 → 0.4.7

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.
Files changed (49) hide show
  1. package/package.json +7 -12
  2. package/src/index.js +13 -61
  3. package/src/index.d.ts +0 -3
  4. package/src/index.d.ts.map +0 -1
  5. package/src/index.js.map +0 -1
  6. package/src/lib/action/download-recording-media.d.ts +0 -6
  7. package/src/lib/action/download-recording-media.d.ts.map +0 -1
  8. package/src/lib/action/download-recording-media.js +0 -75
  9. package/src/lib/action/download-recording-media.js.map +0 -1
  10. package/src/lib/action/get-message.d.ts +0 -4
  11. package/src/lib/action/get-message.d.ts.map +0 -1
  12. package/src/lib/action/get-message.js +0 -34
  13. package/src/lib/action/get-message.js.map +0 -1
  14. package/src/lib/action/make-call.d.ts +0 -10
  15. package/src/lib/action/make-call.d.ts.map +0 -1
  16. package/src/lib/action/make-call.js +0 -96
  17. package/src/lib/action/make-call.js.map +0 -1
  18. package/src/lib/action/phone-number-lookup.d.ts +0 -4
  19. package/src/lib/action/phone-number-lookup.d.ts.map +0 -1
  20. package/src/lib/action/phone-number-lookup.js +0 -42
  21. package/src/lib/action/phone-number-lookup.js.map +0 -1
  22. package/src/lib/action/send-sms.d.ts +0 -6
  23. package/src/lib/action/send-sms.d.ts.map +0 -1
  24. package/src/lib/action/send-sms.js +0 -42
  25. package/src/lib/action/send-sms.js.map +0 -1
  26. package/src/lib/common/index.d.ts +0 -9
  27. package/src/lib/common/index.d.ts.map +0 -1
  28. package/src/lib/common/index.js +0 -54
  29. package/src/lib/common/index.js.map +0 -1
  30. package/src/lib/trigger/new-call.d.ts +0 -3
  31. package/src/lib/trigger/new-call.d.ts.map +0 -1
  32. package/src/lib/trigger/new-call.js +0 -133
  33. package/src/lib/trigger/new-call.js.map +0 -1
  34. package/src/lib/trigger/new-incoming-sms.d.ts +0 -11
  35. package/src/lib/trigger/new-incoming-sms.d.ts.map +0 -1
  36. package/src/lib/trigger/new-incoming-sms.js +0 -106
  37. package/src/lib/trigger/new-incoming-sms.js.map +0 -1
  38. package/src/lib/trigger/new-phone-number.d.ts +0 -3
  39. package/src/lib/trigger/new-phone-number.d.ts.map +0 -1
  40. package/src/lib/trigger/new-phone-number.js +0 -111
  41. package/src/lib/trigger/new-phone-number.js.map +0 -1
  42. package/src/lib/trigger/new-recording.d.ts +0 -3
  43. package/src/lib/trigger/new-recording.d.ts.map +0 -1
  44. package/src/lib/trigger/new-recording.js +0 -121
  45. package/src/lib/trigger/new-recording.js.map +0 -1
  46. package/src/lib/trigger/new-transcription.d.ts +0 -3
  47. package/src/lib/trigger/new-transcription.d.ts.map +0 -1
  48. package/src/lib/trigger/new-transcription.js +0 -110
  49. package/src/lib/trigger/new-transcription.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"make-call.d.ts","sourceRoot":"","sources":["../../../../src/lib/action/make-call.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;;;;;;EA+FzB,CAAC"}
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.twilioMakeCall = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const common_1 = require("../common");
8
- const __1 = require("../..");
9
- exports.twilioMakeCall = (0, pieces_framework_1.createAction)({
10
- auth: __1.twilioAuth,
11
- name: 'make_call',
12
- description: 'Call a number and say a message.',
13
- audience: 'both',
14
- aiMetadata: { description: 'Places an outbound voice call from a Twilio number that reads a text-to-speech message to the recipient. Use to deliver a spoken notification or alert by phone. Requires both numbers in E.164 format and the message text; each call places a real, billable phone call, so it is not idempotent.', idempotent: false },
15
- displayName: 'Call Phone',
16
- props: {
17
- from: common_1.twilioCommon.phone_number,
18
- to: pieces_framework_1.Property.ShortText({
19
- displayName: 'To',
20
- description: 'The phone number to call. Must be in E.164 format (e.g., +15558675310).',
21
- required: true,
22
- }),
23
- message: pieces_framework_1.Property.LongText({
24
- displayName: 'Message to Say',
25
- description: 'The text message to be converted to speech and spoken to the recipient.',
26
- required: true,
27
- }),
28
- voice: pieces_framework_1.Property.StaticDropdown({
29
- displayName: 'Voice',
30
- description: 'The voice to use for the text-to-speech message.',
31
- required: false,
32
- options: {
33
- options: [
34
- { label: 'Alice (Default)', value: 'alice' },
35
- { label: 'Man', value: 'man' },
36
- { label: 'Woman', value: 'woman' },
37
- ]
38
- }
39
- }),
40
- language: pieces_framework_1.Property.StaticDropdown({
41
- displayName: 'Language',
42
- description: 'The language to use for the text-to-speech message.',
43
- required: false,
44
- options: {
45
- options: [
46
- { label: 'English (US)', value: 'en-US' },
47
- { label: 'English (UK)', value: 'en-GB' },
48
- { label: 'Spanish', value: 'es-ES' },
49
- { label: 'French', value: 'fr-FR' },
50
- { label: 'German', value: 'de-DE' },
51
- ]
52
- }
53
- }),
54
- sendDigits: pieces_framework_1.Property.ShortText({
55
- displayName: 'Send DTMF Tones',
56
- description: "A string of keys to dial after the call is connected. Use 'w' for a half-second pause.",
57
- required: false,
58
- }),
59
- timeout: pieces_framework_1.Property.Number({
60
- displayName: 'Timeout (seconds)',
61
- description: 'The number of seconds to let the phone ring before assuming no answer. Default is 60.',
62
- required: false,
63
- })
64
- },
65
- run(context) {
66
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
67
- const { from, to, message, voice, language, sendDigits, timeout } = context.propsValue;
68
- const account_sid = context.auth.username;
69
- const auth_token = context.auth.password;
70
- // Construct TwiML for the <Say> verb
71
- const voiceAttr = voice ? ` voice="${voice}"` : '';
72
- const langAttr = language ? ` language="${language}"` : '';
73
- const escapedMessage = message
74
- .replace(/&/g, '&amp;')
75
- .replace(/</g, '&lt;')
76
- .replace(/>/g, '&gt;')
77
- .replace(/"/g, '&quot;')
78
- .replace(/'/g, '&apos;');
79
- const twiml = `<Response><Say${voiceAttr}${langAttr}>${escapedMessage}</Say></Response>`;
80
- const bodyParams = {
81
- From: from,
82
- To: to,
83
- Twiml: twiml,
84
- };
85
- if (sendDigits) {
86
- bodyParams['SendDigits'] = sendDigits;
87
- }
88
- if (timeout) {
89
- bodyParams['Timeout'] = timeout;
90
- }
91
- const response = yield (0, common_1.callTwilioApi)(pieces_common_1.HttpMethod.POST, 'Calls.json', { account_sid, auth_token }, bodyParams);
92
- return response.body;
93
- });
94
- },
95
- });
96
- //# sourceMappingURL=make-call.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"make-call.js","sourceRoot":"","sources":["../../../../src/lib/action/make-call.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,sCAAwD;AACxD,6BAAmC;AAEtB,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,cAAU;IAChB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,kCAAkC;IAC/C,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,qSAAqS,EAAE,UAAU,EAAE,KAAK,EAAE;IACrV,WAAW,EAAE,YAAY;IACzB,KAAK,EAAE;QACL,IAAI,EAAE,qBAAY,CAAC,YAAY;QAC/B,EAAE,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACrB,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,yEAAyE;YACtF,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,yEAAyE;YACtF,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC3B,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,kDAAkD;YAC/D,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACL,OAAO,EAAE;oBACL,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE;oBAC5C,EAAE,KAA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AC,CAAC,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACnD,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3D,MAAM,cAAc,GAAG,OAAO;iBACzB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;iBACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;iBACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;iBACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;iBACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC7B,MAAM,KAAK,GAAG,iBAAiB,SAAS,GAAG,QAAQ,IAAI,cAAc,mBAAmB,CAAC;YAEzF,MAAM,UAAU,GAA4B;gBAC1C,IAAI,EAAE,IAAI;gBACV,EAAE,EAAE,EAAE;gBACN,KAAK,EAAE,KAAK;aACb,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACf,UAAU,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC;YACxC,CAAC;YACD,IAAI,OAAO,EAAE,CAAC;gBACZ,UAAU,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;YAClC,CAAC;YAED,MAAM,QAAQ,GAAI,MAAM,IAAA,sBAAa,EACnC,0BAAU,CAAC,IAAI,EACf,YAAY,EACZ,EAAE,WAAW,EAAE,UAAU,EAAE,EAC3B,UAAU,CACX,CAAC;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare const twilioPhoneNumberLookup: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").BasicAuthProperty, {
2
- phone_number: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- }>;
4
- //# sourceMappingURL=phone-number-lookup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phone-number-lookup.d.ts","sourceRoot":"","sources":["../../../../src/lib/action/phone-number-lookup.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB;;EAkClC,CAAC"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.twilioPhoneNumberLookup = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const __1 = require("../..");
8
- exports.twilioPhoneNumberLookup = (0, pieces_framework_1.createAction)({
9
- auth: __1.twilioAuth,
10
- name: 'phone_number_lookup',
11
- description: 'Lookup information about a phone number.',
12
- audience: 'both',
13
- aiMetadata: { description: 'Looks up carrier and line-type intelligence for a single phone number via the Twilio Lookup API. Use to validate or enrich a number (e.g. detect mobile vs landline, carrier) before messaging or calling it. Read-only and idempotent.', idempotent: true },
14
- displayName: 'Phone Number Lookup',
15
- props: {
16
- phone_number: pieces_framework_1.Property.ShortText({
17
- displayName: 'Phone Number',
18
- required: true
19
- })
20
- },
21
- run(context) {
22
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
- const { phone_number } = context.propsValue;
24
- const account_sid = context.auth.username;
25
- const auth_token = context.auth.password;
26
- const response = yield pieces_common_1.httpClient.sendRequest({
27
- method: pieces_common_1.HttpMethod.GET,
28
- url: `https://lookups.twilio.com/v2/PhoneNumbers/${encodeURIComponent(phone_number)}`,
29
- authentication: {
30
- type: pieces_common_1.AuthenticationType.BASIC,
31
- username: account_sid,
32
- password: auth_token,
33
- },
34
- queryParams: {
35
- Fields: 'line_type_intelligence'
36
- }
37
- });
38
- return response.body;
39
- });
40
- },
41
- });
42
- //# sourceMappingURL=phone-number-lookup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phone-number-lookup.js","sourceRoot":"","sources":["../../../../src/lib/action/phone-number-lookup.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyF;AACzF,6BAAmC;AAEtB,QAAA,uBAAuB,GAAG,IAAA,+BAAY,EAAC;IAClD,IAAI,EAAE,cAAU;IAChB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,0CAA0C;IACvD,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,yOAAyO,EAAE,UAAU,EAAE,IAAI,EAAE;IACxR,WAAW,EAAE,qBAAqB;IAClC,KAAK,EAAE;QACL,YAAY,EAAC,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAC,cAAc;YAC1B,QAAQ,EAAC,IAAI;SACd,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAE5C,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YAEzC,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAC,0BAAU,CAAC,GAAG;gBACrB,GAAG,EAAC,8CAA8C,kBAAkB,CAAC,YAAY,CAAC,EAAE;gBACnF,cAAc,EAAE;oBACX,IAAI,EAAE,kCAAkB,CAAC,KAAK;oBAC9B,QAAQ,EAAE,WAAW;oBACrB,QAAQ,EAAE,UAAU;iBACrB;gBACH,WAAW,EAAC;oBACV,MAAM,EAAC,wBAAwB;iBAChC;aACJ,CAAC,CAAA;YAEF,OAAO,QAAQ,CAAC,IAAI,CAAA;QACtB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,6 +0,0 @@
1
- export declare const twilioSendSms: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").BasicAuthProperty, {
2
- from: import("@activepieces/pieces-framework").DropdownProperty<any, true, import("@activepieces/pieces-framework").BasicAuthProperty>;
3
- body: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- to: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
- }>;
6
- //# sourceMappingURL=send-sms.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-sms.d.ts","sourceRoot":"","sources":["../../../../src/lib/action/send-sms.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;;EAmCxB,CAAC"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.twilioSendSms = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const common_1 = require("../common");
8
- const __1 = require("../..");
9
- exports.twilioSendSms = (0, pieces_framework_1.createAction)({
10
- auth: __1.twilioAuth,
11
- name: 'send_sms',
12
- description: 'Send a new SMS message',
13
- audience: 'both',
14
- aiMetadata: { description: 'Sends an SMS text message from a Twilio phone number to a recipient. Use to notify or message a person by text. Requires the destination number, message body, and a Twilio-owned sender number; sending costs money and delivers a separate message on every call, so it is not idempotent.', idempotent: false },
15
- displayName: 'Send SMS',
16
- props: {
17
- from: common_1.twilioCommon.phone_number,
18
- body: pieces_framework_1.Property.ShortText({
19
- description: 'The body of the message to send',
20
- displayName: 'Message Body',
21
- required: true,
22
- }),
23
- to: pieces_framework_1.Property.ShortText({
24
- description: 'The phone number to send the message to',
25
- displayName: 'To',
26
- required: true,
27
- }),
28
- },
29
- run(context) {
30
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
- const { body, to, from } = context.propsValue;
32
- const account_sid = context.auth.username;
33
- const auth_token = context.auth.password;
34
- return yield (0, common_1.callTwilioApi)(pieces_common_1.HttpMethod.POST, 'Messages.json', { account_sid, auth_token }, {
35
- From: from,
36
- Body: body,
37
- To: to,
38
- });
39
- });
40
- },
41
- });
42
- //# sourceMappingURL=send-sms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-sms.js","sourceRoot":"","sources":["../../../../src/lib/action/send-sms.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,sCAAwD;AACxD,6BAAmC;AAEtB,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,cAAU;IAChB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,wBAAwB;IACrC,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,8RAA8R,EAAE,UAAU,EAAE,KAAK,EAAE;IAC9U,WAAW,EAAE,UAAU;IACvB,KAAK,EAAE;QACL,IAAI,EAAE,qBAAY,CAAC,YAAY;QAC/B,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,iCAAiC;YAC9C,WAAW,EAAE,cAAc;YAC3B,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,EAAE,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACrB,WAAW,EAAE,yCAAyC;YACtD,WAAW,EAAE,IAAI;YACjB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YACzC,OAAO,MAAM,IAAA,sBAAa,EACxB,0BAAU,CAAC,IAAI,EACf,eAAe,EACf,EAAE,WAAW,EAAE,UAAU,EAAE,EAC3B;gBACE,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,IAAI;gBACV,EAAE,EAAE,EAAE;aACP,CACF,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- import { HttpMethod } from '@activepieces/pieces-common';
2
- export declare const twilioCommon: {
3
- phone_number: import("@activepieces/pieces-framework").DropdownProperty<any, true, import("@activepieces/pieces-framework").BasicAuthProperty>;
4
- };
5
- export declare const callTwilioApi: <T extends unknown>(method: HttpMethod, path: string, auth: {
6
- account_sid: string;
7
- auth_token: string;
8
- }, body?: any) => Promise<import("@activepieces/pieces-common").HttpResponse<T>>;
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EAIX,MAAM,6BAA6B,CAAC;AAGrC,eAAO,MAAM,YAAY;;CAmCxB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,CAAC,0BAC3B,UAAU,QACZ,MAAM,QACN;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,SAC1C,GAAG,mEAeX,CAAC"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callTwilioApi = exports.twilioCommon = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const __1 = require("../..");
8
- exports.twilioCommon = {
9
- phone_number: pieces_framework_1.Property.Dropdown({
10
- auth: __1.twilioAuth,
11
- description: 'The phone number to send the message from',
12
- displayName: 'From',
13
- required: true,
14
- refreshers: [],
15
- options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
16
- if (!auth) {
17
- return {
18
- disabled: true,
19
- placeholder: 'connect your account first',
20
- options: [],
21
- };
22
- }
23
- const basicAuthProperty = auth;
24
- const response = yield (0, exports.callTwilioApi)(pieces_common_1.HttpMethod.GET, 'IncomingPhoneNumbers.json', {
25
- account_sid: basicAuthProperty.username,
26
- auth_token: basicAuthProperty.password,
27
- });
28
- return {
29
- disabled: false,
30
- options: response.body.incoming_phone_numbers.map((number) => ({
31
- value: number.phone_number,
32
- label: number.friendly_name,
33
- })),
34
- };
35
- }),
36
- }),
37
- };
38
- const callTwilioApi = (method, path, auth, body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
39
- return yield pieces_common_1.httpClient.sendRequest({
40
- method,
41
- url: `https://api.twilio.com/2010-04-01/Accounts/${auth.account_sid}/${path}`,
42
- authentication: {
43
- type: pieces_common_1.AuthenticationType.BASIC,
44
- username: auth.account_sid,
45
- password: auth.auth_token,
46
- },
47
- headers: {
48
- 'Content-Type': 'application/x-www-form-urlencoded',
49
- },
50
- body: body,
51
- });
52
- });
53
- exports.callTwilioApi = callTwilioApi;
54
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,qEAGwC;AACxC,+DAKqC;AACrC,6BAAmC;AAEtB,QAAA,YAAY,GAAG;IAC1B,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;QAC9B,IAAI,EAAE,cAAU;QAChB,WAAW,EAAE,2CAA2C;QACxD,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;YACtB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,4BAA4B;oBACzC,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;YAED,MAAM,iBAAiB,GAAG,IAAI,CAAC;YAC/B,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAKjC,0BAAU,CAAC,GAAG,EAAE,2BAA2B,EAAE;gBAC9C,WAAW,EAAE,iBAAiB,CAAC,QAAQ;gBACvC,UAAU,EAAE,iBAAiB,CAAC,QAAQ;aACvC,CAAC,CAAC;YACH,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,CAAC;oBAClE,KAAK,EAAE,MAAM,CAAC,YAAY;oBAC1B,KAAK,EAAE,MAAM,CAAC,aAAa;iBAC5B,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC,CAAA;KACF,CAAC;CACH,CAAC;AAEK,MAAM,aAAa,GAAG,CAC3B,MAAkB,EAClB,IAAY,EACZ,IAAiD,EACjD,IAAU,EACV,EAAE;IACF,OAAO,MAAM,0BAAU,CAAC,WAAW,CAAI;QACrC,MAAM;QACN,GAAG,EAAE,8CAA8C,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE;QAC7E,cAAc,EAAE;YACd,IAAI,EAAE,kCAAkB,CAAC,KAAK;YAC9B,QAAQ,EAAE,IAAI,CAAC,WAAW;YAC1B,QAAQ,EAAE,IAAI,CAAC,UAAU;SAC1B;QACD,OAAO,EAAE;YACP,cAAc,EAAE,mCAAmC;SACpD;QACD,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAnBW,QAAA,aAAa,iBAmBxB"}
@@ -1,3 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const twilioNewCall: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").BasicAuthProperty, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").BasicAuthProperty, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").BasicAuthProperty, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").BasicAuthProperty, {}>;
3
- //# sourceMappingURL=new-call.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-call.d.ts","sourceRoot":"","sources":["../../../../src/lib/trigger/new-call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAA2D,MAAM,gCAAgC,CAAC;AAqFzI,eAAO,MAAM,aAAa,sjBAsExB,CAAC"}
@@ -1,133 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.twilioNewCall = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const __1 = require("../..");
7
- const pieces_common_1 = require("@activepieces/pieces-common");
8
- const polling = {
9
- strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
10
- items(_a) {
11
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, lastFetchEpochMS }) {
12
- var _b, _c;
13
- const isTest = lastFetchEpochMS === 0;
14
- const account_sid = auth.username;
15
- const auth_token = auth.password;
16
- let currentUri = `/2010-04-01/Accounts/${account_sid}/Calls.json?PageSize=${isTest ? 1 : 1000}`;
17
- const results = [];
18
- let stop = false;
19
- do {
20
- const response = yield pieces_common_1.httpClient.sendRequest({
21
- method: pieces_common_1.HttpMethod.GET,
22
- url: `https://api.twilio.com${currentUri}`,
23
- authentication: {
24
- type: pieces_common_1.AuthenticationType.BASIC,
25
- username: account_sid,
26
- password: auth_token,
27
- },
28
- });
29
- const payload = response.body;
30
- const calls = (_b = payload.calls) !== null && _b !== void 0 ? _b : [];
31
- for (const call of calls) {
32
- const ts = new Date(call.date_created).getTime();
33
- if (call.status !== 'completed')
34
- continue;
35
- if (isTest || ts > lastFetchEpochMS) {
36
- results.push(call);
37
- }
38
- else {
39
- stop = true;
40
- break;
41
- }
42
- }
43
- if (isTest)
44
- break;
45
- currentUri = (_c = payload === null || payload === void 0 ? void 0 : payload.next_page_uri) !== null && _c !== void 0 ? _c : null;
46
- } while (currentUri && !stop);
47
- return results.map((call) => {
48
- return {
49
- epochMilliSeconds: new Date(call.date_created).getTime(),
50
- data: call,
51
- };
52
- });
53
- });
54
- },
55
- };
56
- exports.twilioNewCall = (0, pieces_framework_1.createTrigger)({
57
- auth: __1.twilioAuth,
58
- name: 'new_call',
59
- displayName: 'New Call',
60
- description: 'Triggers when a call completes (incoming or outgoing).',
61
- aiMetadata: {
62
- description: 'Fires when a voice call reaches completed status on the Twilio account, for both inbound and outbound calls. Each event represents one finished call with its direction, participants, duration, and status.',
63
- },
64
- props: {},
65
- sampleData: {
66
- "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
67
- "answered_by": "machine_start",
68
- "api_version": "2010-04-01",
69
- "caller_name": "callerid1",
70
- "date_created": "Fri, 18 Oct 2019 17:00:00 +0000",
71
- "date_updated": "Fri, 18 Oct 2019 17:01:00 +0000",
72
- "direction": "outbound-api",
73
- "duration": "4",
74
- "end_time": "Fri, 18 Oct 2019 17:03:00 +0000",
75
- "forwarded_from": "calledvia1",
76
- "from": "+13051416799",
77
- "from_formatted": "(305) 141-6799",
78
- "group_sid": "GPdeadbeefdeadbeefdeadbeefdeadbeef",
79
- "parent_call_sid": "CAdeadbeefdeadbeefdeadbeefdeadbeef",
80
- "phone_number_sid": "PNdeadbeefdeadbeefdeadbeefdeadbeef",
81
- "price": "-0.200",
82
- "price_unit": "USD",
83
- "sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
84
- "start_time": "Fri, 18 Oct 2019 17:02:00 +0000",
85
- "status": "completed",
86
- "subresource_uris": {
87
- "notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",
88
- "recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
89
- "payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",
90
- "events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",
91
- "siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",
92
- "streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",
93
- "transcriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Transcriptions.json",
94
- "user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json",
95
- "user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json"
96
- },
97
- "to": "+13051913581",
98
- "to_formatted": "(305) 191-3581",
99
- "trunk_sid": "TKdeadbeefdeadbeefdeadbeefdeadbeef",
100
- "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
101
- "queue_time": "1000"
102
- },
103
- type: pieces_framework_1.TriggerStrategy.POLLING,
104
- onEnable(context) {
105
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
106
- yield pieces_common_1.pollingHelper.onEnable(polling, {
107
- auth: context.auth,
108
- store: context.store,
109
- propsValue: context.propsValue,
110
- });
111
- });
112
- },
113
- onDisable(context) {
114
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
115
- yield pieces_common_1.pollingHelper.onDisable(polling, {
116
- auth: context.auth,
117
- store: context.store,
118
- propsValue: context.propsValue,
119
- });
120
- });
121
- },
122
- test(context) {
123
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
124
- return yield pieces_common_1.pollingHelper.test(polling, context);
125
- });
126
- },
127
- run(context) {
128
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
129
- return yield pieces_common_1.pollingHelper.poll(polling, context);
130
- });
131
- },
132
- });
133
- //# sourceMappingURL=new-call.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-call.js","sourceRoot":"","sources":["../../../../src/lib/trigger/new-call.ts"],"names":[],"mappings":";;;;AAAA,qEAAyI;AACzI,6BAAmC;AACnC,+DAAiI;AAuBjI,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAC5B,KAAK;qEAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE;;YACpC,MAAM,MAAM,GAAG,gBAAgB,KAAK,CAAC,CAAC;YACtC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC;YAClC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC;YAEjC,IAAI,UAAU,GAEH,wBAAwB,WAAW,wBAC5C,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IACf,EAAE,CAAC;YAEH,MAAM,OAAO,GAAG,EAAE,CAAC;YACnB,IAAI,IAAI,GAAG,KAAK,CAAC;YAEjB,GAAG,CAAC;gBACF,MAAM,QAAQ,GAAQ,MAAM,0BAAU,CAAC,WAAW,CAAC;oBACjD,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,yBAAyB,UAAU,EAAE;oBAC1C,cAAc,EAAE;wBACd,IAAI,EAAE,kCAAkB,CAAC,KAAK;wBAC9B,QAAQ,EAAE,WAAW;wBACrB,QAAQ,EAAE,UAAU;qBACrB;iBACF,CAAC,CAAC;gBAEH,MAAM,OAAO,GAAG,QAAQ,CAAC,IAA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AAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;KAAA;IACK,IAAI,CAAC,OAAO;;YAChB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const twilioNewIncomingSms: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").BasicAuthProperty, {
3
- phone_number: import("@activepieces/pieces-framework").DropdownProperty<any, true, import("@activepieces/pieces-framework").BasicAuthProperty>;
4
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").BasicAuthProperty, {
5
- phone_number: import("@activepieces/pieces-framework").DropdownProperty<any, true, import("@activepieces/pieces-framework").BasicAuthProperty>;
6
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").BasicAuthProperty, {
7
- phone_number: import("@activepieces/pieces-framework").DropdownProperty<any, true, import("@activepieces/pieces-framework").BasicAuthProperty>;
8
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").BasicAuthProperty, {
9
- phone_number: import("@activepieces/pieces-framework").DropdownProperty<any, true, import("@activepieces/pieces-framework").BasicAuthProperty>;
10
- }>;
11
- //# sourceMappingURL=new-incoming-sms.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-incoming-sms.d.ts","sourceRoot":"","sources":["../../../../src/lib/trigger/new-incoming-sms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAUhF,eAAO,MAAM,oBAAoB;;;;;;;;EAuG/B,CAAC"}
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.twilioNewIncomingSms = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const common_1 = require("../common");
8
- const __1 = require("../..");
9
- exports.twilioNewIncomingSms = (0, pieces_framework_1.createTrigger)({
10
- auth: __1.twilioAuth,
11
- name: 'new_incoming_sms',
12
- displayName: 'New Incoming SMS',
13
- description: 'Triggers when a new SMS message is received',
14
- aiMetadata: {
15
- description: 'Fires when an inbound SMS message is received on the specified Twilio phone number. Each event represents one incoming text message with its sender, body, and metadata.',
16
- },
17
- props: {
18
- phone_number: common_1.twilioCommon.phone_number,
19
- },
20
- sampleData: {
21
- body: 'Hello',
22
- num_segments: '1',
23
- direction: 'inbound',
24
- from: '+12184191735',
25
- date_updated: 'Wed, 08 Feb 2023 01:40:51 +0000',
26
- price: null,
27
- error_message: null,
28
- uri: '/2010-04-01/Accounts/ACc0ea1238d61fe90d78a69a3de71d45619/Messages/SM8c3920d3f2ac481ba83e639a69dadd63.json',
29
- account_sid: 'ACc0ea716d61fe90d78a123a3de71d45619',
30
- num_media: '0',
31
- to: '+12184191735',
32
- date_created: 'Wed, 08 Feb 2023 01:40:50 +0000',
33
- status: 'failed',
34
- sid: 'SM8c3920d3f2ac481ba83e639a69dadd63',
35
- date_sent: 'Wed, 08 Feb 2023 01:40:51 +0000',
36
- messaging_service_sid: 'MG88e323e6a88ce67ba3bf12e1bcb7e0b8',
37
- error_code: 21211,
38
- price_unit: 'USD',
39
- api_version: '2010-04-01',
40
- subresource_uris: {
41
- media: '/2010-04-01/Accounts/ACc0ea716d61fe90d78a69a3de71d45619/Messages/SM8c3920d3f2ac481ba83e639a69dadd63/Media.json',
42
- feedback: '/2010-04-01/Accounts/ACc0ea716d61fe90d78a69a3de71d45619/Messages/SM8c3920d3f2ac481ba83e639a69dadd63/Feedback.json',
43
- },
44
- },
45
- // Twilio API only allows one webhook per phone number, so we need to poll
46
- type: pieces_framework_1.TriggerStrategy.POLLING,
47
- onEnable(context) {
48
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
- const { phone_number } = context.propsValue;
50
- const account_sid = context.auth.username;
51
- const auth_token = context.auth.password;
52
- const response = yield (0, common_1.callTwilioApi)(pieces_common_1.HttpMethod.GET, `Messages.json?PageSize=20&To=${phone_number}`, { account_sid, auth_token }, {});
53
- yield context.store.put('_new_incoming_sms_trigger', {
54
- lastMessageId: response.body.messages.length === 0
55
- ? null
56
- : response.body.messages[0].sid,
57
- });
58
- });
59
- },
60
- onDisable(context) {
61
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
62
- yield context.store.put('_new_incoming_sms_trigger', null);
63
- });
64
- },
65
- run(context) {
66
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
67
- const account_sid = context.auth.username;
68
- const auth_token = context.auth.password;
69
- const newMessages = [];
70
- const lastMessage = yield context.store.get('_new_incoming_sms_trigger');
71
- let currentUri = `2010-04-01/Accounts/${account_sid}/Messages.json?PageSize=20&To=${context.propsValue.phone_number}`;
72
- let firstMessageId = undefined;
73
- while (currentUri !== undefined && currentUri !== null) {
74
- const res = yield pieces_common_1.httpClient.sendRequest({
75
- method: pieces_common_1.HttpMethod.GET,
76
- url: `https://api.twilio.com/${currentUri}`,
77
- authentication: {
78
- type: pieces_common_1.AuthenticationType.BASIC,
79
- username: account_sid,
80
- password: auth_token,
81
- },
82
- });
83
- const messages = res.body.messages;
84
- if (!firstMessageId && messages.length > 0) {
85
- firstMessageId = messages[0].sid;
86
- }
87
- currentUri = res.body.next_page_uri;
88
- for (let i = 0; i < messages.length; i++) {
89
- const message = messages[i];
90
- if (message.sid === (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.lastMessageId)) {
91
- currentUri = null;
92
- break;
93
- }
94
- if (message.direction === 'inbound') {
95
- newMessages.push(message);
96
- }
97
- }
98
- }
99
- yield context.store.put('_new_incoming_sms_trigger', {
100
- lastMessageId: firstMessageId !== null && firstMessageId !== void 0 ? firstMessageId : lastMessage.lastMessageId,
101
- });
102
- return newMessages;
103
- });
104
- },
105
- });
106
- //# sourceMappingURL=new-incoming-sms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-incoming-sms.js","sourceRoot":"","sources":["../../../../src/lib/trigger/new-incoming-sms.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,+DAKqC;AACrC,sCAAwD;AACxD,6BAAmC;AAEtB,QAAA,oBAAoB,GAAG,IAAA,gCAAa,EAAC;IAChD,IAAI,EAAE,cAAU;IAChB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,6CAA6C;IAC1D,UAAU,EAAE;QACV,WAAW,EAAE,0KAA0K;KACxL;IACD,KAAK,EAAE;QACL,YAAY,EAAE,qBAAY,CAAC,YAAY;KACxC;IACD,UAAU,EAAE;QACV,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,GAAG;QACjB,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,cAAc;QACpB,YAAY,EAAE,iCAAiC;QAC/C,KAAK,EAAE,IAAI;QACX,aAAa,EAAE,IAAI;QACnB,GAAG,EAAE,2GAA2G;QAChH,WAAW,EAAE,qCAAqC;QAClD,SAAS,EAAE,GAAG;QACd,EAAE,EAAE,cAAc;QAClB,YAAY,EAAE,iCAAiC;QAC/C,MAAM,EAAE,QAAQ;QAChB,GAAG,EAAE,oCAAoC;QACzC,SAAS,EAAE,iCAAiC;QAC5C,qBAAqB,EAAE,oCAAoC;QAC3D,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,KAAK;QACjB,WAAW,EAAE,YAAY;QACzB,gBAAgB,EAAE;YAChB,KAAK,EACH,gHAAgH;YAClH,QAAQ,EACN,mHAAmH;SACtH;KACF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rB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const twilioNewPhoneNumber: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").BasicAuthProperty, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").BasicAuthProperty, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").BasicAuthProperty, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").BasicAuthProperty, {}>;
3
- //# sourceMappingURL=new-phone-number.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-phone-number.d.ts","sourceRoot":"","sources":["../../../../src/lib/trigger/new-phone-number.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EAChB,MAAM,gCAAgC,CAAC;AA8FxC,eAAO,MAAM,oBAAoB,sjBAiD/B,CAAC"}