Skip to content

Commit 3a1bbdf

Browse files
Feat/add linkup component (#15257)
* add linkup component * add pnpm-lock file * add pnpm-lock file * change methode name * updates * pnpm-lock.yaml * pnpm-lock.yaml --------- Co-authored-by: juliette_sivan <juliette_sivan@carrefour.com> Co-authored-by: michelle0927 <michellelbergero@hotmail.com>
1 parent 5c394df commit 3a1bbdf

File tree

6 files changed

+189
-17
lines changed

6 files changed

+189
-17
lines changed

components/linkup/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Overview
2+
The Linkup API allows you to access and retrieve high-quality, real-time content from the internet for various use cases, including search, trend analysis, and contextual data gathering. By integrating the Linkup API with Pipedream, you can automate workflows that leverage Linkup's powerful search capabilities, enabling efficient data retrieval, content processing, and integration with other tools and platforms.
3+
4+
# Example Use Cases
5+
6+
- **Automated Content Research and Reporting:** Create a workflow that uses the Linkup API to perform automated searches based on specific queries. The results can be processed and stored in Google Sheets or a database for further analysis. This is particularly useful for market research, trend analysis, or competitive intelligence.
7+
8+
- **Slack Notifications for Trending Topics:** Use Pipedream to set up a workflow that triggers regular searches on trending topics using the Linkup API. The results can then be sent to a Slack channel, keeping your team informed about the latest developments in your industry.
9+
10+
- **Dynamic Content Generation for Marketing:** Integrate Linkup with a CMS or email marketing platform. Automatically fetch relevant content or insights from the Linkup API and embed them into newsletters, blog posts, or social media updates, ensuring fresh and engaging content for your audience.
11+
12+
- **Enhanced Customer Support Knowledge Base:** Use the Linkup API to fetch and update relevant, real-time information from trusted sources to enhance your customer support responses or update your knowledge base dynamically.
+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import app from "../../linkup.app.mjs";
2+
3+
export default {
4+
name: "Linkup Search",
5+
description: "Search and retrieve insights using the Linkup API. [See the documentation](https://docs.linkup.so/pages/api-reference/endpoint/post-search)",
6+
key: "linkup-search",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
query: {
12+
type: "string",
13+
label: "Query",
14+
description: "The search query for Linkup.",
15+
},
16+
depth: {
17+
type: "string",
18+
label: "Search Depth",
19+
description: "Defines the precision of the search. `standard` returns results quickly; `deep` takes longer but yields more complete results.",
20+
options: [
21+
"standard",
22+
"deep",
23+
],
24+
},
25+
outputType: {
26+
type: "string",
27+
label: "Output Type",
28+
description: "The type of output you want to get. Use `structured` for a custom-formatted response defined by `structuredOutputSchema`",
29+
options: [
30+
{
31+
value: "sourcedAnswer",
32+
label: "Natural language answer and its sources",
33+
},
34+
{
35+
value: "searchResults",
36+
label: "Raw context",
37+
},
38+
{
39+
value: "structured",
40+
label: "Json format of the response",
41+
},
42+
],
43+
reloadProps: true,
44+
},
45+
structuredOutputSchema: {
46+
type: "string",
47+
label: "Structured Output Schema",
48+
description: "Schema for structured output (only applicable if Output Type is 'structured'). Provide a JSON schema (as a string) representing the desired response format.",
49+
optional: true,
50+
hidden: true,
51+
},
52+
includeImages: {
53+
type: "boolean",
54+
label: "Include Images",
55+
description: "Defines whether the API should include images in its results",
56+
optional: true,
57+
},
58+
},
59+
additionalProps(props) {
60+
if (this.outputType === "structured") {
61+
props.structuredOutputSchema.optional = false;
62+
props.structuredOutputSchema.hidden = false;
63+
props.structuredOutputSchema.default = `{
64+
"type": "object",
65+
"properties": {
66+
"results": {
67+
"type": "array",
68+
"items": {
69+
"type": "object",
70+
"properties": {
71+
"name": {
72+
"type": "string"
73+
},
74+
"year": {
75+
"type": "number"
76+
}
77+
},
78+
"required": [
79+
"name",
80+
"year"
81+
],
82+
"additionalProperties": false
83+
}
84+
}
85+
},
86+
"required": [
87+
"results"
88+
],
89+
"additionalProperties": false
90+
}`;
91+
}
92+
return {};
93+
},
94+
async run({ $ }) {
95+
try {
96+
const response = await this.app.search({
97+
query: this.query,
98+
depth: this.depth,
99+
outputType: this.outputType,
100+
structuredOutputSchema:
101+
this.structuredOutputSchema && JSON.parse(this.structuredOutputSchema),
102+
includeImages: this.includeImages,
103+
});
104+
$.export("$summary", "Successfully completed search query");
105+
return response;
106+
} catch (error) {
107+
console.error("Error calling Linkup API:", error);
108+
throw new Error(`Failed to fetch data from Linkup API: ${error.message}`);
109+
}
110+
},
111+
};

components/linkup/linkup.app.mjs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
import { LinkupClient } from "linkup-sdk";
2+
13
export default {
24
type: "app",
35
app: "linkup",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_getClient() {
9+
return new LinkupClient({
10+
apiKey: this.$auth.api_key,
11+
});
12+
},
13+
search(params) {
14+
const client = this._getClient();
15+
return client.search(params);
916
},
1017
},
1118
};

components/linkup/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/linkup",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Linkup Components",
55
"main": "linkup.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"linkup-sdk": "^1.0.3"
1417
}
15-
}
18+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"@sentry/node": "^7.7.0",
8080
"@types/node": "^20.17.6",
8181
"crypto": "^1.0.1",
82+
"linkup-sdk": "^1.0.3",
8283
"uuid": "^8.3.2",
8384
"vue": "^2.6.14"
8485
},

pnpm-lock.yaml

+50-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)