piece-osvi-ai 0.0.1
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/package.json +16 -0
- package/src/index.d.ts +3 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +34 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/make-call.d.ts +11 -0
- package/src/lib/actions/make-call.d.ts.map +1 -0
- package/src/lib/actions/make-call.js +105 -0
- package/src/lib/actions/make-call.js.map +1 -0
- package/src/lib/auth.d.ts +6 -0
- package/src/lib/auth.d.ts.map +1 -0
- package/src/lib/auth.js +14 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +14 -0
- package/src/lib/common/client.d.ts.map +1 -0
- package/src/lib/common/client.js +25 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/props.d.ts +5 -0
- package/src/lib/common/props.d.ts.map +1 -0
- package/src/lib/common/props.js +92 -0
- package/src/lib/common/props.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "piece-osvi-ai",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@activepieces/pieces-common": "0.12.3",
|
|
8
|
+
"@activepieces/pieces-framework": "0.29.0",
|
|
9
|
+
"@activepieces/shared": "0.79.0",
|
|
10
|
+
"tslib": "2.6.2"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
14
|
+
"lint": "eslint 'src/**/*.ts'"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,MAAM,mHAmBV,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.osviAi = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const make_call_1 = require("./lib/actions/make-call");
|
|
9
|
+
const auth_1 = require("./lib/auth");
|
|
10
|
+
const client_1 = require("./lib/common/client");
|
|
11
|
+
const osviAi = (0, pieces_framework_1.createPiece)({
|
|
12
|
+
displayName: 'Osvi AI',
|
|
13
|
+
description: 'AI phone calling platform for outbound voice agents.',
|
|
14
|
+
minimumSupportedRelease: '0.30.0',
|
|
15
|
+
logoUrl: '/pieces/osvi-ai.svg',
|
|
16
|
+
categories: [shared_1.PieceCategory.COMMUNICATION],
|
|
17
|
+
auth: auth_1.osviAuth,
|
|
18
|
+
authors: [],
|
|
19
|
+
actions: [
|
|
20
|
+
make_call_1.makeCall,
|
|
21
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
22
|
+
baseUrl: () => client_1.osviClient.baseUrl,
|
|
23
|
+
auth: auth_1.osviAuth,
|
|
24
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
return ({
|
|
26
|
+
'API-Token': auth.secret_text,
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
triggers: [],
|
|
32
|
+
});
|
|
33
|
+
exports.osviAi = osviAi;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAA6D;AAC7D,iDAAqD;AACrD,uDAAmD;AACnD,qCAAsC;AACtC,gDAAiD;AAEjD,MAAM,MAAM,GAAG,IAAA,8BAAW,EAAC;IACzB,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,sDAAsD;IACnE,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,qBAAqB;IAC9B,UAAU,EAAE,CAAC,sBAAa,CAAC,aAAa,CAAC;IACzC,IAAI,EAAE,eAAQ;IACd,OAAO,EAAE,EAAE;IACX,OAAO,EAAE;QACP,oBAAQ;QACR,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAU,CAAC,OAAO;YACjC,IAAI,EAAE,eAAQ;YACd,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,WAAW,EAAE,IAAI,CAAC,WAAW;iBAC9B,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEM,wBAAM"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const makeCall: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
agentId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
|
|
3
|
+
phoneNumber: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
countryCode: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
language: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
6
|
+
personName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
initialGreeting: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
8
|
+
additionalData: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
9
|
+
}>;
|
|
10
|
+
export { makeCall };
|
|
11
|
+
//# sourceMappingURL=make-call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-call.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/make-call.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,QAAQ;;;;;;;;EAmEZ,CAAC;AAuFH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCall = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const props_1 = require("../common/props");
|
|
10
|
+
const makeCall = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: auth_1.osviAuth,
|
|
12
|
+
name: 'make_call',
|
|
13
|
+
displayName: 'Make Call',
|
|
14
|
+
description: 'Trigger an Osvi agent to place an outbound phone call.',
|
|
15
|
+
props: {
|
|
16
|
+
agentId: props_1.osviProps.agentId,
|
|
17
|
+
phoneNumber: pieces_framework_1.Property.ShortText({
|
|
18
|
+
displayName: 'Phone Number',
|
|
19
|
+
description: 'Recipient phone number without the country code, for example 9876543210.',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
countryCode: pieces_framework_1.Property.ShortText({
|
|
23
|
+
displayName: 'Country Code',
|
|
24
|
+
description: 'Two-letter country code for the recipient, for example IN or US.',
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
27
|
+
language: pieces_framework_1.Property.StaticDropdown({
|
|
28
|
+
displayName: 'Language',
|
|
29
|
+
description: 'Language the Osvi agent should use for this call. Indian language support must also be enabled by the Osvi API.',
|
|
30
|
+
required: false,
|
|
31
|
+
options: {
|
|
32
|
+
options: [
|
|
33
|
+
{ label: 'Hindi', value: 'hi' },
|
|
34
|
+
{ label: 'English', value: 'en' },
|
|
35
|
+
{ label: 'Bengali', value: 'bn' },
|
|
36
|
+
{ label: 'Telugu', value: 'te' },
|
|
37
|
+
{ label: 'Marathi', value: 'mr' },
|
|
38
|
+
{ label: 'Tamil', value: 'ta' },
|
|
39
|
+
{ label: 'Gujarati', value: 'gu' },
|
|
40
|
+
{ label: 'Kannada', value: 'kn' },
|
|
41
|
+
{ label: 'Malayalam', value: 'ml' },
|
|
42
|
+
{ label: 'Punjabi', value: 'pa' },
|
|
43
|
+
{ label: 'Urdu', value: 'ur' },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
personName: pieces_framework_1.Property.ShortText({
|
|
48
|
+
displayName: 'Person Name',
|
|
49
|
+
description: 'Name of the person the agent is calling.',
|
|
50
|
+
required: false,
|
|
51
|
+
}),
|
|
52
|
+
initialGreeting: pieces_framework_1.Property.LongText({
|
|
53
|
+
displayName: 'Initial Greeting',
|
|
54
|
+
description: 'Opening line the agent should say when the call connects. Leave blank to use the agent default.',
|
|
55
|
+
required: false,
|
|
56
|
+
}),
|
|
57
|
+
additionalData: pieces_framework_1.Property.Object({
|
|
58
|
+
displayName: 'Additional Data',
|
|
59
|
+
description: 'Map extra variables to send to Osvi for this call, such as lead source, CRM record ID, appointment time, or any values the agent should know.',
|
|
60
|
+
required: false,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
run(context) {
|
|
64
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const response = yield client_1.osviClient.request({
|
|
66
|
+
apiToken: context.auth.secret_text,
|
|
67
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
68
|
+
path: '/call',
|
|
69
|
+
body: buildMakeCallBody(context.propsValue),
|
|
70
|
+
});
|
|
71
|
+
return toMakeCallOutput(response.body);
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
exports.makeCall = makeCall;
|
|
76
|
+
function buildMakeCallBody(props) {
|
|
77
|
+
return Object.assign({ agent_uuid: resolveAgentId(props), phone_number: props.phoneNumber, country_code: props.countryCode }, definedRecord({
|
|
78
|
+
language: props.language,
|
|
79
|
+
person_name: props.personName,
|
|
80
|
+
initial_greeting: props.initialGreeting,
|
|
81
|
+
additional_data: props.additionalData,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
function resolveAgentId(props) {
|
|
85
|
+
if (!props.agentId) {
|
|
86
|
+
throw new Error('Select an Osvi agent.');
|
|
87
|
+
}
|
|
88
|
+
return props.agentId;
|
|
89
|
+
}
|
|
90
|
+
function definedRecord(values) {
|
|
91
|
+
return Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined && value !== ''));
|
|
92
|
+
}
|
|
93
|
+
function toMakeCallOutput(response) {
|
|
94
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
95
|
+
return {
|
|
96
|
+
success: response.success,
|
|
97
|
+
call_id: (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.call_id) !== null && _b !== void 0 ? _b : response.call_id) !== null && _c !== void 0 ? _c : null,
|
|
98
|
+
status: (_f = (_e = (_d = response.data) === null || _d === void 0 ? void 0 : _d.status) !== null && _e !== void 0 ? _e : response.status) !== null && _f !== void 0 ? _f : null,
|
|
99
|
+
agent_id: (_k = (_h = (_g = response.data) === null || _g === void 0 ? void 0 : _g.agent_id) !== null && _h !== void 0 ? _h : (_j = response.data) === null || _j === void 0 ? void 0 : _j.agent_uuid) !== null && _k !== void 0 ? _k : null,
|
|
100
|
+
phone_number: (_m = (_l = response.data) === null || _l === void 0 ? void 0 : _l.phone_number) !== null && _m !== void 0 ? _m : null,
|
|
101
|
+
country_code: (_p = (_o = response.data) === null || _o === void 0 ? void 0 : _o.country_code) !== null && _p !== void 0 ? _p : null,
|
|
102
|
+
message: (_q = response.message) !== null && _q !== void 0 ? _q : null,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=make-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-call.js","sourceRoot":"","sources":["../../../../src/lib/actions/make-call.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,kCAAmC;AACnC,6CAA8C;AAC9C,2CAA4C;AAE5C,MAAM,QAAQ,GAAG,IAAA,+BAAY,EAAC;IAC5B,IAAI,EAAE,eAAQ;IACd,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,wDAAwD;IACrE,KAAK,EAAE;QACL,OAAO,EAAE,iBAAS,CAAC,OAAO;QAC1B,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,cAAc;YAC3B,WAAW,EACT,0EAA0E;YAC5E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,kEAAkE;YAC/E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAChC,WAAW,EAAE,UAAU;YACvB,WAAW,EACT,iHAAiH;YACnH,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;oBAC/B,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;oBACjC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;oBACjC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;oBAChC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;oBACjC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,E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Q,CAAC,IAAI,0CAAE,YAAY,mCAAI,IAAI;QACjD,OAAO,EAAE,MAAA,QAAQ,CAAC,OAAO,mCAAI,IAAI;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
|
|
2
|
+
declare const osviAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
type OsviAuth = AppConnectionValueForAuthProperty<typeof osviAuth>;
|
|
4
|
+
export { osviAuth };
|
|
5
|
+
export type { OsviAuth };
|
|
6
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAElC,MAAM,gCAAgC,CAAC;AAExC,QAAA,MAAM,QAAQ,mEAOZ,CAAC;AAEH,KAAK,QAAQ,GAAG,iCAAiC,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.osviAuth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const osviAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
6
|
+
displayName: 'API Token',
|
|
7
|
+
description: `To get your API token:
|
|
8
|
+
1. Log in to your Osvi account.
|
|
9
|
+
2. Go to **Settings > API**.
|
|
10
|
+
3. Copy the 16-character API-Token and paste it here.`,
|
|
11
|
+
required: true,
|
|
12
|
+
});
|
|
13
|
+
exports.osviAuth = osviAuth;
|
|
14
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,qEAGwC;AAExC,MAAM,QAAQ,GAAG,4BAAS,CAAC,UAAU,CAAC;IACpC,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE;;;sDAGuC;IACpD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAIM,4BAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpMessageBody, HttpMethod, HttpResponse } from '@activepieces/pieces-common';
|
|
2
|
+
declare function makeOsviRequest<T extends HttpMessageBody>({ apiToken, method, path, body, }: OsviRequest): Promise<HttpResponse<T>>;
|
|
3
|
+
declare const osviClient: {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
request: typeof makeOsviRequest;
|
|
6
|
+
};
|
|
7
|
+
type OsviRequest = {
|
|
8
|
+
apiToken: string;
|
|
9
|
+
method: HttpMethod;
|
|
10
|
+
path: string;
|
|
11
|
+
body?: unknown;
|
|
12
|
+
};
|
|
13
|
+
export { osviClient };
|
|
14
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,YAAY,EAEb,MAAM,6BAA6B,CAAC;AAIrC,iBAAe,eAAe,CAAC,CAAC,SAAS,eAAe,EAAE,EACxD,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,GACL,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAUxC;AAED,QAAA,MAAM,UAAU;;;CAGf,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.osviClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const OSVI_BASE_URL = 'https://api.osvi.ai';
|
|
7
|
+
function makeOsviRequest(_a) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiToken, method, path, body, }) {
|
|
9
|
+
return pieces_common_1.httpClient.sendRequest({
|
|
10
|
+
method,
|
|
11
|
+
url: `${OSVI_BASE_URL}${path}`,
|
|
12
|
+
headers: {
|
|
13
|
+
'API-Token': apiToken,
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
},
|
|
16
|
+
body,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const osviClient = {
|
|
21
|
+
baseUrl: OSVI_BASE_URL,
|
|
22
|
+
request: makeOsviRequest,
|
|
23
|
+
};
|
|
24
|
+
exports.osviClient = osviClient;
|
|
25
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;;;AAAA,+DAKqC;AAErC,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAE5C,SAAe,eAAe;iEAA4B,EACxD,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,GACQ;QACZ,OAAO,0BAAU,CAAC,WAAW,CAAI;YAC/B,MAAM;YACN,GAAG,EAAE,GAAG,aAAa,GAAG,IAAI,EAAE;YAC9B,OAAO,EAAE;gBACP,WAAW,EAAE,QAAQ;gBACrB,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CAAA;AAED,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,eAAe;CACzB,CAAC;AASO,gCAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":"AAoDA,QAAA,MAAM,SAAS;;CAEd,CAAC;AAgFF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.osviProps = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const auth_1 = require("../auth");
|
|
9
|
+
const client_1 = require("./client");
|
|
10
|
+
const agentId = pieces_framework_1.Property.Dropdown({
|
|
11
|
+
displayName: 'Agent',
|
|
12
|
+
description: 'Select the Osvi agent that should place the outbound call.',
|
|
13
|
+
required: true,
|
|
14
|
+
auth: auth_1.osviAuth,
|
|
15
|
+
refreshers: ['auth'],
|
|
16
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
17
|
+
if (!auth) {
|
|
18
|
+
return {
|
|
19
|
+
disabled: true,
|
|
20
|
+
options: [],
|
|
21
|
+
placeholder: 'Please connect your Osvi account first.',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const { data: response, error } = yield (0, shared_1.tryCatch)(() => client_1.osviClient.request({
|
|
25
|
+
apiToken: auth.secret_text,
|
|
26
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
27
|
+
path: '/v1/active_agents',
|
|
28
|
+
}));
|
|
29
|
+
if (error) {
|
|
30
|
+
return {
|
|
31
|
+
disabled: true,
|
|
32
|
+
options: [],
|
|
33
|
+
placeholder: 'Failed to load agents. Check your Osvi connection.',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const options = extractAgents(response.body)
|
|
37
|
+
.map(toAgentDropdownOption)
|
|
38
|
+
.filter(isDropdownOption);
|
|
39
|
+
return {
|
|
40
|
+
disabled: false,
|
|
41
|
+
options,
|
|
42
|
+
placeholder: options.length === 0
|
|
43
|
+
? 'No active agents found. Create or activate an agent in Osvi first.'
|
|
44
|
+
: undefined,
|
|
45
|
+
};
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
const osviProps = {
|
|
49
|
+
agentId,
|
|
50
|
+
};
|
|
51
|
+
exports.osviProps = osviProps;
|
|
52
|
+
function extractAgents(response) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
if (Array.isArray(response)) {
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(response.data)) {
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray((_a = response.data) === null || _a === void 0 ? void 0 : _a.agents)) {
|
|
61
|
+
return response.data.agents;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray((_b = response.data) === null || _b === void 0 ? void 0 : _b.items)) {
|
|
64
|
+
return response.data.items;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(response.agents)) {
|
|
67
|
+
return response.agents;
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(response.active_agents)) {
|
|
70
|
+
return response.active_agents;
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(response.items)) {
|
|
73
|
+
return response.items;
|
|
74
|
+
}
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
function toAgentDropdownOption(agent) {
|
|
78
|
+
var _a, _b, _c, _d, _e;
|
|
79
|
+
const value = (_b = (_a = agent.agent_id) !== null && _a !== void 0 ? _a : agent.agent_uuid) !== null && _b !== void 0 ? _b : agent.id;
|
|
80
|
+
const label = (_e = (_d = (_c = agent.name) !== null && _c !== void 0 ? _c : agent.agent_name) !== null && _d !== void 0 ? _d : agent.display_name) !== null && _e !== void 0 ? _e : value;
|
|
81
|
+
if (!value || !label) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
label,
|
|
86
|
+
value,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function isDropdownOption(option) {
|
|
90
|
+
return option !== undefined;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAA0E;AAC1E,iDAAgD;AAChD,kCAAmC;AACnC,qCAAsC;AAEtC,MAAM,OAAO,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAChC,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,4DAA4D;IACzE,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,eAAQ;IACd,UAAU,EAAE,CAAC,MAAM,CAAC;IACpB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,yCAAyC;aACvD,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,iBAAQ,EAAC,GAAG,EAAE,CACpD,mBAAU,CAAC,OAAO,CAAwB;YACxC,QAAQ,EAAE,IAAI,CAAC,WAAW;YAC1B,MAAM,EAAE,0BAAU,CAAC,GAAG;YACtB,IAAI,EAAE,mBAAmB;SAC1B,CAAC,CACH,CAAC;QAEF,IAAI,KAAK,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE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