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
83 changes: 83 additions & 0 deletions components/chattermill/actions/create-response/create-response.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import chattermill from "../../chattermill.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "chattermill-create-response",
name: "Create Response",
description: "Create response model with given attributes. [See the documentation](https://apidocs.chattermill.com/#70001058-ac53-eec1-7c44-c836fb0b2489)",
version: "0.0.1",
type: "action",
props: {
chattermill,
projectId: {
propDefinition: [
chattermill,
"projectId",
],
},
score: {
type: "integer",
label: "Score",
description: "A score of 1 - 10 to add to the response",
min: 1,
max: 10,
},
comment: {
type: "string",
label: "Comment",
description: "The comment to add to the response",
},
userMeta: {
propDefinition: [
chattermill,
"userMeta",
],
},
segments: {
propDefinition: [
chattermill,
"segments",
],
},
dataType: {
propDefinition: [
chattermill,
"dataType",
(c) => ({
projectId: c.projectId,
}),
],
},
dataSource: {
propDefinition: [
chattermill,
"dataSource",
(c) => ({
projectId: c.projectId,
}),
],
},
},
async run({ $ }) {
try {
const response = await this.chattermill.createResponse({
$,
projectId: this.projectId,
data: {
response: {
score: this.score,
comment: this.comment,
user_meta: parseObject(this.userMeta),
segments: parseObject(this.segments),
data_type: this.dataType,
data_source: this.dataSource,
},
},
});
$.export("$summary", "Successfully created response.");
return response;
} catch {
throw new Error("Failed to create response");
}
},
};
36 changes: 36 additions & 0 deletions components/chattermill/actions/get-response/get-response.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import chattermill from "../../chattermill.app.mjs";

export default {
key: "chattermill-get-response",
name: "Get Response",
description: "Get a response by ID. [See the documentation](https://apidocs.chattermill.com/#ace8b4a6-4e39-a1d2-e443-2ed1f10cd589)",
version: "0.0.1",
type: "action",
props: {
chattermill,
projectId: {
propDefinition: [
chattermill,
"projectId",
],
},
responseId: {
propDefinition: [
chattermill,
"responseId",
(c) => ({
projectId: c.projectId,
}),
],
},
},
async run({ $ }) {
const response = await this.chattermill.getResponse({
$,
projectId: this.projectId,
responseId: this.responseId,
});
$.export("$summary", `Successfully retrieved response with ID: ${this.responseId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import chattermill from "../../chattermill.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "chattermill-search-responses",
name: "Search Responses",
description: "Search for responses. [See the documentation](https://apidocs.chattermill.com/#3dd30375-7956-b872-edbd-873eef126b2d)",
version: "0.0.1",
type: "action",
props: {
chattermill,
projectId: {
propDefinition: [
chattermill,
"projectId",
],
},
filterProperty: {
type: "string",
label: "Filter Property",
description: "Segment property to filter by",
optional: true,
},
filterValue: {
type: "string",
label: "Filter Value",
description: "Segment value to filter by",
optional: true,
},
maxResults: {
type: "integer",
label: "Max Results",
description: "The maximum number of results to return",
default: 100,
optional: true,
},
},
async run({ $ }) {
if ((this.filterProperty && !this.filterValue)
|| (!this.filterProperty && this.filterValue)) {
throw new ConfigurationError("Filter Property and Value must be provided together");
}

const responses = await this.chattermill.getPaginatedResources({
fn: this.chattermill.listResponses,
args: {
$,
projectId: this.projectId,
params: {
filter_property: this.filterProperty,
filter_value: this.filterValue,
},
},
resourceKey: "responses",
max: this.maxResults,
});

$.export("$summary", `Found ${responses.length} responses.`);
return responses;
},
};
57 changes: 57 additions & 0 deletions components/chattermill/actions/update-response/update-response.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import chattermill from "../../chattermill.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "chattermill-update-response",
name: "Update Response",
description: "Update a response by ID. [See the documentation](https://apidocs.chattermill.com/#a632c60d-ccda-74b3-b9e7-b5a0c4917e1a)",
version: "0.0.1",
type: "action",
props: {
chattermill,
projectId: {
propDefinition: [
chattermill,
"projectId",
],
},
responseId: {
propDefinition: [
chattermill,
"responseId",
(c) => ({
projectId: c.projectId,
}),
],
},
userMeta: {
propDefinition: [
chattermill,
"userMeta",
],
optional: true,
},
segments: {
propDefinition: [
chattermill,
"segments",
],
optional: true,
},
},
async run({ $ }) {
const response = await this.chattermill.updateResponse({
$,
projectId: this.projectId,
responseId: this.responseId,
data: {
response: {
user_meta: parseObject(this.userMeta),
segments: parseObject(this.segments),
},
},
});
$.export("$summary", `Successfully updated response with ID: ${this.responseId}`);
return response;
},
};
Loading
Loading