diff --git a/components/heylibby/actions/list-qualified-leads/list-qualified-leads.mjs b/components/heylibby/actions/list-qualified-leads/list-qualified-leads.mjs new file mode 100644 index 0000000000000..3c7b86e2595bb --- /dev/null +++ b/components/heylibby/actions/list-qualified-leads/list-qualified-leads.mjs @@ -0,0 +1,21 @@ +import heylibby from "../../heylibby.app.mjs"; + +export default { + key: "heylibby-list-qualified-leads", + name: "List Qualified Leads", + description: "List qualified leads.", + version: "0.0.1", + type: "action", + props: { + heylibby, + }, + async run({ $ }) { + const response = await this.heylibby.listQualifiedLeads({ + $, + }); + $.export("$summary", `Successfully listed ${response.length} qualified lead${response.length === 1 + ? "" + : "s"}`); + return response; + }, +}; diff --git a/components/heylibby/heylibby.app.mjs b/components/heylibby/heylibby.app.mjs index 2578ea65fcea3..29d51416e2300 100644 --- a/components/heylibby/heylibby.app.mjs +++ b/components/heylibby/heylibby.app.mjs @@ -1,11 +1,27 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "heylibby", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://3wsq3v2kgg.execute-api.us-east-1.amazonaws.com/prod/zapier/trigger"; + }, + _makeRequest({ + $ = this, params = {}, ...opts + }) { + return axios($, { + url: this._baseUrl(), + params: { + ...params, + zapierAPI: this.$auth.api_key, + }, + ...opts, + }); + }, + listQualifiedLeads(opts = {}) { + return this._makeRequest(opts); }, }, }; diff --git a/components/heylibby/package.json b/components/heylibby/package.json index 910de30a2c223..66632873cbfa8 100644 --- a/components/heylibby/package.json +++ b/components/heylibby/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/heylibby", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream HeyLibby Components", "main": "heylibby.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/components/heylibby/sources/new-qualified-lead-created/new-qualified-lead-created.mjs b/components/heylibby/sources/new-qualified-lead-created/new-qualified-lead-created.mjs new file mode 100644 index 0000000000000..b45e6371ca0db --- /dev/null +++ b/components/heylibby/sources/new-qualified-lead-created/new-qualified-lead-created.mjs @@ -0,0 +1,55 @@ +import heylibby from "../../heylibby.app.mjs"; +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import sampleEmit from "./test-event.mjs"; + +export default { + key: "heylibby-new-qualified-lead-created", + name: "New Qualified Lead Created", + description: "Emit new event when a new qualified lead is created.", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + heylibby, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastTs() { + return this.db.get("lastTs") || 0; + }, + _setLastTs(ts) { + this.db.set("lastTs", ts); + }, + generateMeta(lead) { + return { + id: lead.id, + summary: `New Lead ID: ${lead.id}`, + ts: Date.parse(lead.datetime), + }; + }, + }, + async run() { + const lastTs = this._getLastTs(); + let maxTs = lastTs; + const leads = await this.heylibby.listQualifiedLeads(); + if (!leads?.length) { + return; + } + for (const lead of leads) { + const ts = Date.parse(lead.datetime); + if (ts > lastTs) { + const meta = this.generateMeta(lead); + this.$emit(lead, meta); + maxTs = Math.max(maxTs, ts); + } + } + this._setLastTs(maxTs); + }, + sampleEmit, +}; diff --git a/components/heylibby/sources/new-qualified-lead-created/test-event.mjs b/components/heylibby/sources/new-qualified-lead-created/test-event.mjs new file mode 100644 index 0000000000000..6f2e5f637f467 --- /dev/null +++ b/components/heylibby/sources/new-qualified-lead-created/test-event.mjs @@ -0,0 +1,21 @@ +export default { + "id": "f5652b14-80aa-4cfb-82e9-688d7d373209", + "summary": "Not enough information for a summary.", + "name": null, + "email": null, + "phone": "", + "streetAddress": null, + "city": null, + "state": null, + "zipCode": null, + "country": null, + "qualification": "qualified", + "nextStep": "Recommend follow-up email", + "status": "New", + "htmlChat": "", + "chat": "• assistant: Hi, I'm the AI assistant.\n", + "datetime": "2025-06-05T19:52:54.388Z", + "channel": "phone", + "leftVoicemail": false, + "sentLinks": null + } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81a357245fbf5..b69ce320e433d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6092,7 +6092,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/heylibby: {} + components/heylibby: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/heyreach: {} @@ -18733,6 +18737,9 @@ packages: '@pipedream/platform@3.0.3': resolution: {integrity: sha512-7elalas41lnT8i6EAFkqB7fT/+hkLGEQ1njS6A7CVguTrEswaIYk/seKmkfkRY7+O6qncgnXswYIKCBML9Co7w==} + '@pipedream/platform@3.1.0': + resolution: {integrity: sha512-ELmV3fpd9PIUm74/RPaqmA7hJaY4ryIn6PCNT1NP/gnqMrkRNOAr+DTV4xPaJgPiRm74WC5HvrkC8YdRveXzZA==} + '@pipedream/postgresql@2.2.3': resolution: {integrity: sha512-Co9r4UKvvimEPo9T4v+EfVn/Sqqw8+X7PtvsAF7tydq7CHpkmOT9eYAiD0Kuybg5WbuWuqDaXHHmhVtsAxgpBw==} @@ -35456,7 +35463,7 @@ snapshots: '@pipedream/linear_app@0.7.1': dependencies: '@linear/sdk': 13.0.0 - '@pipedream/platform': 3.0.3 + '@pipedream/platform': 3.1.0 transitivePeerDependencies: - debug - encoding @@ -35471,7 +35478,7 @@ snapshots: '@pipedream/monday@0.7.0': dependencies: - '@pipedream/platform': 3.0.3 + '@pipedream/platform': 3.1.0 form-data: 4.0.2 lodash.flatmap: 4.5.0 lodash.map: 4.6.0 @@ -35484,7 +35491,7 @@ snapshots: '@pipedream/notion@0.6.2': dependencies: '@notionhq/client': 2.3.0 - '@pipedream/platform': 3.0.3 + '@pipedream/platform': 3.1.0 '@tryfabric/martian': 1.2.4 lodash-es: 4.17.21 notion-to-md: 3.1.8 @@ -35590,6 +35597,17 @@ snapshots: transitivePeerDependencies: - debug + '@pipedream/platform@3.1.0': + dependencies: + axios: 1.9.0 + fp-ts: 2.16.10 + io-ts: 2.2.22(fp-ts@2.16.10) + mime-types: 3.0.1 + querystring: 0.2.1 + uuid: 11.1.0 + transitivePeerDependencies: + - debug + '@pipedream/postgresql@2.2.3': dependencies: '@pipedream/platform': 2.0.0 @@ -35601,13 +35619,13 @@ snapshots: '@pipedream/quickbooks@0.5.1': dependencies: - '@pipedream/platform': 3.0.3 + '@pipedream/platform': 3.1.0 transitivePeerDependencies: - debug '@pipedream/ramp@0.1.2': dependencies: - '@pipedream/platform': 3.0.3 + '@pipedream/platform': 3.1.0 uuid: 10.0.0 transitivePeerDependencies: - debug @@ -35644,14 +35662,14 @@ snapshots: '@pipedream/sftp@0.4.1': dependencies: - '@pipedream/platform': 3.0.3 + '@pipedream/platform': 3.1.0 ssh2-sftp-client: 11.0.0 transitivePeerDependencies: - debug '@pipedream/shopify@0.7.0': dependencies: - '@pipedream/platform': 3.0.3 + '@pipedream/platform': 3.1.0 async-retry: 1.3.3 bottleneck: 2.19.5 form-data: 4.0.2