@agnocon/piece-bonjoro 0.1.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.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/add-greet.d.ts +19 -0
- package/dist/lib/actions/add-greet.d.ts.map +1 -0
- package/dist/lib/actions/add-greet.js +125 -0
- package/dist/lib/actions/add-greet.js.map +1 -0
- package/dist/lib/api.d.ts +25 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +64 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/auth.d.ts +7 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +45 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/props.d.ts +38 -0
- package/dist/lib/props.d.ts.map +1 -0
- package/dist/lib/props.js +62 -0
- package/dist/lib/props.js.map +1 -0
- package/package.json +47 -0
- package/src/index.ts +29 -0
- package/src/lib/actions/add-greet.ts +123 -0
- package/src/lib/api.ts +66 -0
- package/src/lib/auth.ts +43 -0
- package/src/lib/props.ts +55 -0
package/LICENSE.MIT-AP
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Activepieces AB
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Derived helpers in this folder are adapted from Activepieces (MIT) for use
|
|
24
|
+
inside CX without depending on @activepieces/* packages at runtime.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO;;GAmBlB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bonjoro = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/bonjoro/src/index.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const pieces_framework_2 = require("@agnocon/pieces-framework");
|
|
10
|
+
const add_greet_1 = require("./lib/actions/add-greet");
|
|
11
|
+
const auth_1 = require("./lib/auth");
|
|
12
|
+
exports.bonjoro = (0, pieces_framework_1.createPiece)({
|
|
13
|
+
displayName: 'Bonjoro',
|
|
14
|
+
description: 'Send personal video messages to delight customers',
|
|
15
|
+
auth: auth_1.bonjoroAuth,
|
|
16
|
+
minimumSupportedRelease: '0.30.0',
|
|
17
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/bonjoro.png',
|
|
18
|
+
categories: [pieces_framework_2.PieceCategory.CUSTOMER_SUPPORT],
|
|
19
|
+
authors: ["joeworkman", "kishanprmr", "MoShizzle", "abuaboud"],
|
|
20
|
+
actions: [
|
|
21
|
+
add_greet_1.addGreetAction,
|
|
22
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
23
|
+
baseUrl: () => 'https://www.bonjoro.com/api/v2', // replace with the actual base URL
|
|
24
|
+
auth: auth_1.bonjoroAuth,
|
|
25
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
return ({
|
|
27
|
+
Authorization: `Bearer ${auth.props.apiKey}`,
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
triggers: [],
|
|
33
|
+
});
|
|
34
|
+
// https://vimily.github.io/bonjoro-api-docs/
|
|
35
|
+
// https://www.bonjoro.com/settings/api#/
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mFAAmF;AACnF,qEAAqE;AACrE,0DAAmE;AACnE,gEAAwD;AACxD,gEAA0D;AAC1D,uDAAyD;AACzD,qCAAyC;AAE5B,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,mDAAmD;IAChE,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,UAAU,EAAE,CAAC,gCAAa,CAAC,gBAAgB,CAAC;IAC5C,OAAO,EAAE,CAAC,YAAY,EAAC,YAAY,EAAC,WAAW,EAAC,UAAU,CAAC;IAC3D,OAAO,EAAE;QACP,0BAAc;QACd,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,gCAAgC,EAAE,mCAAmC;YACpF,IAAI,EAAE,kBAAW;YACjB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAU,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;iBAC7C,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEH,6CAA6C;AAC7C,yCAAyC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const addGreetAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
apiKey: import("@agnocon/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
}>, {
|
|
4
|
+
note: import("@agnocon/pieces-framework").LongTextProperty<true>;
|
|
5
|
+
email: import("@agnocon/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
first: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
last: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
assignee: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").CustomAuthProperty<{
|
|
9
|
+
apiKey: import("@agnocon/pieces-framework").SecretTextProperty<true>;
|
|
10
|
+
}>>;
|
|
11
|
+
campaign: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
apiKey: import("@agnocon/pieces-framework").SecretTextProperty<true>;
|
|
13
|
+
}>>;
|
|
14
|
+
template: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").CustomAuthProperty<{
|
|
15
|
+
apiKey: import("@agnocon/pieces-framework").SecretTextProperty<true>;
|
|
16
|
+
}>>;
|
|
17
|
+
custom: import("@agnocon/pieces-framework").JsonProperty<false>;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=add-greet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-greet.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/add-greet.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;EAiHzB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addGreetAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/bonjoro/src/lib/actions/add-greet.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
const auth_1 = require("../auth");
|
|
10
|
+
const props_1 = require("../props");
|
|
11
|
+
exports.addGreetAction = (0, pieces_framework_1.createAction)({
|
|
12
|
+
name: 'add_greet',
|
|
13
|
+
auth: auth_1.bonjoroAuth,
|
|
14
|
+
displayName: 'Create a Greet',
|
|
15
|
+
description: 'Create a new Greet in Bonjoro',
|
|
16
|
+
audience: 'both',
|
|
17
|
+
aiMetadata: { description: 'Creates a personal-video Greet task in Bonjoro for a recipient identified by email (upserting their profile first), with a note and optional assignee, campaign, and message template. Use to queue a new outreach video for a customer. Not idempotent: each call creates a new Greet, so repeating it produces duplicates.', idempotent: false },
|
|
18
|
+
props: {
|
|
19
|
+
note: pieces_framework_1.Property.LongText({
|
|
20
|
+
displayName: 'Note',
|
|
21
|
+
description: 'Note to send with the greet',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
email: pieces_framework_1.Property.ShortText({
|
|
25
|
+
displayName: 'Email',
|
|
26
|
+
description: 'Email to send the greet to',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
first: pieces_framework_1.Property.ShortText({
|
|
30
|
+
displayName: 'First Name',
|
|
31
|
+
description: 'First name of the person to greet',
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
last: pieces_framework_1.Property.ShortText({
|
|
35
|
+
displayName: 'Last Name',
|
|
36
|
+
description: 'Last name of the person to greet',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
assignee: pieces_framework_1.Property.Dropdown({
|
|
40
|
+
auth: auth_1.bonjoroAuth,
|
|
41
|
+
displayName: 'Assignee',
|
|
42
|
+
description: 'Who to assign the greet to',
|
|
43
|
+
required: false,
|
|
44
|
+
refreshers: [],
|
|
45
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
46
|
+
if (!auth) {
|
|
47
|
+
return {
|
|
48
|
+
disabled: true,
|
|
49
|
+
options: [],
|
|
50
|
+
placeholder: 'Please connect your Bonjoro account first',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return yield (0, props_1.buildUserDropdown)(auth.props);
|
|
54
|
+
})
|
|
55
|
+
}),
|
|
56
|
+
campaign: pieces_framework_1.Property.Dropdown({
|
|
57
|
+
auth: auth_1.bonjoroAuth,
|
|
58
|
+
displayName: 'Campaign',
|
|
59
|
+
description: 'The campaign to add the greet to',
|
|
60
|
+
required: false,
|
|
61
|
+
refreshers: [],
|
|
62
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
63
|
+
if (!auth) {
|
|
64
|
+
return {
|
|
65
|
+
disabled: true,
|
|
66
|
+
options: [],
|
|
67
|
+
placeholder: 'Please connect your Bonjoro account first',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return yield (0, props_1.buildCampaignDropdown)(auth.props);
|
|
71
|
+
})
|
|
72
|
+
}),
|
|
73
|
+
template: pieces_framework_1.Property.Dropdown({
|
|
74
|
+
auth: auth_1.bonjoroAuth,
|
|
75
|
+
displayName: 'Template',
|
|
76
|
+
description: 'The template to use for the greet',
|
|
77
|
+
required: false,
|
|
78
|
+
refreshers: [],
|
|
79
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
80
|
+
if (!auth) {
|
|
81
|
+
return {
|
|
82
|
+
disabled: true,
|
|
83
|
+
options: [],
|
|
84
|
+
placeholder: 'Please connect your Bonjoro account first',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return yield (0, props_1.buildTemplateDropdown)(auth.props);
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
custom: pieces_framework_1.Property.Json({
|
|
91
|
+
displayName: 'Custom Attributes',
|
|
92
|
+
description: 'Enter custom attributes to send with the greet',
|
|
93
|
+
required: false,
|
|
94
|
+
defaultValue: {},
|
|
95
|
+
}),
|
|
96
|
+
},
|
|
97
|
+
run(context) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const user = {
|
|
100
|
+
email: context.propsValue.email,
|
|
101
|
+
first_name: context.propsValue.first,
|
|
102
|
+
last_name: context.propsValue.last,
|
|
103
|
+
};
|
|
104
|
+
(0, api_1.addProfile)(context.auth.props, user);
|
|
105
|
+
const greet = {
|
|
106
|
+
profiles: [context.propsValue.email],
|
|
107
|
+
note: context.propsValue.note,
|
|
108
|
+
assignee_id: context.propsValue.assignee,
|
|
109
|
+
campaign_id: context.propsValue.campaign,
|
|
110
|
+
template_id: context.propsValue.template,
|
|
111
|
+
custom_attributes: context.propsValue.custom,
|
|
112
|
+
};
|
|
113
|
+
if (!greet.assignee_id)
|
|
114
|
+
delete greet.assignee_id;
|
|
115
|
+
if (!greet.campaign_id)
|
|
116
|
+
delete greet.campaign_id;
|
|
117
|
+
if (!greet.template_id)
|
|
118
|
+
delete greet.template_id;
|
|
119
|
+
if (!greet.custom_attributes)
|
|
120
|
+
delete greet.custom_attributes;
|
|
121
|
+
return yield (0, api_1.addGreet)(context.auth.props, greet);
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=add-greet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-greet.js","sourceRoot":"","sources":["../../../src/lib/actions/add-greet.ts"],"names":[],"mappings":";;;;AAAA,mGAAmG;AACnG,qEAAqE;AACrE,gEAAmE;AACnE,gCAA8C;AAC9C,kCAAuD;AACvD,oCAIkB;AAEL,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,kBAAW;IACjB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,+BAA+B;IAC5C,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,8TAA8T,EAAE,UAAU,EAAE,KAAK,EAAE;IAC9W,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,mCAAmC;YAChD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,IAAI,EAAE,kBAAW;YACjB,WAA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,OAAO,MAAM,IAAA,cAAQ,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BonjoroAuthType } from './auth';
|
|
2
|
+
export type KeyValuePair = {
|
|
3
|
+
[key: string]: string | boolean | object | undefined;
|
|
4
|
+
};
|
|
5
|
+
export declare function getUsers(auth: BonjoroAuthType): Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
data: any;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function getCampaigns(auth: BonjoroAuthType): Promise<{
|
|
10
|
+
success: boolean;
|
|
11
|
+
data: any;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function getTemplates(auth: BonjoroAuthType): Promise<{
|
|
14
|
+
success: boolean;
|
|
15
|
+
data: any;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function addGreet(auth: BonjoroAuthType, data: KeyValuePair): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
data: any;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function addProfile(auth: BonjoroAuthType, data: KeyValuePair): Promise<{
|
|
22
|
+
success: boolean;
|
|
23
|
+
data: any;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CACtD,CAAC;AAiCF,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe;;;GAGnD;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,eAAe;;;GAGvD;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,eAAe;;;GAGvD;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,YAAY;;;GAGvE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,YAAY;;;GAGzE"}
|
package/dist/lib/api.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUsers = getUsers;
|
|
4
|
+
exports.getCampaigns = getCampaigns;
|
|
5
|
+
exports.getTemplates = getTemplates;
|
|
6
|
+
exports.addGreet = addGreet;
|
|
7
|
+
exports.addProfile = addProfile;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
// Vendored from Activepieces packages/pieces/community/bonjoro/src/lib/api.ts (MIT).
|
|
10
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
11
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
12
|
+
const bonjoroAPI = (api_1, auth_1, ...args_1) => tslib_1.__awaiter(void 0, [api_1, auth_1, ...args_1], void 0, function* (api, auth, method = pieces_common_1.HttpMethod.GET, body = {}) {
|
|
13
|
+
const baseUrl = 'https://www.bonjoro.com/api/v2/';
|
|
14
|
+
const request = {
|
|
15
|
+
body: body,
|
|
16
|
+
method: method,
|
|
17
|
+
url: `${baseUrl}${api}`,
|
|
18
|
+
headers: {
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
Authorization: `Bearer ${auth.apiKey}`,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
24
|
+
if (response.status > 201 || response.body['data'] === undefined) {
|
|
25
|
+
throw new Error(`Bonjoro API error: ${response.status} ${response.body}`);
|
|
26
|
+
}
|
|
27
|
+
let data = [];
|
|
28
|
+
data = response.body['data'];
|
|
29
|
+
return {
|
|
30
|
+
success: true,
|
|
31
|
+
data: data,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
function getUsers(auth) {
|
|
35
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const api = 'users';
|
|
37
|
+
return bonjoroAPI(api, auth);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function getCampaigns(auth) {
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const api = 'campaigns';
|
|
43
|
+
return bonjoroAPI(api, auth);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function getTemplates(auth) {
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const api = 'message-templates';
|
|
49
|
+
return bonjoroAPI(api, auth);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function addGreet(auth, data) {
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const api = 'greets';
|
|
55
|
+
return bonjoroAPI(api, auth, pieces_common_1.HttpMethod.POST, data);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function addProfile(auth, data) {
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const api = 'profiles';
|
|
61
|
+
return bonjoroAPI(api, auth, pieces_common_1.HttpMethod.POST, data);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":";;AA4CA,4BAGC;AAED,oCAGC;AAED,oCAGC;AAED,4BAGC;AAED,gCAGC;;AAnED,qFAAqF;AACrF,qEAAqE;AACrE,0DAIgC;AAOhC,MAAM,UAAU,GAAG,2BAKjB,EAAE,0EAJF,GAAW,EACX,IAAqB,EACrB,SAAqB,0BAAU,CAAC,GAAG,EACnC,OAA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AE,IAAkB;;QACtE,MAAM,GAAG,GAAG,QAAQ,CAAC;QACrB,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,0BAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CAAA;AAED,SAAsB,UAAU,CAAC,IAAqB,EAAE,IAAkB;;QACxE,MAAM,GAAG,GAAG,UAAU,CAAC;QACvB,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,0BAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,eAAe,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,eAAO,MAAM,WAAW;;EA0BtB,CAAC"}
|
package/dist/lib/auth.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bonjoroAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/bonjoro/src/lib/auth.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const api_1 = require("./api");
|
|
9
|
+
const z = tslib_1.__importStar(require("zod/mini"));
|
|
10
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
11
|
+
exports.bonjoroAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
12
|
+
description: 'Authenticate with your Bonjoro account',
|
|
13
|
+
props: {
|
|
14
|
+
apiKey: pieces_framework_1.PieceAuth.SecretText({
|
|
15
|
+
displayName: 'API Key',
|
|
16
|
+
description: 'The API key for your Bonjoro account',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
21
|
+
try {
|
|
22
|
+
yield pieces_common_1.propsValidation.validateZod(auth, {
|
|
23
|
+
apiKey: z.string().check(z.minLength(1)),
|
|
24
|
+
});
|
|
25
|
+
yield validateAuth(auth);
|
|
26
|
+
return {
|
|
27
|
+
valid: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
return {
|
|
32
|
+
valid: false,
|
|
33
|
+
error: e === null || e === void 0 ? void 0 : e.message,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
required: true,
|
|
38
|
+
});
|
|
39
|
+
const validateAuth = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const response = yield (0, api_1.getCampaigns)(auth);
|
|
41
|
+
if (response.success !== true) {
|
|
42
|
+
throw new Error('Authentication failed. Please check your domain and API key and try again.');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,sFAAsF;AACtF,qEAAqE;AACrE,gEAAsD;AACtD,+BAAqC;AACrC,oDAA6B;AAC7B,0DAAyD;AAI5C,QAAA,WAAW,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,wCAAwC;IACrD,KAAK,EAAE;QACL,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC3B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,+BAAe,CAAC,WAAW,CAAC,IAAI,EAAE;gBACtC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;aACzC,CAAC,CAAC;YACH,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;YACzB,OAAO;gBACL,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAG,CAAW,aAAX,CAAC,uBAAD,CAAC,CAAY,OAAO;aAC7B,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;IACD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAO,IAAqB,EAAE,EAAE;IACnD,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAY,EAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BonjoroAuthType } from './auth';
|
|
2
|
+
export declare function buildCampaignDropdown(auth: BonjoroAuthType): Promise<{
|
|
3
|
+
options: never[];
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
placeholder: string;
|
|
6
|
+
} | {
|
|
7
|
+
options: {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}[];
|
|
11
|
+
disabled?: undefined;
|
|
12
|
+
placeholder?: undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function buildTemplateDropdown(auth: BonjoroAuthType): Promise<{
|
|
15
|
+
options: never[];
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
placeholder: string;
|
|
18
|
+
} | {
|
|
19
|
+
options: {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}[];
|
|
23
|
+
disabled?: undefined;
|
|
24
|
+
placeholder?: undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function buildUserDropdown(auth: BonjoroAuthType): Promise<{
|
|
27
|
+
options: never[];
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
placeholder: string;
|
|
30
|
+
} | {
|
|
31
|
+
options: {
|
|
32
|
+
label: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}[];
|
|
35
|
+
disabled?: undefined;
|
|
36
|
+
placeholder?: undefined;
|
|
37
|
+
}>;
|
|
38
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/lib/props.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAKzC,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,eAAe;;;;;;;;;;;GAehE;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,eAAe;;;;;;;;;;;GAehE;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,eAAe;;;;;;;;;;;GAe5D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildCampaignDropdown = buildCampaignDropdown;
|
|
4
|
+
exports.buildTemplateDropdown = buildTemplateDropdown;
|
|
5
|
+
exports.buildUserDropdown = buildUserDropdown;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const api_1 = require("./api");
|
|
8
|
+
function buildCampaignDropdown(auth) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
if (!auth) {
|
|
11
|
+
return {
|
|
12
|
+
options: [],
|
|
13
|
+
disabled: true,
|
|
14
|
+
placeholder: 'Please authenticate first',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const response = yield (0, api_1.getCampaigns)(auth);
|
|
18
|
+
const options = response.data.map((campaign) => {
|
|
19
|
+
return { label: campaign.name, value: campaign.uuid };
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
options: options,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function buildTemplateDropdown(auth) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (!auth) {
|
|
29
|
+
return {
|
|
30
|
+
options: [],
|
|
31
|
+
disabled: true,
|
|
32
|
+
placeholder: 'Please authenticate first',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const response = yield (0, api_1.getTemplates)(auth);
|
|
36
|
+
const options = response.data.map((template) => {
|
|
37
|
+
return { label: template.name, value: template.id };
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
options: options,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function buildUserDropdown(auth) {
|
|
45
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (!auth) {
|
|
47
|
+
return {
|
|
48
|
+
options: [],
|
|
49
|
+
disabled: true,
|
|
50
|
+
placeholder: 'Please authenticate first',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const response = yield (0, api_1.getUsers)(auth);
|
|
54
|
+
const options = response.data.map((user) => {
|
|
55
|
+
return { label: user.name, value: user.id };
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
options: options,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/lib/props.ts"],"names":[],"mappings":";;AAOA,sDAeC;AAED,sDAeC;AAED,8CAeC;;AArDD,+BAA6D;AAI7D,SAAsB,qBAAqB,CAAC,IAAqB;;QAC/D,IAAI,C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AAC,IAAuB,CAAC,CAAC;QACzD,MAAM,OAAO,GAAI,QAAQ,CAAC,IAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC5D,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agnocon/piece-bonjoro",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "AgnoCon bonjoro connector",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src",
|
|
17
|
+
"LICENSE.MIT-AP"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"vendor": "node ../scripts/vendor-ap.mjs piece-bonjoro"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@agnocon/core-utils": "0.2.0",
|
|
25
|
+
"@agnocon/piece-types": "0.3.1",
|
|
26
|
+
"@agnocon/pieces-common": "0.12.8",
|
|
27
|
+
"@agnocon/pieces-framework": "0.36.0",
|
|
28
|
+
"tslib": "2.6.2",
|
|
29
|
+
"zod": "4.3.6"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "20.17.6",
|
|
33
|
+
"typescript": "5.5.4"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"agnocon": {
|
|
37
|
+
"originVersion": "0.1.7"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "restricted",
|
|
41
|
+
"tag": "latest"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"agnocon",
|
|
45
|
+
"connector"
|
|
46
|
+
]
|
|
47
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCustomApiCallAction } from '@agnocon/pieces-common';
|
|
2
|
+
import { createPiece } from '@agnocon/pieces-framework';
|
|
3
|
+
import { PieceCategory } from '@agnocon/pieces-framework';
|
|
4
|
+
import { addGreetAction } from './lib/actions/add-greet';
|
|
5
|
+
import { bonjoroAuth } from './lib/auth';
|
|
6
|
+
|
|
7
|
+
export const bonjoro = createPiece({
|
|
8
|
+
displayName: 'Bonjoro',
|
|
9
|
+
description: 'Send personal video messages to delight customers',
|
|
10
|
+
auth: bonjoroAuth,
|
|
11
|
+
minimumSupportedRelease: '0.30.0',
|
|
12
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/bonjoro.png',
|
|
13
|
+
categories: [PieceCategory.CUSTOMER_SUPPORT],
|
|
14
|
+
authors: ["joeworkman","kishanprmr","MoShizzle","abuaboud"],
|
|
15
|
+
actions: [
|
|
16
|
+
addGreetAction,
|
|
17
|
+
createCustomApiCallAction({
|
|
18
|
+
baseUrl: () => 'https://www.bonjoro.com/api/v2', // replace with the actual base URL
|
|
19
|
+
auth: bonjoroAuth,
|
|
20
|
+
authMapping: async (auth) => ({
|
|
21
|
+
Authorization: `Bearer ${auth.props.apiKey}`,
|
|
22
|
+
}),
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
triggers: [],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// https://vimily.github.io/bonjoro-api-docs/
|
|
29
|
+
// https://www.bonjoro.com/settings/api#/
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { addGreet, addProfile } from '../api';
|
|
3
|
+
import { bonjoroAuth, BonjoroAuthType } from '../auth';
|
|
4
|
+
import {
|
|
5
|
+
buildCampaignDropdown,
|
|
6
|
+
buildTemplateDropdown,
|
|
7
|
+
buildUserDropdown,
|
|
8
|
+
} from '../props';
|
|
9
|
+
|
|
10
|
+
export const addGreetAction = createAction({
|
|
11
|
+
name: 'add_greet',
|
|
12
|
+
auth: bonjoroAuth,
|
|
13
|
+
displayName: 'Create a Greet',
|
|
14
|
+
description: 'Create a new Greet in Bonjoro',
|
|
15
|
+
audience: 'both',
|
|
16
|
+
aiMetadata: { description: 'Creates a personal-video Greet task in Bonjoro for a recipient identified by email (upserting their profile first), with a note and optional assignee, campaign, and message template. Use to queue a new outreach video for a customer. Not idempotent: each call creates a new Greet, so repeating it produces duplicates.', idempotent: false },
|
|
17
|
+
props: {
|
|
18
|
+
note: Property.LongText({
|
|
19
|
+
displayName: 'Note',
|
|
20
|
+
description: 'Note to send with the greet',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
email: Property.ShortText({
|
|
24
|
+
displayName: 'Email',
|
|
25
|
+
description: 'Email to send the greet to',
|
|
26
|
+
required: true,
|
|
27
|
+
}),
|
|
28
|
+
first: Property.ShortText({
|
|
29
|
+
displayName: 'First Name',
|
|
30
|
+
description: 'First name of the person to greet',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
last: Property.ShortText({
|
|
34
|
+
displayName: 'Last Name',
|
|
35
|
+
description: 'Last name of the person to greet',
|
|
36
|
+
required: false,
|
|
37
|
+
}),
|
|
38
|
+
assignee: Property.Dropdown({
|
|
39
|
+
auth: bonjoroAuth,
|
|
40
|
+
displayName: 'Assignee',
|
|
41
|
+
description: 'Who to assign the greet to',
|
|
42
|
+
required: false,
|
|
43
|
+
refreshers: [],
|
|
44
|
+
options: async ({ auth }) =>
|
|
45
|
+
{
|
|
46
|
+
if (!auth) {
|
|
47
|
+
return {
|
|
48
|
+
disabled: true,
|
|
49
|
+
options: [],
|
|
50
|
+
placeholder: 'Please connect your Bonjoro account first',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return await buildUserDropdown(auth.props);
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
campaign: Property.Dropdown({
|
|
57
|
+
auth: bonjoroAuth,
|
|
58
|
+
displayName: 'Campaign',
|
|
59
|
+
description: 'The campaign to add the greet to',
|
|
60
|
+
required: false,
|
|
61
|
+
refreshers: [],
|
|
62
|
+
options: async ({ auth }) =>
|
|
63
|
+
{
|
|
64
|
+
if (!auth) {
|
|
65
|
+
return {
|
|
66
|
+
disabled: true,
|
|
67
|
+
options: [],
|
|
68
|
+
placeholder: 'Please connect your Bonjoro account first',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return await buildCampaignDropdown(auth.props);
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
template: Property.Dropdown({
|
|
75
|
+
auth: bonjoroAuth,
|
|
76
|
+
displayName: 'Template',
|
|
77
|
+
description: 'The template to use for the greet',
|
|
78
|
+
required: false,
|
|
79
|
+
refreshers: [],
|
|
80
|
+
options: async ({ auth }) =>
|
|
81
|
+
{
|
|
82
|
+
if (!auth) {
|
|
83
|
+
return {
|
|
84
|
+
disabled: true,
|
|
85
|
+
options: [],
|
|
86
|
+
placeholder: 'Please connect your Bonjoro account first',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return await buildTemplateDropdown(auth.props);
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
custom: Property.Json({
|
|
93
|
+
displayName: 'Custom Attributes',
|
|
94
|
+
description: 'Enter custom attributes to send with the greet',
|
|
95
|
+
required: false,
|
|
96
|
+
defaultValue: {},
|
|
97
|
+
}),
|
|
98
|
+
},
|
|
99
|
+
async run(context) {
|
|
100
|
+
const user = {
|
|
101
|
+
email: context.propsValue.email,
|
|
102
|
+
first_name: context.propsValue.first,
|
|
103
|
+
last_name: context.propsValue.last,
|
|
104
|
+
};
|
|
105
|
+
addProfile(context.auth.props, user);
|
|
106
|
+
|
|
107
|
+
const greet = {
|
|
108
|
+
profiles: [context.propsValue.email],
|
|
109
|
+
note: context.propsValue.note,
|
|
110
|
+
assignee_id: context.propsValue.assignee,
|
|
111
|
+
campaign_id: context.propsValue.campaign,
|
|
112
|
+
template_id: context.propsValue.template,
|
|
113
|
+
custom_attributes: context.propsValue.custom,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (!greet.assignee_id) delete greet.assignee_id;
|
|
117
|
+
if (!greet.campaign_id) delete greet.campaign_id;
|
|
118
|
+
if (!greet.template_id) delete greet.template_id;
|
|
119
|
+
if (!greet.custom_attributes) delete greet.custom_attributes;
|
|
120
|
+
|
|
121
|
+
return await addGreet(context.auth.props, greet);
|
|
122
|
+
},
|
|
123
|
+
});
|
package/src/lib/api.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
httpClient,
|
|
3
|
+
HttpMethod,
|
|
4
|
+
HttpRequest,
|
|
5
|
+
} from '@agnocon/pieces-common';
|
|
6
|
+
import { BonjoroAuthType } from './auth';
|
|
7
|
+
|
|
8
|
+
export type KeyValuePair = {
|
|
9
|
+
[key: string]: string | boolean | object | undefined;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const bonjoroAPI = async (
|
|
13
|
+
api: string,
|
|
14
|
+
auth: BonjoroAuthType,
|
|
15
|
+
method: HttpMethod = HttpMethod.GET,
|
|
16
|
+
body: KeyValuePair = {}
|
|
17
|
+
) => {
|
|
18
|
+
const baseUrl = 'https://www.bonjoro.com/api/v2/';
|
|
19
|
+
const request: HttpRequest = {
|
|
20
|
+
body: body,
|
|
21
|
+
method: method,
|
|
22
|
+
url: `${baseUrl}${api}`,
|
|
23
|
+
headers: {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
Authorization: `Bearer ${auth.apiKey}`,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const response = await httpClient.sendRequest(request);
|
|
29
|
+
|
|
30
|
+
if (response.status > 201 || response.body['data'] === undefined) {
|
|
31
|
+
throw new Error(`Bonjoro API error: ${response.status} ${response.body}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let data = [];
|
|
35
|
+
data = response.body['data'];
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
data: data,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export async function getUsers(auth: BonjoroAuthType) {
|
|
44
|
+
const api = 'users';
|
|
45
|
+
return bonjoroAPI(api, auth);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function getCampaigns(auth: BonjoroAuthType) {
|
|
49
|
+
const api = 'campaigns';
|
|
50
|
+
return bonjoroAPI(api, auth);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function getTemplates(auth: BonjoroAuthType) {
|
|
54
|
+
const api = 'message-templates';
|
|
55
|
+
return bonjoroAPI(api, auth);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function addGreet(auth: BonjoroAuthType, data: KeyValuePair) {
|
|
59
|
+
const api = 'greets';
|
|
60
|
+
return bonjoroAPI(api, auth, HttpMethod.POST, data);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function addProfile(auth: BonjoroAuthType, data: KeyValuePair) {
|
|
64
|
+
const api = 'profiles';
|
|
65
|
+
return bonjoroAPI(api, auth, HttpMethod.POST, data);
|
|
66
|
+
}
|
package/src/lib/auth.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PieceAuth } from '@agnocon/pieces-framework';
|
|
2
|
+
import { getCampaigns } from './api';
|
|
3
|
+
import * as z from 'zod/mini'
|
|
4
|
+
import { propsValidation } from '@agnocon/pieces-common';
|
|
5
|
+
|
|
6
|
+
export type BonjoroAuthType = { apiKey: string };
|
|
7
|
+
|
|
8
|
+
export const bonjoroAuth = PieceAuth.CustomAuth({
|
|
9
|
+
description: 'Authenticate with your Bonjoro account',
|
|
10
|
+
props: {
|
|
11
|
+
apiKey: PieceAuth.SecretText({
|
|
12
|
+
displayName: 'API Key',
|
|
13
|
+
description: 'The API key for your Bonjoro account',
|
|
14
|
+
required: true,
|
|
15
|
+
}),
|
|
16
|
+
},
|
|
17
|
+
validate: async ({ auth }) => {
|
|
18
|
+
try {
|
|
19
|
+
await propsValidation.validateZod(auth, {
|
|
20
|
+
apiKey: z.string().check(z.minLength(1)),
|
|
21
|
+
});
|
|
22
|
+
await validateAuth(auth);
|
|
23
|
+
return {
|
|
24
|
+
valid: true,
|
|
25
|
+
};
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return {
|
|
28
|
+
valid: false,
|
|
29
|
+
error: (e as Error)?.message,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
required: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const validateAuth = async (auth: BonjoroAuthType) => {
|
|
37
|
+
const response = await getCampaigns(auth);
|
|
38
|
+
if (response.success !== true) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
'Authentication failed. Please check your domain and API key and try again.'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
};
|
package/src/lib/props.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BonjoroAuthType } from './auth';
|
|
2
|
+
import { getCampaigns, getTemplates, getUsers } from './api';
|
|
3
|
+
|
|
4
|
+
type BonjoroData = { id: string; name: string; uuid: string };
|
|
5
|
+
|
|
6
|
+
export async function buildCampaignDropdown(auth: BonjoroAuthType) {
|
|
7
|
+
if (!auth) {
|
|
8
|
+
return {
|
|
9
|
+
options: [],
|
|
10
|
+
disabled: true,
|
|
11
|
+
placeholder: 'Please authenticate first',
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const response = await getCampaigns(auth as BonjoroAuthType);
|
|
15
|
+
const options = (response.data as BonjoroData[]).map((campaign) => {
|
|
16
|
+
return { label: campaign.name, value: campaign.uuid };
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
options: options,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function buildTemplateDropdown(auth: BonjoroAuthType) {
|
|
24
|
+
if (!auth) {
|
|
25
|
+
return {
|
|
26
|
+
options: [],
|
|
27
|
+
disabled: true,
|
|
28
|
+
placeholder: 'Please authenticate first',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const response = await getTemplates(auth as BonjoroAuthType);
|
|
32
|
+
const options = (response.data as BonjoroData[]).map((template) => {
|
|
33
|
+
return { label: template.name, value: template.id };
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
options: options,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function buildUserDropdown(auth: BonjoroAuthType) {
|
|
41
|
+
if (!auth) {
|
|
42
|
+
return {
|
|
43
|
+
options: [],
|
|
44
|
+
disabled: true,
|
|
45
|
+
placeholder: 'Please authenticate first',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const response = await getUsers(auth as BonjoroAuthType);
|
|
49
|
+
const options = (response.data as BonjoroData[]).map((user) => {
|
|
50
|
+
return { label: user.name, value: user.id };
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
options: options,
|
|
54
|
+
};
|
|
55
|
+
}
|