diff --git a/components/vida/actions/provide-context/provide-context.mjs b/components/vida/actions/provide-context/provide-context.mjs new file mode 100644 index 0000000000000..f769a2ec5447d --- /dev/null +++ b/components/vida/actions/provide-context/provide-context.mjs @@ -0,0 +1,33 @@ +import vida from "../../vida.app.mjs"; + +export default { + key: "vida-provide-context", + name: "Add Context", + description: "Uploads additional context for a conversation with your AI agent. Helpful when integrating data from external CRMs. [See the documentation](https://vida.io/docs/api-reference/knowledge/add-context)", + version: "0.0.1", + type: "action", + props: { + vida, + target: { + type: "string", + label: "Target", + description: "Phone number in E.164 format or VIDA username of the user.", + }, + context: { + type: "string", + label: "Context", + description: "Context information to inject", + }, + }, + async run({ $ }) { + const response = await this.vida.addContext({ + $, + data: { + target: this.target, + context: this.context, + }, + }); + $.export("$summary", `Successfully uploaded additional context for target ${this.target}`); + return response; + }, +}; diff --git a/components/vida/package.json b/components/vida/package.json index b1ef97ce5e328..a1d6419c2b19d 100644 --- a/components/vida/package.json +++ b/components/vida/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/vida", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Vida Components", "main": "vida.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/components/vida/sources/common/base.mjs b/components/vida/sources/common/base.mjs new file mode 100644 index 0000000000000..c022d76a02b75 --- /dev/null +++ b/components/vida/sources/common/base.mjs @@ -0,0 +1,49 @@ +import vida from "../../vida.app.mjs"; + +export default { + props: { + vida, + http: { + type: "$.interface.http", + customResponse: false, + }, + db: "$.service.db", + label: { + type: "string", + label: "Label", + description: "Friendly label for webhook", + }, + }, + methods: { + filterEvent() { + return true; + }, + }, + hooks: { + async activate() { + await this.vida.createWebhook({ + data: { + url: this.http.endpoint, + label: this.label, + type: "conversation", + }, + }); + }, + async deactivate() { + await this.vida.deleteWebhook({ + data: { + url: this.http.endpoint, + }, + }); + }, + }, + async run({ body }) { + if (this.filterEvent(body)) { + this.$emit(body, { + id: body.uuid, + summary: this.getSummary(body), + ts: body.timestamp, + }); + } + }, +}; diff --git a/components/vida/sources/new-conversation-instant/new-conversation-instant.mjs b/components/vida/sources/new-conversation-instant/new-conversation-instant.mjs new file mode 100644 index 0000000000000..ebfceeee634ee --- /dev/null +++ b/components/vida/sources/new-conversation-instant/new-conversation-instant.mjs @@ -0,0 +1,19 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "vida-new-conversation-instant", + name: "New Conversation (Instant)", + description: "Emit new events after completion of any communication handled by your Vida AI agent, be it a call, text, or email.", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getSummary(event) { + return `New conversation created: ${event.uuid}`; + }, + }, + sampleEmit, +}; diff --git a/components/vida/sources/new-conversation-instant/test-event.mjs b/components/vida/sources/new-conversation-instant/test-event.mjs new file mode 100644 index 0000000000000..a628e5d61d40f --- /dev/null +++ b/components/vida/sources/new-conversation-instant/test-event.mjs @@ -0,0 +1,50 @@ +export default { + "from": 999999999999, + "fromUser": "integrations__test", + "to": 1269579, + "toUser": "integrations", + "rate": 0, + "usdRate": 0, + "timestamp": 1727728969, + "date": "2024-09-30T20:42:49.000Z", + "message": "Call from integrations", + "content-type": "text/plain", + "disposition-notification": null, + "roomId": "1269579:1269579", + "status": "success", + "attachments": [], + "isLive": false, + "aiAgent": false, + "aiReward": null, + "aiRewardUsd": null, + "aiLeadRating": null, + "aiLeadRatingReason": null, + "aiAgentOverride": null, + "gift": false, + "source": "call", + "uuid": "86547d26-9b89-41a6-afd1-292085c9b846", + "campaignId": "campa861346f6104e3e4762ef5b936e2984fb", + "fromNumber": "+1234567890", + "toNumber": "integrations", + "notify": false, + "targetInbox": "inbox", + "type": "call", + "duration": 1, + "direction": "outbound", + "missedCall": false, + "bypassAgent": false, + "cnamSpam": false, + "selfCall": true, + "callingUserIsContact": false, + "agentOutcome": null, + "summary": null, + "callDialog": [], + "campaign": true, + "diversion": null, + "voicemailRecording": null, + "eventType": "outbound-call", + "forcedCampaign": true, + "conversation": "", + "collectedData": null, + "functionsRun": [] +} \ No newline at end of file diff --git a/components/vida/sources/new-incoming-conversation-instant/new-incoming-conversation-instant.mjs b/components/vida/sources/new-incoming-conversation-instant/new-incoming-conversation-instant.mjs new file mode 100644 index 0000000000000..1415d0135ea83 --- /dev/null +++ b/components/vida/sources/new-incoming-conversation-instant/new-incoming-conversation-instant.mjs @@ -0,0 +1,22 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "vida-new-incoming-conversation-instant", + name: "New Incoming Conversation (Instant)", + description: "Emit new event when an incoming call or message is received before answered by an agent. Useful for providing context about the caller or messenger to your agent before response.", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getSummary(event) { + return `New incoming ${event.body.communicationSource} from ${event.body.source}`; + }, + filterEvents(body) { + return body.direction === "inbound"; + }, + }, + sampleEmit, +}; diff --git a/components/vida/sources/new-incoming-conversation-instant/test-event.mjs b/components/vida/sources/new-incoming-conversation-instant/test-event.mjs new file mode 100644 index 0000000000000..3f99116e529d6 --- /dev/null +++ b/components/vida/sources/new-incoming-conversation-instant/test-event.mjs @@ -0,0 +1,50 @@ +export default { + "from": 999999999999, + "fromUser": "integrations__test", + "to": 1269579, + "toUser": "integrations", + "rate": 0, + "usdRate": 0, + "timestamp": 1727728969, + "date": "2024-09-30T20:42:49.000Z", + "message": "Call from integrations", + "content-type": "text/plain", + "disposition-notification": null, + "roomId": "1269579:1269579", + "status": "success", + "attachments": [], + "isLive": false, + "aiAgent": false, + "aiReward": null, + "aiRewardUsd": null, + "aiLeadRating": null, + "aiLeadRatingReason": null, + "aiAgentOverride": null, + "gift": false, + "source": "call", + "uuid": "86547d26-9b89-41a6-afd1-292085c9b846", + "campaignId": "campa861346f6104e3e4762ef5b936e2984fb", + "fromNumber": "+1234567890", + "toNumber": "integrations", + "notify": false, + "targetInbox": "inbox", + "type": "call", + "duration": 1, + "direction": "inbound", + "missedCall": false, + "bypassAgent": false, + "cnamSpam": false, + "selfCall": true, + "callingUserIsContact": false, + "agentOutcome": null, + "summary": null, + "callDialog": [], + "campaign": true, + "diversion": null, + "voicemailRecording": null, + "eventType": "inbound-call", + "forcedCampaign": true, + "conversation": "", + "collectedData": null, + "functionsRun": [] +} \ No newline at end of file diff --git a/components/vida/vida.app.mjs b/components/vida/vida.app.mjs index 965a2403b4154..c0baba25e0e57 100644 --- a/components/vida/vida.app.mjs +++ b/components/vida/vida.app.mjs @@ -1,11 +1,47 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "vida", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.vida.dev/api/v2"; + }, + _params(params = {}) { + return { + ...params, + token: `${this.$auth.api_token}`, + }; + }, + _makeRequest({ + $ = this, path, params, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + params: this._params(params), + ...opts, + }); + }, + addContext(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/context", + ...opts, + }); + }, + createWebhook(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/webhooks", + ...opts, + }); + }, + deleteWebhook(opts = {}) { + return this._makeRequest({ + method: "DELETE", + path: "/webhooks", + ...opts, + }); }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 926c70f486320..1b83edc102a23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10635,7 +10635,10 @@ importers: '@pipedream/platform': 2.0.0 components/vida: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/videoask: specifiers: {} @@ -12850,55 +12853,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: - resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sts': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sts' - - aws-crt - dev: false - /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13134,7 +13088,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 + '@aws-sdk/client-sso-oidc': 3.600.0 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13176,6 +13130,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: + resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + dev: false + /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -17502,7 +17505,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6