From bfc1790d09dcd26024d99b969c893d7919c5a0d7 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 28 Jan 2025 12:37:09 -0500 Subject: [PATCH 1/3] gloria_ai init --- .../actions/create-lead/create-lead.mjs | 62 +++++++++++++++ components/gloria_ai/gloria_ai.app.mjs | 79 ++++++++++++++++++- components/gloria_ai/package.json | 2 +- 3 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 components/gloria_ai/actions/create-lead/create-lead.mjs diff --git a/components/gloria_ai/actions/create-lead/create-lead.mjs b/components/gloria_ai/actions/create-lead/create-lead.mjs new file mode 100644 index 0000000000000..88c4e862aaa36 --- /dev/null +++ b/components/gloria_ai/actions/create-lead/create-lead.mjs @@ -0,0 +1,62 @@ +import gloria_ai from "../../gloria_ai.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "gloria_ai-create-lead", + name: "Create Lead", + description: "Creates a new lead/contact in Gloria.ai. [See the documentation]().", + version: "0.0.{{ts}}", + type: "action", + props: { + gloria_ai: { + type: "app", + app: "gloria_ai", + }, + leadName: { + propDefinition: [ + "gloria_ai", + "leadName", + ], + }, + phone: { + propDefinition: [ + "gloria_ai", + "phone", + ], + optional: true, + }, + email: { + propDefinition: [ + "gloria_ai", + "email", + ], + optional: true, + }, + initiation: { + propDefinition: [ + "gloria_ai", + "initiation", + ], + optional: true, + }, + tags: { + propDefinition: [ + "gloria_ai", + "tags", + ], + optional: true, + }, + status: { + propDefinition: [ + "gloria_ai", + "status", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.gloria_ai.createContact(); + $.export("$summary", `Created lead ${this.leadName}`); + return response; + }, +}; diff --git a/components/gloria_ai/gloria_ai.app.mjs b/components/gloria_ai/gloria_ai.app.mjs index a3e1944472a89..a7b397751f2a1 100644 --- a/components/gloria_ai/gloria_ai.app.mjs +++ b/components/gloria_ai/gloria_ai.app.mjs @@ -1,11 +1,86 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "gloria_ai", - propDefinitions: {}, + version: "0.0.{{ts}}", + propDefinitions: { + leadName: { + type: "string", + label: "Lead Name", + description: "The name of the lead", + }, + phone: { + type: "string", + label: "Phone", + description: "Phone number of the lead", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Email address of the lead", + optional: true, + }, + initiation: { + type: "string", + label: "Initiation", + description: "Initiation details for the lead", + optional: true, + }, + tags: { + type: "string[]", + label: "Tags", + description: "Tags associated with the lead", + optional: true, + }, + status: { + type: "string", + label: "Status", + description: "Status of the lead", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data + // Existing method from the existing app file authKeys() { console.log(Object.keys(this.$auth)); }, + _baseUrl() { + return "https://api.iamgloria.com/api"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + method = "GET", + path = "/", + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.api_token}`, + }, + }); + }, + async createContact(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/api/v1/contacts", + data: { + name: this.leadName, + phone: this.phone, + email: this.email, + initiation: this.initiation, + tags: this.tags, + status: this.status, + }, + ...opts, + }); + }, }, }; diff --git a/components/gloria_ai/package.json b/components/gloria_ai/package.json index 1a39e58475e28..ace12d7bdaf4f 100644 --- a/components/gloria_ai/package.json +++ b/components/gloria_ai/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} From 8572a0915cc51de544d393e9c03a9de130ef909f Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 28 Jan 2025 13:04:49 -0500 Subject: [PATCH 2/3] new action component --- .../actions/create-lead/create-lead.mjs | 52 +++++++++++-------- components/gloria_ai/gloria_ai.app.mjs | 48 +++++++---------- components/gloria_ai/package.json | 5 +- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/components/gloria_ai/actions/create-lead/create-lead.mjs b/components/gloria_ai/actions/create-lead/create-lead.mjs index 88c4e862aaa36..b1420a5be1f90 100644 --- a/components/gloria_ai/actions/create-lead/create-lead.mjs +++ b/components/gloria_ai/actions/create-lead/create-lead.mjs @@ -1,62 +1,72 @@ -import gloria_ai from "../../gloria_ai.app.mjs"; -import { axios } from "@pipedream/platform"; +import gloriaAi from "../../gloria_ai.app.mjs"; export default { key: "gloria_ai-create-lead", name: "Create Lead", - description: "Creates a new lead/contact in Gloria.ai. [See the documentation]().", - version: "0.0.{{ts}}", + description: "Creates a new lead/contact in Gloria.ai. [See the documentation](https://api.iamgloria.com/api).", + version: "0.0.1", type: "action", props: { - gloria_ai: { - type: "app", - app: "gloria_ai", - }, + gloriaAi, leadName: { propDefinition: [ - "gloria_ai", + gloriaAi, "leadName", ], }, phone: { propDefinition: [ - "gloria_ai", + gloriaAi, "phone", ], - optional: true, }, email: { propDefinition: [ - "gloria_ai", + gloriaAi, "email", ], - optional: true, }, initiation: { propDefinition: [ - "gloria_ai", + gloriaAi, "initiation", ], - optional: true, }, tags: { propDefinition: [ - "gloria_ai", + gloriaAi, "tags", ], - optional: true, }, status: { propDefinition: [ - "gloria_ai", + gloriaAi, "status", ], - optional: true, }, }, async run({ $ }) { - const response = await this.gloria_ai.createContact(); - $.export("$summary", `Created lead ${this.leadName}`); + const response = await this.gloriaAi.createContact({ + $, + data: { + tenantId: this.gloriaAi.$auth.tenant_id, + createdAt: Date.now(), + name: [ + this.leadName, + ], + phone: this.phone && [ + this.phone, + ], + email: this.email && [ + this.email, + ], + origin: "api", + initiation: this.initiation, + tags: this.tags, + status: this.status, + }, + }); + $.export("$summary", `Successfully created lead with ID: ${response.id}`); return response; }, }; diff --git a/components/gloria_ai/gloria_ai.app.mjs b/components/gloria_ai/gloria_ai.app.mjs index a7b397751f2a1..10245bf98797d 100644 --- a/components/gloria_ai/gloria_ai.app.mjs +++ b/components/gloria_ai/gloria_ai.app.mjs @@ -3,7 +3,6 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "gloria_ai", - version: "0.0.{{ts}}", propDefinitions: { leadName: { type: "string", @@ -26,6 +25,10 @@ export default { type: "string", label: "Initiation", description: "Initiation details for the lead", + options: [ + "Inbound", + "Outbound", + ], optional: true, }, tags: { @@ -38,47 +41,36 @@ export default { type: "string", label: "Status", description: "Status of the lead", + options: [ + "active", + "archived", + "favorite", + ], optional: true, }, }, methods: { - // Existing method from the existing app file - authKeys() { - console.log(Object.keys(this.$auth)); - }, _baseUrl() { - return "https://api.iamgloria.com/api"; + return "https://api.iamgloria.com/api/v1"; }, - async _makeRequest(opts = {}) { - const { - $ = this, - method = "GET", - path = "/", - headers, - ...otherOpts - } = opts; + _makeRequest({ + $ = this, + path, + ...otherOpts + }) { return axios($, { ...otherOpts, - method, - url: this._baseUrl() + path, + url: `${this._baseUrl()}${path}`, headers: { - ...headers, - Authorization: `Bearer ${this.$auth.api_token}`, + "Authorization": `Bearer ${this.$auth.api_key}`, + "tenant-id": `${this.$auth.tenant_id}`, }, }); }, - async createContact(opts = {}) { + createContact(opts = {}) { return this._makeRequest({ method: "POST", - path: "/api/v1/contacts", - data: { - name: this.leadName, - phone: this.phone, - email: this.email, - initiation: this.initiation, - tags: this.tags, - status: this.status, - }, + path: "/contacts", ...opts, }); }, diff --git a/components/gloria_ai/package.json b/components/gloria_ai/package.json index ace12d7bdaf4f..0a3f48057feb3 100644 --- a/components/gloria_ai/package.json +++ b/components/gloria_ai/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/gloria_ai", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Gloria AI Components", "main": "gloria_ai.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } From 125f8aeca3a1815d2f3f1fd665a02f2693e9bf26 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 28 Jan 2025 13:06:25 -0500 Subject: [PATCH 3/3] pnpm-lock.yaml --- pnpm-lock.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0175fcf2a536f..6c41ad6820d1a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4171,7 +4171,11 @@ importers: components/glide: {} - components/gloria_ai: {} + components/gloria_ai: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/gloww: dependencies: @@ -5884,8 +5888,7 @@ importers: specifier: ^1.2.1 version: 1.6.6 - components/lightpanda: - specifiers: {} + components/lightpanda: {} components/lightspeed_retail_pos: dependencies: