Skip to content

Commit

Permalink
New Components - neuronwriter (PipedreamHQ#12155)
Browse files Browse the repository at this point in the history
* neuronwriter init

* [Components] neuronwriter PipedreamHQ#12067
Webhooks
 - New Query Processed
 - New Done Query

Actions
 - Create New Query
 - Get Query Details
 - Get Content Saved

* pnpm update

* Update components/neuronwriter/package.json

Co-authored-by: Jorge Cortes <[email protected]>

* some adjusts

---------

Co-authored-by: Jorge Cortes <[email protected]>
  • Loading branch information
luancazarine and jcortes authored May 31, 2024
1 parent eea62dd commit 0023fa2
Show file tree
Hide file tree
Showing 12 changed files with 1,256 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
ENGINE_OPTIONS, LANGUAGE_OPTIONS,
} from "../../common/constants.mjs";
import neuronwriter from "../../neuronwriter.app.mjs";

export default {
key: "neuronwriter-create-new-query",
name: "Create New Query",
description: "Launches a new query based on provided keyword, search engine, and language. [See the documentation](https://contadu.crisp.help/en/article/neuronwriter-api-how-to-use-2ds6hx/#3-new-query)",
version: "0.0.1",
type: "action",
props: {
neuronwriter,
keyword: {
type: "string",
label: "Keyword",
description: "The keyword to generate a query and recommendations for.",
},
searchEngine: {
type: "string",
label: "Search Engine",
description: "Preferred search engine.",
options: ENGINE_OPTIONS,
},
language: {
type: "string",
label: "Language",
description: "Content language.",
options: LANGUAGE_OPTIONS,
},
},
async run({ $ }) {
const response = await this.neuronwriter.createNewQuery({
$,
data: {
project: this.neuronwriter.$auth.project_id,
keyword: this.keyword,
engine: this.searchEngine,
language: this.language,
},
});

$.export("$summary", `Successfully created new query with Id: ${response.query}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import neuronwriter from "../../neuronwriter.app.mjs";

export default {
key: "neuronwriter-get-content-saved",
name: "Get Content Saved",
description: "Pulls the most recent revision of the content saved for a specific query. [See the documentation](https://contadu.crisp.help/en/article/neuronwriter-api-how-to-use-2ds6hx/#3-get-content)",
version: "0.0.1",
type: "action",
props: {
neuronwriter,
queryId: {
propDefinition: [
neuronwriter,
"queryId",
],
},
},
async run({ $ }) {
const response = await this.neuronwriter.getContent({
$,
data: {
query: this.queryId,
},
});
$.export("$summary", `Successfully retrieved the content for query ID ${this.queryId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import neuronwriter from "../../neuronwriter.app.mjs";

export default {
key: "neuronwriter-get-query-details",
name: "Get Query Details",
description: "Fetches the data related to a pre-defined query. [See the documentation](https://contadu.crisp.help/en/article/neuronwriter-api-how-to-use-2ds6hx/#3-get-query)",
version: "0.0.1",
type: "action",
props: {
neuronwriter,
queryId: {
propDefinition: [
neuronwriter,
"queryId",
],
},
},
async run({ $ }) {
const response = await this.neuronwriter.getQueryResults({
data: {
query: this.queryId,
},
});

let summary = `Successfully fetched query details for Query ID: ${this.queryId}`;
if (response.status != "ready") {
summary = `Query is not ready. Current status: ${response.status}`;
}

$.export("$summary", summary);
return response;
},
};
Loading

0 comments on commit 0023fa2

Please sign in to comment.