Skip to content

Commit c4ba5f7

Browse files
authored
New Components - vida (#14143)
* vida init * [Components] vida #14121 Sources - New Incoming Conversation (Instant) - New Conversation (Instant) Actions - Provide Context * pnpm update
1 parent 80bc90f commit c4ba5f7

File tree

9 files changed

+272
-7
lines changed

9 files changed

+272
-7
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import vida from "../../vida.app.mjs";
2+
3+
export default {
4+
key: "vida-provide-context",
5+
name: "Add Context",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
vida,
11+
target: {
12+
type: "string",
13+
label: "Target",
14+
description: "Phone number in E.164 format or VIDA username of the user.",
15+
},
16+
context: {
17+
type: "string",
18+
label: "Context",
19+
description: "Context information to inject",
20+
},
21+
},
22+
async run({ $ }) {
23+
const response = await this.vida.addContext({
24+
$,
25+
data: {
26+
target: this.target,
27+
context: this.context,
28+
},
29+
});
30+
$.export("$summary", `Successfully uploaded additional context for target ${this.target}`);
31+
return response;
32+
},
33+
};

components/vida/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/vida",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Vida Components",
55
"main": "vida.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import vida from "../../vida.app.mjs";
2+
3+
export default {
4+
props: {
5+
vida,
6+
http: {
7+
type: "$.interface.http",
8+
customResponse: false,
9+
},
10+
db: "$.service.db",
11+
label: {
12+
type: "string",
13+
label: "Label",
14+
description: "Friendly label for webhook",
15+
},
16+
},
17+
methods: {
18+
filterEvent() {
19+
return true;
20+
},
21+
},
22+
hooks: {
23+
async activate() {
24+
await this.vida.createWebhook({
25+
data: {
26+
url: this.http.endpoint,
27+
label: this.label,
28+
type: "conversation",
29+
},
30+
});
31+
},
32+
async deactivate() {
33+
await this.vida.deleteWebhook({
34+
data: {
35+
url: this.http.endpoint,
36+
},
37+
});
38+
},
39+
},
40+
async run({ body }) {
41+
if (this.filterEvent(body)) {
42+
this.$emit(body, {
43+
id: body.uuid,
44+
summary: this.getSummary(body),
45+
ts: body.timestamp,
46+
});
47+
}
48+
},
49+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "vida-new-conversation-instant",
7+
name: "New Conversation (Instant)",
8+
description: "Emit new events after completion of any communication handled by your Vida AI agent, be it a call, text, or email.",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getSummary(event) {
15+
return `New conversation created: ${event.uuid}`;
16+
},
17+
},
18+
sampleEmit,
19+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
export default {
2+
"from": 999999999999,
3+
"fromUser": "integrations__test",
4+
"to": 1269579,
5+
"toUser": "integrations",
6+
"rate": 0,
7+
"usdRate": 0,
8+
"timestamp": 1727728969,
9+
"date": "2024-09-30T20:42:49.000Z",
10+
"message": "Call from integrations",
11+
"content-type": "text/plain",
12+
"disposition-notification": null,
13+
"roomId": "1269579:1269579",
14+
"status": "success",
15+
"attachments": [],
16+
"isLive": false,
17+
"aiAgent": false,
18+
"aiReward": null,
19+
"aiRewardUsd": null,
20+
"aiLeadRating": null,
21+
"aiLeadRatingReason": null,
22+
"aiAgentOverride": null,
23+
"gift": false,
24+
"source": "call",
25+
"uuid": "86547d26-9b89-41a6-afd1-292085c9b846",
26+
"campaignId": "campa861346f6104e3e4762ef5b936e2984fb",
27+
"fromNumber": "+1234567890",
28+
"toNumber": "integrations",
29+
"notify": false,
30+
"targetInbox": "inbox",
31+
"type": "call",
32+
"duration": 1,
33+
"direction": "outbound",
34+
"missedCall": false,
35+
"bypassAgent": false,
36+
"cnamSpam": false,
37+
"selfCall": true,
38+
"callingUserIsContact": false,
39+
"agentOutcome": null,
40+
"summary": null,
41+
"callDialog": [],
42+
"campaign": true,
43+
"diversion": null,
44+
"voicemailRecording": null,
45+
"eventType": "outbound-call",
46+
"forcedCampaign": true,
47+
"conversation": "",
48+
"collectedData": null,
49+
"functionsRun": []
50+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "vida-new-incoming-conversation-instant",
7+
name: "New Incoming Conversation (Instant)",
8+
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.",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getSummary(event) {
15+
return `New incoming ${event.body.communicationSource} from ${event.body.source}`;
16+
},
17+
filterEvents(body) {
18+
return body.direction === "inbound";
19+
},
20+
},
21+
sampleEmit,
22+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
export default {
2+
"from": 999999999999,
3+
"fromUser": "integrations__test",
4+
"to": 1269579,
5+
"toUser": "integrations",
6+
"rate": 0,
7+
"usdRate": 0,
8+
"timestamp": 1727728969,
9+
"date": "2024-09-30T20:42:49.000Z",
10+
"message": "Call from integrations",
11+
"content-type": "text/plain",
12+
"disposition-notification": null,
13+
"roomId": "1269579:1269579",
14+
"status": "success",
15+
"attachments": [],
16+
"isLive": false,
17+
"aiAgent": false,
18+
"aiReward": null,
19+
"aiRewardUsd": null,
20+
"aiLeadRating": null,
21+
"aiLeadRatingReason": null,
22+
"aiAgentOverride": null,
23+
"gift": false,
24+
"source": "call",
25+
"uuid": "86547d26-9b89-41a6-afd1-292085c9b846",
26+
"campaignId": "campa861346f6104e3e4762ef5b936e2984fb",
27+
"fromNumber": "+1234567890",
28+
"toNumber": "integrations",
29+
"notify": false,
30+
"targetInbox": "inbox",
31+
"type": "call",
32+
"duration": 1,
33+
"direction": "inbound",
34+
"missedCall": false,
35+
"bypassAgent": false,
36+
"cnamSpam": false,
37+
"selfCall": true,
38+
"callingUserIsContact": false,
39+
"agentOutcome": null,
40+
"summary": null,
41+
"callDialog": [],
42+
"campaign": true,
43+
"diversion": null,
44+
"voicemailRecording": null,
45+
"eventType": "inbound-call",
46+
"forcedCampaign": true,
47+
"conversation": "",
48+
"collectedData": null,
49+
"functionsRun": []
50+
}

components/vida/vida.app.mjs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "vida",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
_baseUrl() {
8+
return "https://api.vida.dev/api/v2";
9+
},
10+
_params(params = {}) {
11+
return {
12+
...params,
13+
token: `${this.$auth.api_token}`,
14+
};
15+
},
16+
_makeRequest({
17+
$ = this, path, params, ...opts
18+
}) {
19+
return axios($, {
20+
url: this._baseUrl() + path,
21+
params: this._params(params),
22+
...opts,
23+
});
24+
},
25+
addContext(opts = {}) {
26+
return this._makeRequest({
27+
method: "POST",
28+
path: "/context",
29+
...opts,
30+
});
31+
},
32+
createWebhook(opts = {}) {
33+
return this._makeRequest({
34+
method: "POST",
35+
path: "/webhooks",
36+
...opts,
37+
});
38+
},
39+
deleteWebhook(opts = {}) {
40+
return this._makeRequest({
41+
method: "DELETE",
42+
path: "/webhooks",
43+
...opts,
44+
});
945
},
1046
},
1147
};

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)