Skip to content

Commit 8572a09

Browse files
committed
new action component
1 parent bfc1790 commit 8572a09

File tree

3 files changed

+55
-50
lines changed

3 files changed

+55
-50
lines changed
Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,72 @@
1-
import gloria_ai from "../../gloria_ai.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import gloriaAi from "../../gloria_ai.app.mjs";
32

43
export default {
54
key: "gloria_ai-create-lead",
65
name: "Create Lead",
7-
description: "Creates a new lead/contact in Gloria.ai. [See the documentation]().",
8-
version: "0.0.{{ts}}",
6+
description: "Creates a new lead/contact in Gloria.ai. [See the documentation](https://api.iamgloria.com/api).",
7+
version: "0.0.1",
98
type: "action",
109
props: {
11-
gloria_ai: {
12-
type: "app",
13-
app: "gloria_ai",
14-
},
10+
gloriaAi,
1511
leadName: {
1612
propDefinition: [
17-
"gloria_ai",
13+
gloriaAi,
1814
"leadName",
1915
],
2016
},
2117
phone: {
2218
propDefinition: [
23-
"gloria_ai",
19+
gloriaAi,
2420
"phone",
2521
],
26-
optional: true,
2722
},
2823
email: {
2924
propDefinition: [
30-
"gloria_ai",
25+
gloriaAi,
3126
"email",
3227
],
33-
optional: true,
3428
},
3529
initiation: {
3630
propDefinition: [
37-
"gloria_ai",
31+
gloriaAi,
3832
"initiation",
3933
],
40-
optional: true,
4134
},
4235
tags: {
4336
propDefinition: [
44-
"gloria_ai",
37+
gloriaAi,
4538
"tags",
4639
],
47-
optional: true,
4840
},
4941
status: {
5042
propDefinition: [
51-
"gloria_ai",
43+
gloriaAi,
5244
"status",
5345
],
54-
optional: true,
5546
},
5647
},
5748
async run({ $ }) {
58-
const response = await this.gloria_ai.createContact();
59-
$.export("$summary", `Created lead ${this.leadName}`);
49+
const response = await this.gloriaAi.createContact({
50+
$,
51+
data: {
52+
tenantId: this.gloriaAi.$auth.tenant_id,
53+
createdAt: Date.now(),
54+
name: [
55+
this.leadName,
56+
],
57+
phone: this.phone && [
58+
this.phone,
59+
],
60+
email: this.email && [
61+
this.email,
62+
],
63+
origin: "api",
64+
initiation: this.initiation,
65+
tags: this.tags,
66+
status: this.status,
67+
},
68+
});
69+
$.export("$summary", `Successfully created lead with ID: ${response.id}`);
6070
return response;
6171
},
6272
};

components/gloria_ai/gloria_ai.app.mjs

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "gloria_ai",
6-
version: "0.0.{{ts}}",
76
propDefinitions: {
87
leadName: {
98
type: "string",
@@ -26,6 +25,10 @@ export default {
2625
type: "string",
2726
label: "Initiation",
2827
description: "Initiation details for the lead",
28+
options: [
29+
"Inbound",
30+
"Outbound",
31+
],
2932
optional: true,
3033
},
3134
tags: {
@@ -38,47 +41,36 @@ export default {
3841
type: "string",
3942
label: "Status",
4043
description: "Status of the lead",
44+
options: [
45+
"active",
46+
"archived",
47+
"favorite",
48+
],
4149
optional: true,
4250
},
4351
},
4452
methods: {
45-
// Existing method from the existing app file
46-
authKeys() {
47-
console.log(Object.keys(this.$auth));
48-
},
4953
_baseUrl() {
50-
return "https://api.iamgloria.com/api";
54+
return "https://api.iamgloria.com/api/v1";
5155
},
52-
async _makeRequest(opts = {}) {
53-
const {
54-
$ = this,
55-
method = "GET",
56-
path = "/",
57-
headers,
58-
...otherOpts
59-
} = opts;
56+
_makeRequest({
57+
$ = this,
58+
path,
59+
...otherOpts
60+
}) {
6061
return axios($, {
6162
...otherOpts,
62-
method,
63-
url: this._baseUrl() + path,
63+
url: `${this._baseUrl()}${path}`,
6464
headers: {
65-
...headers,
66-
Authorization: `Bearer ${this.$auth.api_token}`,
65+
"Authorization": `Bearer ${this.$auth.api_key}`,
66+
"tenant-id": `${this.$auth.tenant_id}`,
6767
},
6868
});
6969
},
70-
async createContact(opts = {}) {
70+
createContact(opts = {}) {
7171
return this._makeRequest({
7272
method: "POST",
73-
path: "/api/v1/contacts",
74-
data: {
75-
name: this.leadName,
76-
phone: this.phone,
77-
email: this.email,
78-
initiation: this.initiation,
79-
tags: this.tags,
80-
status: this.status,
81-
},
73+
path: "/contacts",
8274
...opts,
8375
});
8476
},

components/gloria_ai/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gloria_ai",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Gloria AI Components",
55
"main": "gloria_ai.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

0 commit comments

Comments
 (0)