Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions components/vida/actions/provide-context/provide-context.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
7 changes: 5 additions & 2 deletions components/vida/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/vida",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Vida Components",
"main": "vida.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
49 changes: 49 additions & 0 deletions components/vida/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -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,
});
}
},
};
Original file line number Diff line number Diff line change
@@ -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,
};
50 changes: 50 additions & 0 deletions components/vida/sources/new-conversation-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -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": []
}
Original file line number Diff line number Diff line change
@@ -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,
};
Original file line number Diff line number Diff line change
@@ -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": []
}
44 changes: 40 additions & 4 deletions components/vida/vida.app.mjs
Original file line number Diff line number Diff line change
@@ -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,
});
},
},
};
Loading
Loading