diff --git a/components/repliq/actions/get-credits-count/get-credits-count.mjs b/components/repliq/actions/get-credits-count/get-credits-count.mjs new file mode 100644 index 0000000000000..774bd968f9af4 --- /dev/null +++ b/components/repliq/actions/get-credits-count/get-credits-count.mjs @@ -0,0 +1,19 @@ +import repliq from "../../repliq.app.mjs"; + +export default { + key: "repliq-get-credits-count", + name: "Get Credits Count", + description: "Retrieve the total number of credits left for the month. [See the documentation](https://developer.repliq.co/get/g1-credits-count)", + version: "0.0.1", + type: "action", + props: { + repliq, + }, + async run({ $ }) { + const response = await this.repliq.getCreditsCount({ + $, + }); + $.export("$summary", `Successfully retrieved credits count: ${response.creditsCount}`); + return response; + }, +}; diff --git a/components/repliq/actions/launch-template/launch-template.mjs b/components/repliq/actions/launch-template/launch-template.mjs new file mode 100644 index 0000000000000..fbe1e8d550da1 --- /dev/null +++ b/components/repliq/actions/launch-template/launch-template.mjs @@ -0,0 +1,57 @@ +import { predefinedProps } from "../../common/props.mjs"; +import repliq from "../../repliq.app.mjs"; + +export default { + key: "repliq-launch-template", + name: "Launch Repliq Template", + description: "Launch a Repliq process by deploying the selected template. [See the documentation](https://developer.repliq.co/)", + version: "0.0.1", + type: "action", + props: { + repliq, + templateId: { + propDefinition: [ + repliq, + "templateId", + ], + reloadProps: true, + }, + }, + async additionalProps() { + let props = {}; + if (this.templateId) { + const templates = await this.repliq.listTemplates(); + const template = templates.find((item) => item.id === this.templateId); + + props = { + ...predefinedProps[template.type], + email: { + type: "string", + label: "Email", + description: "The account email you want to send this result to.", + optional: true, + }, + webhook: { + type: "string", + label: "Webhook", + description: "Attach a webhook URL that will trigger when the process is ready for you to use. You cannot use multiple URLs.", + optional: true, + }, + }; + } + return props; + }, + async run({ $ }) { + const { + repliq, + ...data + } = this; + + const response = await repliq.launchTemplate({ + $, + data, + }); + $.export("$summary", `Successfully launched template with ID ${this.templateId}`); + return response; + }, +}; diff --git a/components/repliq/common/props.mjs b/components/repliq/common/props.mjs new file mode 100644 index 0000000000000..13ceef0f39436 --- /dev/null +++ b/components/repliq/common/props.mjs @@ -0,0 +1,109 @@ +const url = { + type: "string", + label: "URL", + description: "The url of the website you want to use.", +}; +const firstName = { + type: "string", + label: "First Name", + description: "The name of the person you create the process for.", +}; +const lastName = { + type: "string", + label: "Last Name", + description: "The last name of the person you create the process for.", + optional: true, +}; +const companyName = { + type: "string", + label: "Company Name", + description: "The name of the company you create the process for.", +}; +const jobTitle = { + type: "string", + label: "Job Title", + description: "The Job Title of the person you create the process for.", + optional: true, +}; +const icebreaker = { + type: "string", + label: "Icebreaker", + description: "Use an icebreaker as introduction for your process specific to the person you create the process for.", + optional: true, +}; +const yourCustomVariable = { + type: "string", + label: "Your Custom Variable", + description: "The yourCustomVariable you use for your process.", + optional: true, +}; + +export const predefinedProps = { + ai_image: { + firstName, + lastName, + jobTitle, + companyName: { + ...companyName, + optional: true, + }, + yourCustomVariable, + }, + ai_avatar: { + url, + companyName: { + ...companyName, + optional: true, + }, + firstName: { + ...firstName, + optional: true, + }, + jobTitle, + icebreaker, + }, + gpt_image: { + companyName, + firstName: { + ...firstName, + optional: true, + }, + lastName, + jobTitle, + competion: { + type: "string", + label: "Competion", + description: "The competion of the company you create an image for.", + optional: true, + }, + yourCustomVariable, + }, + icebreaker: { + url, + firstName, + }, + text_to_video: { + firstName, + prospectImgUrl: { + type: "string", + label: "Prospect Img URL", + description: "The linkedin profile url of the person you want to reach out to.", + optional: true, + }, + lastName, + companyName: { + ...companyName, + optional: true, + }, + jobTitle, + icebreaker, + }, + video_scale: { + url, + firstName: { + ...firstName, + optional: true, + }, + lastName, + }, +}; diff --git a/components/repliq/package.json b/components/repliq/package.json index ef9b003a5082c..1bb671ce35da6 100644 --- a/components/repliq/package.json +++ b/components/repliq/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/repliq", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream RepliQ Components", "main": "repliq.app.mjs", "keywords": [ @@ -11,5 +11,9 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^2.0.0" } -} \ No newline at end of file +} + diff --git a/components/repliq/repliq.app.mjs b/components/repliq/repliq.app.mjs index a892ed56397f6..771e9112b5da1 100644 --- a/components/repliq/repliq.app.mjs +++ b/components/repliq/repliq.app.mjs @@ -1,11 +1,63 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "repliq", - propDefinitions: {}, + propDefinitions: { + templateId: { + type: "string", + label: "Template ID", + description: "The ID of the template you want to deploy.", + async options() { + const templates = await this.listTemplates(); + if (templates.error) return []; + + return templates.map(({ + id: value, name: label, + }) => ({ + label, + value, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.repliq.co/v2"; + }, + _headers() { + return { + Authorization: `Bearer ${this.$auth.api_key}`, + }; + }, + _makeRequest({ + $ = this, + path, + ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(), + ...opts, + }); + }, + getCreditsCount(opts = {}) { + return this._makeRequest({ + path: "/getCreditsCount", + ...opts, + }); + }, + listTemplates() { + return this._makeRequest({ + path: "/getTemplateList", + }); + }, + launchTemplate(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/launchTemplate", + ...opts, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 34679d91049ab..9cb0adb6200f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7261,7 +7261,10 @@ importers: '@pipedream/platform': 1.5.1 components/repliq: - specifiers: {} + specifiers: + '@pipedream/platform': ^2.0.0 + dependencies: + '@pipedream/platform': 2.0.0 components/reply_io: specifiers: