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..b1420a5be1f90 --- /dev/null +++ b/components/gloria_ai/actions/create-lead/create-lead.mjs @@ -0,0 +1,72 @@ +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](https://api.iamgloria.com/api).", + version: "0.0.1", + type: "action", + props: { + gloriaAi, + leadName: { + propDefinition: [ + gloriaAi, + "leadName", + ], + }, + phone: { + propDefinition: [ + gloriaAi, + "phone", + ], + }, + email: { + propDefinition: [ + gloriaAi, + "email", + ], + }, + initiation: { + propDefinition: [ + gloriaAi, + "initiation", + ], + }, + tags: { + propDefinition: [ + gloriaAi, + "tags", + ], + }, + status: { + propDefinition: [ + gloriaAi, + "status", + ], + }, + }, + async run({ $ }) { + 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 a3e1944472a89..10245bf98797d 100644 --- a/components/gloria_ai/gloria_ai.app.mjs +++ b/components/gloria_ai/gloria_ai.app.mjs @@ -1,11 +1,78 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "gloria_ai", - propDefinitions: {}, + 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", + options: [ + "Inbound", + "Outbound", + ], + 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", + options: [ + "active", + "archived", + "favorite", + ], + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.iamgloria.com/api/v1"; + }, + _makeRequest({ + $ = this, + path, + ...otherOpts + }) { + return axios($, { + ...otherOpts, + url: `${this._baseUrl()}${path}`, + headers: { + "Authorization": `Bearer ${this.$auth.api_key}`, + "tenant-id": `${this.$auth.tenant_id}`, + }, + }); + }, + createContact(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/contacts", + ...opts, + }); }, }, }; diff --git a/components/gloria_ai/package.json b/components/gloria_ai/package.json index 1a39e58475e28..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" } -} \ No newline at end of file +} 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: