@scopieflows/app-autocalls 0.1.0
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/README.md +7 -0
- package/package.json +29 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +61 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/add-lead.d.ts +8 -0
- package/src/lib/actions/add-lead.js +179 -0
- package/src/lib/actions/add-lead.js.map +1 -0
- package/src/lib/actions/campaign-control.d.ts +4 -0
- package/src/lib/actions/campaign-control.js +84 -0
- package/src/lib/actions/campaign-control.js.map +1 -0
- package/src/lib/actions/delete-lead.d.ts +3 -0
- package/src/lib/actions/delete-lead.js +70 -0
- package/src/lib/actions/delete-lead.js.map +1 -0
- package/src/lib/actions/make-phone-call.d.ts +5 -0
- package/src/lib/actions/make-phone-call.js +83 -0
- package/src/lib/actions/make-phone-call.js.map +1 -0
- package/src/lib/actions/send-sms.d.ts +5 -0
- package/src/lib/actions/send-sms.js +84 -0
- package/src/lib/actions/send-sms.js.map +1 -0
- package/src/lib/triggers/get-assistants.d.ts +14 -0
- package/src/lib/triggers/get-assistants.js +108 -0
- package/src/lib/triggers/get-assistants.js.map +1 -0
- package/src/lib/triggers/inbound-call.d.ts +10 -0
- package/src/lib/triggers/inbound-call.js +98 -0
- package/src/lib/triggers/inbound-call.js.map +1 -0
- package/src/lib/triggers/phone-call-ended.d.ts +10 -0
- package/src/lib/triggers/phone-call-ended.js +123 -0
- package/src/lib/triggers/phone-call-ended.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scopieflows/app-autocalls",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@sinclair/typebox": "0.34.11",
|
|
6
|
+
"ai": "^6.0.0",
|
|
7
|
+
"axios": "1.13.1",
|
|
8
|
+
"axios-retry": "4.4.1",
|
|
9
|
+
"dayjs": "1.11.9",
|
|
10
|
+
"deepmerge-ts": "7.1.0",
|
|
11
|
+
"form-data": "4.0.4",
|
|
12
|
+
"i18next": "23.13.0",
|
|
13
|
+
"mime-types": "2.1.35",
|
|
14
|
+
"nanoid": "3.3.8",
|
|
15
|
+
"semver": "7.6.0",
|
|
16
|
+
"socket.io-client": "4.8.1",
|
|
17
|
+
"zod": "4.1.13",
|
|
18
|
+
"@scopieflows/pieces-common": "0.11.2",
|
|
19
|
+
"@scopieflows/pieces-framework": "0.25.0",
|
|
20
|
+
"@scopieflows/shared": "0.33.0",
|
|
21
|
+
"tslib": "2.6.2"
|
|
22
|
+
},
|
|
23
|
+
"resolutions": {
|
|
24
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
25
|
+
},
|
|
26
|
+
"types": "./src/index.d.ts",
|
|
27
|
+
"main": "./src/index.js",
|
|
28
|
+
"type": "commonjs"
|
|
29
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const baseApiUrl = "https://app.autocalls.ai/";
|
|
2
|
+
export declare const autocallsAuth: import("@scopieflows/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
export declare const autocalls: import("@scopieflows/pieces-framework").Piece<import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.autocalls = exports.autocallsAuth = exports.baseApiUrl = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const make_phone_call_1 = require("./lib/actions/make-phone-call");
|
|
7
|
+
const phone_call_ended_1 = require("./lib/triggers/phone-call-ended");
|
|
8
|
+
const add_lead_1 = require("./lib/actions/add-lead");
|
|
9
|
+
const send_sms_1 = require("./lib/actions/send-sms");
|
|
10
|
+
const inbound_call_1 = require("./lib/triggers/inbound-call");
|
|
11
|
+
const get_assistants_1 = require("./lib/triggers/get-assistants");
|
|
12
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
13
|
+
const campaign_control_1 = require("./lib/actions/campaign-control");
|
|
14
|
+
const delete_lead_1 = require("./lib/actions/delete-lead");
|
|
15
|
+
exports.baseApiUrl = 'https://app.autocalls.ai/';
|
|
16
|
+
exports.autocallsAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
17
|
+
displayName: 'API Key',
|
|
18
|
+
description: 'Create an API key in your Autocalls account and paste the value here. Get API key here -> https://app.autocalls.ai.',
|
|
19
|
+
required: true,
|
|
20
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
21
|
+
try {
|
|
22
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
24
|
+
url: exports.baseApiUrl + 'api/user/me',
|
|
25
|
+
headers: {
|
|
26
|
+
'Authorization': `Bearer ${auth}`,
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Accept': 'application/json'
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (response.status === 200) {
|
|
32
|
+
return {
|
|
33
|
+
valid: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return {
|
|
38
|
+
valid: false,
|
|
39
|
+
error: 'Invalid API key or authentication failed'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
valid: false,
|
|
46
|
+
error: 'Failed to validate API key. Please check your API key and try again.'
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
exports.autocalls = (0, pieces_framework_1.createPiece)({
|
|
52
|
+
displayName: "Autocalls",
|
|
53
|
+
auth: exports.autocallsAuth,
|
|
54
|
+
minimumSupportedRelease: '0.36.1',
|
|
55
|
+
logoUrl: "/pieces/autocalls.png",
|
|
56
|
+
description: "Automate phone calls using our AI calling platform.",
|
|
57
|
+
authors: ['Zebi15'],
|
|
58
|
+
actions: [add_lead_1.addLead, send_sms_1.sendSms, campaign_control_1.campaignControl, make_phone_call_1.makePhoneCall, delete_lead_1.deleteLead],
|
|
59
|
+
triggers: [phone_call_ended_1.phoneCallEnded, get_assistants_1.getAssistants, inbound_call_1.inboundCall],
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/autocalls/src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,mEAA8D;AAC9D,sEAAiE;AACjE,qDAAiD;AACjD,qDAAiD;AACjD,8DAA0D;AAC1D,kEAA8D;AAC9D,8DAAoE;AACpE,qEAAiE;AACjE,2DAAuD;AAE1C,QAAA,UAAU,GAAG,2BAA2B,CAAC;AAEzC,QAAA,aAAa,GAAI,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,qHAAqH;IAClI,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,kBAAU,GAAG,aAAa;gBAC/B,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,IAAI,EAAE;oBACjC,cAAc,EAAE,kBAAkB;oBAClC,QAAQ,EAAE,kBAAkB;iBAC7B;aACF,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,OAAO;oBACL,KAAK,EAAE,IAAI;iBACZ,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,0CAA0C;iBAClD,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,sEAAsE;aAC9E,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAA;AAES,QAAA,SAAS,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,WAAW;IACxB,IAAI,EAAC,qBAAa;IAClB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,uBAAuB;IAChC,WAAW,EAAE,qDAAqD;IAClE,OAAO,EAAE,CAAC,QAAQ,CAAC;IACnB,OAAO,EAAE,CAAC,kBAAO,EAAC,kBAAO,EAAC,kCAAe,EAAC,+BAAa,EAAC,wBAAU,CAAC;IACnE,QAAQ,EAAE,CAAC,iCAAc,EAAC,8BAAa,EAAC,0BAAW,CAAC;CACrD,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const addLead: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
campaign: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
phone_number: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
variables: import("@scopieflows/pieces-framework").ObjectProperty<true>;
|
|
5
|
+
allow_dupplicate: import("@scopieflows/pieces-framework").CheckboxProperty<true>;
|
|
6
|
+
num_secondary_contacts: import("@scopieflows/pieces-framework").NumberProperty<false>;
|
|
7
|
+
secondary_contacts: import("@scopieflows/pieces-framework").DynamicProperties<false, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addLead = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
exports.addLead = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.autocallsAuth,
|
|
10
|
+
name: 'addLead',
|
|
11
|
+
displayName: 'Add lead to a campaign',
|
|
12
|
+
description: "Add lead to an outbound campaign, to be called by an assistant from our platform.",
|
|
13
|
+
props: {
|
|
14
|
+
campaign: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.autocallsAuth,
|
|
16
|
+
displayName: 'Campaign',
|
|
17
|
+
description: 'Select a campaign',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: ['auth'],
|
|
20
|
+
refreshOnSearch: false,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
if (!auth) {
|
|
23
|
+
return {
|
|
24
|
+
disabled: true,
|
|
25
|
+
placeholder: 'Please authenticate first',
|
|
26
|
+
options: []
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
31
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
32
|
+
url: __1.baseApiUrl + 'api/user/campaigns',
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: "Bearer " + auth,
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
'Accept': 'application/json'
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (res.status !== 200) {
|
|
40
|
+
return {
|
|
41
|
+
disabled: true,
|
|
42
|
+
placeholder: 'Error fetching campaigns',
|
|
43
|
+
options: [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else if (!res.body || res.body.length === 0) {
|
|
47
|
+
return {
|
|
48
|
+
disabled: true,
|
|
49
|
+
placeholder: 'No campaigns found. Create one first.',
|
|
50
|
+
options: [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
options: res.body.map((campaign) => ({
|
|
55
|
+
value: campaign.id,
|
|
56
|
+
label: campaign.name,
|
|
57
|
+
})),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return {
|
|
62
|
+
disabled: true,
|
|
63
|
+
placeholder: 'Failed to fetch campaigns',
|
|
64
|
+
options: [],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
69
|
+
phone_number: pieces_framework_1.Property.ShortText({
|
|
70
|
+
displayName: 'Customer phone number',
|
|
71
|
+
description: 'Enter the phone number of the customer',
|
|
72
|
+
required: true,
|
|
73
|
+
}),
|
|
74
|
+
variables: pieces_framework_1.Property.Object({
|
|
75
|
+
displayName: 'Variables',
|
|
76
|
+
description: 'Variables to pass to the assistant',
|
|
77
|
+
required: true,
|
|
78
|
+
defaultValue: {
|
|
79
|
+
customer_name: 'John',
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
allow_dupplicate: pieces_framework_1.Property.Checkbox({
|
|
83
|
+
displayName: 'Allow duplicates',
|
|
84
|
+
description: 'Allow the same phone number to be added to the campaign more than once',
|
|
85
|
+
required: true,
|
|
86
|
+
defaultValue: false
|
|
87
|
+
}),
|
|
88
|
+
num_secondary_contacts: pieces_framework_1.Property.Number({
|
|
89
|
+
displayName: 'Number of Secondary Contacts',
|
|
90
|
+
description: 'How many secondary contacts do you want to add?',
|
|
91
|
+
required: false,
|
|
92
|
+
defaultValue: 0,
|
|
93
|
+
}),
|
|
94
|
+
secondary_contacts: pieces_framework_1.Property.DynamicProperties({
|
|
95
|
+
auth: __1.autocallsAuth,
|
|
96
|
+
displayName: 'Secondary Contacts',
|
|
97
|
+
description: 'Add secondary contacts for this lead. Each contact can have its own phone number and variables.',
|
|
98
|
+
required: false,
|
|
99
|
+
refreshers: ['num_secondary_contacts'],
|
|
100
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ num_secondary_contacts }) {
|
|
101
|
+
const contacts = {};
|
|
102
|
+
const numContacts = Number(num_secondary_contacts) || 0;
|
|
103
|
+
// Generate fields based on the number specified
|
|
104
|
+
for (let i = 1; i <= numContacts && i <= 10; i++) {
|
|
105
|
+
contacts[`contact_${i}_phone`] = pieces_framework_1.Property.ShortText({
|
|
106
|
+
displayName: `Contact ${i} - Phone Number`,
|
|
107
|
+
description: `Phone number for secondary contact ${i}`,
|
|
108
|
+
required: true,
|
|
109
|
+
});
|
|
110
|
+
contacts[`contact_${i}_variables`] = pieces_framework_1.Property.Object({
|
|
111
|
+
displayName: `Contact ${i} - Variables`,
|
|
112
|
+
description: `Variables for secondary contact ${i} as key-value pairs`,
|
|
113
|
+
required: false,
|
|
114
|
+
defaultValue: {
|
|
115
|
+
customer_name: 'John',
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return contacts;
|
|
120
|
+
}),
|
|
121
|
+
})
|
|
122
|
+
},
|
|
123
|
+
run(context) {
|
|
124
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
if (!context.auth) {
|
|
126
|
+
throw new Error('Authentication is required');
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const body = {
|
|
130
|
+
campaign_id: context.propsValue['campaign'],
|
|
131
|
+
phone_number: context.propsValue['phone_number'],
|
|
132
|
+
variables: context.propsValue['variables'],
|
|
133
|
+
allow_dupplicate: context.propsValue['allow_dupplicate'],
|
|
134
|
+
};
|
|
135
|
+
// Add secondary contacts if provided
|
|
136
|
+
if (context.propsValue['secondary_contacts']) {
|
|
137
|
+
const secondaryContactsData = context.propsValue['secondary_contacts'];
|
|
138
|
+
const numContacts = Number(context.propsValue['num_secondary_contacts']) || 0;
|
|
139
|
+
const secondaryContacts = [];
|
|
140
|
+
// Process the specified number of contacts
|
|
141
|
+
for (let i = 1; i <= numContacts && i <= 10; i++) {
|
|
142
|
+
const phoneNumber = secondaryContactsData[`contact_${i}_phone`];
|
|
143
|
+
const variables = secondaryContactsData[`contact_${i}_variables`];
|
|
144
|
+
// Only add contact if phone number is provided
|
|
145
|
+
if (phoneNumber && phoneNumber.trim() !== '') {
|
|
146
|
+
secondaryContacts.push({
|
|
147
|
+
phone_number: phoneNumber,
|
|
148
|
+
variables: variables || {
|
|
149
|
+
customer_name: '',
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (secondaryContacts.length > 0) {
|
|
155
|
+
body.secondary_contacts = secondaryContacts;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
159
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
160
|
+
url: __1.baseApiUrl + 'api/user/lead',
|
|
161
|
+
body: body,
|
|
162
|
+
headers: {
|
|
163
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
164
|
+
'Content-Type': 'application/json',
|
|
165
|
+
'Accept': 'application/json'
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
if (res.status !== 200) {
|
|
169
|
+
throw new Error(`Failed to add lead: ${res.status}`);
|
|
170
|
+
}
|
|
171
|
+
return res.body;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
throw new Error(`Failed to add lead: ${error}`);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=add-lead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-lead.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/actions/add-lead.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,8DAAoE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C,WAAW;wBACnD,cAAc,EAAE,kBAAkB;wBAClC,QAAQ,EAAE,kBAAkB;qBAC7B;iBACF,CAAC,CAAC;gBAEH,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBACvB,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;gBACvD,CAAC;gBAED,OAAO,GAAG,CAAC,IAAI,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const campaignControl: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
campaign: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
action: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, true>;
|
|
4
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.campaignControl = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
exports.campaignControl = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.autocallsAuth,
|
|
10
|
+
name: 'campaignControl',
|
|
11
|
+
displayName: 'Start/Stop Campaign',
|
|
12
|
+
description: "Start or stop an outbound campaign from our platform.",
|
|
13
|
+
props: {
|
|
14
|
+
campaign: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.autocallsAuth,
|
|
16
|
+
displayName: 'Campaign',
|
|
17
|
+
description: 'Select a campaign',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: ['auth'],
|
|
20
|
+
refreshOnSearch: false,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
24
|
+
url: __1.baseApiUrl + 'api/user/campaigns',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + (auth === null || auth === void 0 ? void 0 : auth.secret_text),
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Accept': 'application/json'
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (res.status !== 200) {
|
|
32
|
+
return {
|
|
33
|
+
disabled: true,
|
|
34
|
+
placeholder: 'Error fetching campaigns',
|
|
35
|
+
options: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else if (res.body.length === 0) {
|
|
39
|
+
return {
|
|
40
|
+
disabled: true,
|
|
41
|
+
placeholder: 'No campaigns found. Create one first.',
|
|
42
|
+
options: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
options: res.body.map((campaign) => ({
|
|
47
|
+
value: campaign.id,
|
|
48
|
+
label: campaign.name,
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
action: pieces_framework_1.Property.StaticDropdown({
|
|
54
|
+
displayName: 'Action',
|
|
55
|
+
description: 'Select action to perform on the campaign',
|
|
56
|
+
required: true,
|
|
57
|
+
options: {
|
|
58
|
+
options: [
|
|
59
|
+
{ label: 'Start Campaign', value: 'start' },
|
|
60
|
+
{ label: 'Stop Campaign', value: 'stop' }
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
run(context) {
|
|
66
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
68
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
69
|
+
url: __1.baseApiUrl + 'api/user/campaigns/update-status',
|
|
70
|
+
body: {
|
|
71
|
+
campaign_id: context.propsValue['campaign'],
|
|
72
|
+
action: context.propsValue['action'],
|
|
73
|
+
},
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
76
|
+
'Content-Type': 'application/json',
|
|
77
|
+
'Accept': 'application/json'
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return res.body;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=campaign-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign-control.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/actions/campaign-control.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,8DAAoE;AACpE,6BAAkD;AAErC,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAC,iBAAa;IAClB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,uDAAuD;IACpE,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,IAAI,EAAE,iBAAa;YACnB,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,mBAAmB;YAChC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,eAAe,EAAE,KAAK;YACtB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACtB,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;oBACvC,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,cAAU,GAAG,oBAAoB;oBACtC,OA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CAAkC;gBACpD,IAAI,EAAE;oBACJ,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC;oBAC3C,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;iBACrC;gBACD,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW;oBACnD,cAAc,EAAE,kBAAkB;oBAClC,QAAQ,EAAE,kBAAkB;iBAC7B;aACF,CAAC,CAAC;YACH,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const deleteLead: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
lead: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
}>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteLead = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
exports.deleteLead = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.autocallsAuth,
|
|
10
|
+
name: 'deleteLead',
|
|
11
|
+
displayName: 'Delete Lead',
|
|
12
|
+
description: "Delete a lead from a campaign.",
|
|
13
|
+
props: {
|
|
14
|
+
lead: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.autocallsAuth,
|
|
16
|
+
displayName: 'Lead',
|
|
17
|
+
description: 'Select a lead to delete',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: ['auth'],
|
|
20
|
+
refreshOnSearch: false,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
24
|
+
url: __1.baseApiUrl + 'api/user/leads',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + auth,
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Accept': 'application/json'
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (res.status !== 200) {
|
|
32
|
+
return {
|
|
33
|
+
disabled: true,
|
|
34
|
+
placeholder: 'Error fetching leads',
|
|
35
|
+
options: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else if (res.body.length === 0) {
|
|
39
|
+
return {
|
|
40
|
+
disabled: true,
|
|
41
|
+
placeholder: 'No leads found.',
|
|
42
|
+
options: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
options: res.body.map((lead) => ({
|
|
47
|
+
value: lead.id,
|
|
48
|
+
label: `${lead.phone_number} - ${lead.campaign.name}`,
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
run(context) {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const leadId = context.propsValue['lead'];
|
|
57
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
58
|
+
method: pieces_common_1.HttpMethod.DELETE,
|
|
59
|
+
url: __1.baseApiUrl + 'api/user/leads/' + leadId,
|
|
60
|
+
headers: {
|
|
61
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
'Accept': 'application/json'
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return res.body;
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=delete-lead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-lead.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/actions/delete-lead.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,8DAAoE;AACpE,6BAAkD;AAErC,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAC,iBAAa;IAClB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,gCAAgC;IAC7C,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,IAAI,EAAE,iBAAa;YACnB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,eAAe,EAAE,KAAK;YACtB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACtB,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;oBACvC,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,cAAU,GAAG,gBAAgB;oBAClC,OAAO,EAAE;wBACP,aAAa,EAAE,SAAS,GAAG,IAAI;wBAC/B,cAAc,EAAE,kBAAkB;wBAClC,QAAQ,EAAE,kBAAkB;qBAC7B;iBACF,CAAC,CAAC;gBAEH,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBACvB,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,sBAAsB;wBACnC,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;qBAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACjC,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,iBAAiB;wBAC9B,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBAED,OAAO;oBACL,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;wBACpC,KAAK,EAAE,IAAI,CAAC,EAAE;wBACd,KAAK,EAAE,GAAG,IAAI,CAAC,YAAY,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;qBACtD,CAAC,CAAC;iBACJ,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAE1C,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAW;gBACjD,MAAM,EAAE,0BAAU,CAAC,MAAM;gBACzB,GAAG,EAAE,cAAU,GAAG,iBAAiB,GAAG,MAAM;gBAC5C,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW;oBACnD,cAAc,EAAE,kBAAkB;oBAClC,QAAQ,EAAE,kBAAkB;iBAC7B;aACF,CAAC,CAAC;YACH,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const makePhoneCall: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
phone_number: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
variables: import("@scopieflows/pieces-framework").ObjectProperty<true>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePhoneCall = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
exports.makePhoneCall = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.autocallsAuth,
|
|
10
|
+
name: 'makePhoneCall',
|
|
11
|
+
displayName: 'Make Phone Call',
|
|
12
|
+
description: "Call a customer by it's phone number using an assistant from our platform.",
|
|
13
|
+
props: {
|
|
14
|
+
assistant: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.autocallsAuth,
|
|
16
|
+
displayName: 'Assistant',
|
|
17
|
+
description: 'Select an assistant',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: ['auth'],
|
|
20
|
+
refreshOnSearch: false,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
24
|
+
url: __1.baseApiUrl + 'api/user/assistants/outbound',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + (auth === null || auth === void 0 ? void 0 : auth.secret_text),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (res.status !== 200) {
|
|
30
|
+
return {
|
|
31
|
+
disabled: true,
|
|
32
|
+
placeholder: 'Error fetching assistants',
|
|
33
|
+
options: [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
else if (res.body.length === 0) {
|
|
37
|
+
return {
|
|
38
|
+
disabled: true,
|
|
39
|
+
placeholder: 'No outbound assistants found. Create one first.',
|
|
40
|
+
options: [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
options: res.body.map((assistant) => ({
|
|
45
|
+
value: assistant.id,
|
|
46
|
+
label: assistant.name,
|
|
47
|
+
})),
|
|
48
|
+
};
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
phone_number: pieces_framework_1.Property.ShortText({
|
|
52
|
+
displayName: 'Customer phone number',
|
|
53
|
+
description: 'Enter the phone number of the customer',
|
|
54
|
+
required: true,
|
|
55
|
+
}),
|
|
56
|
+
variables: pieces_framework_1.Property.Object({
|
|
57
|
+
displayName: 'Variables',
|
|
58
|
+
description: 'Variables to pass to the assistant',
|
|
59
|
+
required: true,
|
|
60
|
+
defaultValue: {
|
|
61
|
+
customer_name: 'John',
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
run(context) {
|
|
66
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
68
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
69
|
+
url: __1.baseApiUrl + 'api/user/make_call',
|
|
70
|
+
body: {
|
|
71
|
+
assistant_id: context.propsValue['assistant'],
|
|
72
|
+
phone_number: context.propsValue['phone_number'],
|
|
73
|
+
variables: context.propsValue['variables'],
|
|
74
|
+
},
|
|
75
|
+
headers: {
|
|
76
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
return res.body;
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=make-phone-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-phone-call.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/actions/make-phone-call.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,8DAAoE;AACpE,6BAAkD;AAErC,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAC,iBAAa;IAClB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,4EAA4E;IACzF,KAAK,EAAE;QACL,SAAS,EAAE,2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AAC;QAEF,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,oCAAoC;YACjD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE;gBACZ,aAAa,EAAE,MAAM;aACtB;SACF,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAW;gBACjD,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,cAAU,GAAG,oBAAoB;gBACtC,IAAI,EAAE;oBACJ,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;oBAC7C,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC;oBAChD,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;iBAC3C;gBACD,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW;iBACpD;aACF,CAAC,CAAC;YACH,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const sendSms: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
from: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
to: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
body: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendSms = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
exports.sendSms = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.autocallsAuth,
|
|
10
|
+
name: 'sendSms',
|
|
11
|
+
displayName: 'Send SMS to Customer',
|
|
12
|
+
description: "Send an SMS to a customer using a phone number from our platform.",
|
|
13
|
+
props: {
|
|
14
|
+
from: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.autocallsAuth,
|
|
16
|
+
displayName: 'From phone number',
|
|
17
|
+
description: 'Select an SMS capable phone number to send the SMS from',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: ['auth'],
|
|
20
|
+
refreshOnSearch: false,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
24
|
+
url: __1.baseApiUrl + 'api/user/phone-numbers',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + (auth === null || auth === void 0 ? void 0 : auth.secret_text),
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Accept': 'application/json'
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (res.status !== 200) {
|
|
32
|
+
return {
|
|
33
|
+
disabled: true,
|
|
34
|
+
placeholder: 'Error fetching phone numbers',
|
|
35
|
+
options: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else if (res.body.length === 0) {
|
|
39
|
+
return {
|
|
40
|
+
disabled: true,
|
|
41
|
+
placeholder: 'No phone numbers found. Purchase an SMS capable phone number first.',
|
|
42
|
+
options: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
options: res.body.map((phoneNumber) => ({
|
|
47
|
+
value: phoneNumber.id,
|
|
48
|
+
label: phoneNumber.phone_number,
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
to: pieces_framework_1.Property.ShortText({
|
|
54
|
+
displayName: 'Customer phone number',
|
|
55
|
+
description: 'Enter the phone number of the customer',
|
|
56
|
+
required: true,
|
|
57
|
+
}),
|
|
58
|
+
body: pieces_framework_1.Property.ShortText({
|
|
59
|
+
displayName: 'Text message',
|
|
60
|
+
description: 'Enter the text message to send to the customer (max 300 characters)',
|
|
61
|
+
required: true,
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
run(context) {
|
|
65
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
67
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
68
|
+
url: __1.baseApiUrl + 'api/user/sms',
|
|
69
|
+
body: {
|
|
70
|
+
from: context.propsValue['from'],
|
|
71
|
+
to: context.propsValue['to'],
|
|
72
|
+
body: context.propsValue['body'],
|
|
73
|
+
},
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
76
|
+
'Content-Type': 'application/json',
|
|
77
|
+
'Accept': 'application/json'
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return res.body;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=send-sms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-sms.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/actions/send-sms.ts"],"names":[],"mappings":";;;;AAAA,oEAAsE;AACtE,8DAAoE;AACpE,6BAAkD;AAErC,QAAA,OAAO,GAAG,IAAA,+BAAY,EAAC;IAClC,IAAI,EAAC,iBAAa;IAClB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,mEAAmE;IAChF,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC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AW,EAAE,wCAAwC;YACrD,QAAQ,EAAE,IAAI;SACf,CAAC;QAEF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,qEAAqE;YAClF,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAW;gBACjD,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,cAAU,GAAG,cAAc;gBAChC,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;oBAChC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;oBAC5B,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;iBACjC;gBACD,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW;oBACnD,cAAc,EAAE,kBAAkB;oBAClC,QAAQ,EAAE,kBAAkB;iBAC7B;aACF,CAAC,CAAC;YACH,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@scopieflows/pieces-framework';
|
|
2
|
+
export declare const getAssistants: import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
start: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
4
|
+
end: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
5
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
6
|
+
start: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
7
|
+
end: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
8
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
start: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
10
|
+
end: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
11
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
12
|
+
start: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
13
|
+
end: import("@scopieflows/pieces-framework").DateTimeProperty<false>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAssistants = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
9
|
+
const polling = {
|
|
10
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
11
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue }) {
|
|
12
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
13
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
14
|
+
url: __1.baseApiUrl + 'api/user/assistants',
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: 'Bearer ' + auth.secret_text,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
if (res.status !== 200) {
|
|
20
|
+
throw new Error(`Failed to fetch assistants. Status: ${res.status}`);
|
|
21
|
+
}
|
|
22
|
+
const assistants = res.body || [];
|
|
23
|
+
const filteredAssistants = assistants.filter((assistant) => {
|
|
24
|
+
const assistantDate = assistant.created_at
|
|
25
|
+
? (0, dayjs_1.default)(assistant.created_at)
|
|
26
|
+
: (0, dayjs_1.default)(assistant.updated_at);
|
|
27
|
+
// Check start date filter
|
|
28
|
+
if (propsValue['start']) {
|
|
29
|
+
const startDate = (0, dayjs_1.default)(propsValue['start']);
|
|
30
|
+
if (assistantDate.isBefore(startDate)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Check end date filter
|
|
35
|
+
if (propsValue['end']) {
|
|
36
|
+
const endDate = (0, dayjs_1.default)(propsValue['end']);
|
|
37
|
+
if (assistantDate.isAfter(endDate)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
43
|
+
return filteredAssistants.map((assistant) => {
|
|
44
|
+
const assistantDate = assistant.created_at
|
|
45
|
+
? (0, dayjs_1.default)(assistant.created_at)
|
|
46
|
+
: (0, dayjs_1.default)(assistant.updated_at);
|
|
47
|
+
return {
|
|
48
|
+
epochMilliSeconds: assistantDate.valueOf(),
|
|
49
|
+
data: assistant,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
exports.getAssistants = (0, pieces_framework_1.createTrigger)({
|
|
55
|
+
auth: __1.autocallsAuth,
|
|
56
|
+
name: 'getAssistants',
|
|
57
|
+
displayName: 'Updated Assistant',
|
|
58
|
+
description: 'Triggers when assistants are fetched or updated in your Autocalls account.',
|
|
59
|
+
props: {
|
|
60
|
+
start: pieces_framework_1.Property.DateTime({
|
|
61
|
+
displayName: 'Start Date',
|
|
62
|
+
description: 'Filter assistants created after this date. Example: 2024-01-15T10:30:00Z',
|
|
63
|
+
required: false,
|
|
64
|
+
}),
|
|
65
|
+
end: pieces_framework_1.Property.DateTime({
|
|
66
|
+
displayName: 'End Date',
|
|
67
|
+
description: 'Filter assistants created before this date. Example: 2024-12-31T23:59:59Z',
|
|
68
|
+
required: false,
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
sampleData: {
|
|
72
|
+
id: "assistant_123",
|
|
73
|
+
name: "Customer Support Assistant",
|
|
74
|
+
description: "Handles customer inquiries and support requests",
|
|
75
|
+
status: "active",
|
|
76
|
+
created_at: "2024-01-15T10:30:00Z",
|
|
77
|
+
updated_at: "2024-01-15T14:20:00Z",
|
|
78
|
+
settings: {
|
|
79
|
+
voice: "en-US-female",
|
|
80
|
+
language: "en-US",
|
|
81
|
+
max_duration: 300
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
85
|
+
test(context) {
|
|
86
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
onEnable(context) {
|
|
91
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const { store, auth, propsValue } = context;
|
|
93
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, { store, auth, propsValue });
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
onDisable(context) {
|
|
97
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const { store, auth, propsValue } = context;
|
|
99
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, { store, auth, propsValue });
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
run(context) {
|
|
103
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=get-assistants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-assistants.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/triggers/get-assistants.ts"],"names":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,QAAQ,EAAE,OAAO;YACjB,YAAY,EAAE,GAAG;SACpB;KACJ;IACL,IAAI,EAAE,kCAAe,CAAC,OAAO;IACvB,IAAI,CAAC,OAAO;;YACd,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;KAAA;IACK,QAAQ,CAAC,OAAO;;YAClB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;YAC5C,MAAM,6BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QACvE,CAAC;KAAA;IACK,SAAS,CAAC,OAAO;;YACnB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;YAC5C,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QACxE,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACb,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;KAAA;CACA,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@scopieflows/pieces-framework';
|
|
2
|
+
export declare const inboundCall: import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
5
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
6
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
7
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
8
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inboundCall = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
exports.inboundCall = (0, pieces_framework_1.createTrigger)({
|
|
9
|
+
auth: __1.autocallsAuth,
|
|
10
|
+
name: 'inboundCall',
|
|
11
|
+
displayName: 'Inbound Call',
|
|
12
|
+
description: 'Triggers for variables before connecting an inbound call.',
|
|
13
|
+
props: {
|
|
14
|
+
assistant: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.autocallsAuth,
|
|
16
|
+
displayName: 'Assistant',
|
|
17
|
+
description: 'Select an assistant',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: ['auth'],
|
|
20
|
+
refreshOnSearch: false,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
24
|
+
url: __1.baseApiUrl + 'api/user/assistants',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + (auth === null || auth === void 0 ? void 0 : auth.secret_text),
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Accept': 'application/json'
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (res.status !== 200) {
|
|
32
|
+
return {
|
|
33
|
+
disabled: true,
|
|
34
|
+
placeholder: 'Error fetching assistants',
|
|
35
|
+
options: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else if (res.body.length === 0) {
|
|
39
|
+
return {
|
|
40
|
+
disabled: true,
|
|
41
|
+
placeholder: 'No assistants found. Create one first.',
|
|
42
|
+
options: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
options: res.body.map((assistant) => ({
|
|
47
|
+
value: assistant.id,
|
|
48
|
+
label: assistant.name,
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
sampleData: {
|
|
55
|
+
customer_phone: '+16380991171',
|
|
56
|
+
assistant_phone: '+16380991171',
|
|
57
|
+
},
|
|
58
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
59
|
+
onEnable(context) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
62
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
63
|
+
url: __1.baseApiUrl + 'api/user/assistants/enable-inbound-webhook',
|
|
64
|
+
body: {
|
|
65
|
+
assistant_id: context.propsValue['assistant'],
|
|
66
|
+
webhook_url: context.webhookUrl,
|
|
67
|
+
},
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
'Accept': 'application/json'
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
onDisable(context) {
|
|
77
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
79
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
80
|
+
url: __1.baseApiUrl + 'api/user/assistants/disable-inbound-webhook',
|
|
81
|
+
body: {
|
|
82
|
+
assistant_id: context.propsValue['assistant'],
|
|
83
|
+
},
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
86
|
+
'Content-Type': 'application/json',
|
|
87
|
+
'Accept': 'application/json'
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
run(context) {
|
|
93
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
return [context.payload.body];
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=inbound-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbound-call.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/triggers/inbound-call.ts"],"names":[],"mappings":";;;;AAAA,oEAAyF;AACzF,8DAAoE;AACpE,6BAAkD;AAErC,QAAA,WAAW,GAAG,IAAA,gCAAa,EAAC;IACrC,IAAI,EAAC,iBAAa;IAClB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,2DAA2D;IACxE,KAAK,EAAE;QACH,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,IAAI,EAAE,iBAAa;YACnB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,qBAAqB;YAClC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,eAAe,EAAE,KAAK;YACtB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACpB,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,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;iBAClC;gBACD,OAAO,EAAE;oBACL,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW;oBACnD,cAAc,EAAE,kBAAkB;oBAClC,QAAQ,EAAE,kBAAkB;iBAC/B;aACJ,CAAC,CAAC;QACP,CAAC;KAAA;IACK,SAAS,CAAC,OAAO;;YACnB,MAAM,0BAAU,CAAC,WAAW,CAAC;gBACzB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,cAAU,GAAG,6CAA6C;gBAC/D,IAAI,EAAE;oBACF,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;iBAChD;gBACD,OAAO,EAAE;oBACL,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW;oBACnD,cAAc,EAAE,kBAAkB;oBAClC,QAAQ,EAAE,kBAAkB;iBAC/B;aACJ,CAAC,CAAC;QACP,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACb,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC;KAAA;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@scopieflows/pieces-framework';
|
|
2
|
+
export declare const phoneCallEnded: import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
4
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
5
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
6
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
7
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
8
|
+
}> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@scopieflows/pieces-framework").SecretTextProperty<true>, {
|
|
9
|
+
assistant: import("@scopieflows/pieces-framework").DropdownProperty<any, true, import("@scopieflows/pieces-framework").SecretTextProperty<true>>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.phoneCallEnded = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
exports.phoneCallEnded = (0, pieces_framework_1.createTrigger)({
|
|
9
|
+
auth: __1.autocallsAuth,
|
|
10
|
+
name: 'phoneCallEnded',
|
|
11
|
+
displayName: 'Phone Call Ended',
|
|
12
|
+
description: 'Triggers when a phone call ends, with extracted variables.',
|
|
13
|
+
props: {
|
|
14
|
+
assistant: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.autocallsAuth,
|
|
16
|
+
displayName: 'Assistant',
|
|
17
|
+
description: 'Select an assistant',
|
|
18
|
+
required: true,
|
|
19
|
+
refreshers: ['auth'],
|
|
20
|
+
refreshOnSearch: false,
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
24
|
+
url: __1.baseApiUrl + 'api/user/assistants',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + (auth === null || auth === void 0 ? void 0 : auth.secret_text),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (res.status !== 200) {
|
|
30
|
+
return {
|
|
31
|
+
disabled: true,
|
|
32
|
+
placeholder: 'Error fetching assistants',
|
|
33
|
+
options: [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
else if (res.body.length === 0) {
|
|
37
|
+
return {
|
|
38
|
+
disabled: true,
|
|
39
|
+
placeholder: 'No assistants found. Create one first.',
|
|
40
|
+
options: [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
options: res.body.map((assistant) => ({
|
|
45
|
+
value: assistant.id,
|
|
46
|
+
label: assistant.name,
|
|
47
|
+
})),
|
|
48
|
+
};
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
sampleData: {
|
|
53
|
+
customer_phone: '+16380991171',
|
|
54
|
+
assistant_phone: '+16380991171',
|
|
55
|
+
duration: 120,
|
|
56
|
+
status: 'completed',
|
|
57
|
+
extracted_variables: {
|
|
58
|
+
status: false,
|
|
59
|
+
summary: 'Call ended without clear objective being met.'
|
|
60
|
+
},
|
|
61
|
+
input_variables: {
|
|
62
|
+
customer_name: 'John'
|
|
63
|
+
},
|
|
64
|
+
transcript: [
|
|
65
|
+
{
|
|
66
|
+
sender: 'bot',
|
|
67
|
+
timestamp: 1722347063.574402,
|
|
68
|
+
text: 'Hi! How are you, John?'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
sender: 'human',
|
|
72
|
+
timestamp: 1722347068.886166,
|
|
73
|
+
text: 'Im fine. How about you?'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
sender: 'bot',
|
|
77
|
+
timestamp: 1722347069.76683,
|
|
78
|
+
text: 'Im doing well, thank you for asking.'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
sender: 'bot',
|
|
82
|
+
timestamp: 1722347071.577889,
|
|
83
|
+
text: 'How can I assist you today?'
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
88
|
+
onEnable(context) {
|
|
89
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
91
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
92
|
+
url: __1.baseApiUrl + 'api/user/assistants/enable-webhook',
|
|
93
|
+
body: {
|
|
94
|
+
assistant_id: context.propsValue['assistant'],
|
|
95
|
+
webhook_url: context.webhookUrl,
|
|
96
|
+
},
|
|
97
|
+
headers: {
|
|
98
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
onDisable(context) {
|
|
104
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
106
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
107
|
+
url: __1.baseApiUrl + 'api/user/assistants/disable-webhook',
|
|
108
|
+
body: {
|
|
109
|
+
assistant_id: context.propsValue['assistant'],
|
|
110
|
+
},
|
|
111
|
+
headers: {
|
|
112
|
+
Authorization: "Bearer " + context.auth.secret_text,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
run(context) {
|
|
118
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
return [context.payload.body];
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=phone-call-ended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-call-ended.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/autocalls/src/lib/triggers/phone-call-ended.ts"],"names":[],"mappings":";;;;AAAA,oEAAyF;AACzF,8DAAoE;AACpE,6BAAkD;AAErC,QAAA,cAAc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