-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] chatlayer #11573 #18261
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
35 changes: 35 additions & 0 deletions
35
components/chatlayer/actions/get-conversations/get-conversations.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,35 @@ | ||
| import app from "../../chatlayer.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "chatlayer-get-conversations", | ||
| name: "Get Conversations", | ||
| description: "Lists conversations with the specified bot. [See the documentation](https://api.chatlayer.ai/v1/docs#operation/getAllPaginatedConversationsByBotId)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| botId: { | ||
| propDefinition: [ | ||
| app, | ||
| "botId", | ||
| ], | ||
| }, | ||
| version: { | ||
| propDefinition: [ | ||
| app, | ||
| "version", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.getConversations({ | ||
| $, | ||
| botId: this.botId, | ||
| params: { | ||
| version: this.version, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully sent the request. Retrieved " + response.data.length + " results"); | ||
| return response; | ||
| }, | ||
| }; |
46 changes: 46 additions & 0 deletions
46
components/chatlayer/actions/get-session-data/get-session-data.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,46 @@ | ||
| import app from "../../chatlayer.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "chatlayer-get-session-data", | ||
| name: "Get Session Data", | ||
| description: "Gets data for the specified session. [See the documentation](https://api.chatlayer.ai/v1/docs#operation/getConversationSessionData)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| botId: { | ||
| propDefinition: [ | ||
| app, | ||
| "botId", | ||
| ], | ||
| }, | ||
| version: { | ||
| propDefinition: [ | ||
| app, | ||
| "version", | ||
| ], | ||
| }, | ||
| sessionId: { | ||
| propDefinition: [ | ||
| app, | ||
| "sessionId", | ||
| (c) => ({ | ||
| botId: c.botId, | ||
| version: c.version, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.getSessionData({ | ||
| $, | ||
| botId: this.botId, | ||
| sessionId: this.sessionId, | ||
| params: { | ||
| version: this.version, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully sent the request"); | ||
| return response; | ||
| }, | ||
| }; |
46 changes: 46 additions & 0 deletions
46
components/chatlayer/actions/list-messages/list-messages.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,46 @@ | ||
| import app from "../../chatlayer.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "chatlayer-list-messages", | ||
| name: "List Messages", | ||
| description: "Lists the messages of the specified session. [See the documentation](https://api.chatlayer.ai/v1/docs#operation/getAllMessagesInConversation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| botId: { | ||
| propDefinition: [ | ||
| app, | ||
| "botId", | ||
| ], | ||
| }, | ||
| version: { | ||
| propDefinition: [ | ||
| app, | ||
| "version", | ||
| ], | ||
| }, | ||
| sessionId: { | ||
| propDefinition: [ | ||
| app, | ||
| "sessionId", | ||
| (c) => ({ | ||
| botId: c.botId, | ||
| version: c.version, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.listMessages({ | ||
| $, | ||
| botId: this.botId, | ||
| sessionId: this.sessionId, | ||
| params: { | ||
| version: this.version, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully sent the request. Retrieved " + response.data.length + " results"); | ||
| return response; | ||
| }, | ||
| }; |
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 |
|---|---|---|
| @@ -1,11 +1,100 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import constants from "./common/constants.mjs"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "chatlayer", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| botId: { | ||
| type: "string", | ||
| label: "Bot ID", | ||
| description: "Unique identifier of the bot", | ||
| async options() { | ||
| const response = await this.getBots(); | ||
| return response.map(({ | ||
| id, name, | ||
| }) => ({ | ||
| value: id, | ||
| label: name, | ||
| })); | ||
| }, | ||
| }, | ||
| sessionId: { | ||
| type: "string", | ||
| label: "Session ID", | ||
| description: "Unique identifier of the user session", | ||
| async options({ | ||
| botId, version, | ||
| }) { | ||
| const response = await this.getConversations({ | ||
| botId, | ||
| params: { | ||
| version, | ||
| }, | ||
| }); | ||
| const sessions = response.data; | ||
| return sessions.map(({ user }) => ({ | ||
| value: user.sessionId, | ||
| })); | ||
| }, | ||
lcaresia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| version: { | ||
| type: "string", | ||
| label: "Version", | ||
| description: "Bot version to use", | ||
| options: constants.BOT_VERSIONS, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return `${this.$auth.url}`; | ||
| }, | ||
| async _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| headers, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| ...otherOpts, | ||
| url: this._baseUrl() + path, | ||
| headers: { | ||
| Authorization: `Bearer ${this.$auth.access_token}`, | ||
| ...headers, | ||
| }, | ||
| }); | ||
| }, | ||
|
|
||
| async getConversations({ | ||
| botId, ...args | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/v1/bots/${botId}/conversations`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| async listMessages({ | ||
| botId, sessionId, ...args | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/v1/bots/${botId}/conversations/${sessionId}/messages`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| async getSessionData({ | ||
| botId, sessionId, ...args | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/v1/bots/${botId}/conversations/${sessionId}/session-data`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| async getBots(args = {}) { | ||
| return this._makeRequest({ | ||
| path: "/v1/bots", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
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,6 @@ | ||
| export default { | ||
| BOT_VERSIONS: [ | ||
| "LIVE", | ||
| "DRAFT", | ||
| ], | ||
| }; |
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/chatlayer", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Chatlayer Components", | ||
| "main": "chatlayer.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.0" | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.