-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - chattermill #17649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - chattermill #17649
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
components/chattermill/actions/create-response/create-response.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
36
components/chattermill/actions/get-response/get-response.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
61 changes: 61 additions & 0 deletions
61
components/chattermill/actions/search-responses/search-responses.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
57
components/chattermill/actions/update-response/update-response.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.