-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - freshchat #17572
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 - freshchat #17572
Changes from 3 commits
Commits
Show all changes
4 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
34 changes: 34 additions & 0 deletions
34
components/freshchat/actions/fetch-conversation-details/fetch-conversation-details.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,34 @@ | ||
| import freshchat from "../../freshchat.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "freshchat-fetch-conversation-details", | ||
| name: "Fetch Conversation Details", | ||
| description: "Fetches details for a specific conversation. [See the documentation](https://developers.freshchat.com/api/#retrieve_a_conversation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| freshchat, | ||
| userId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "userId", | ||
| ], | ||
| }, | ||
| conversationId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "conversationId", | ||
| (c) => ({ | ||
| userId: c.userId, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.freshchat.getConversation({ | ||
| conversationId: this.conversationId, | ||
| }); | ||
| $.export("$summary", `Fetched conversation details for conversation ${this.conversationId}`); | ||
| 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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import freshchat from "../../freshchat.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "freshchat-list-agents", | ||
| name: "List Agents", | ||
| description: "Lists all agents in Freshchat. [See the documentation](https://developers.freshchat.com/api/#list_all_agents)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| freshchat, | ||
| groupId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "groupId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| isDeactivated: { | ||
| type: "boolean", | ||
| label: "Is Deactivated", | ||
| description: "Limits the response to agent objects whose is_deactivated value matches the parameter value", | ||
| optional: true, | ||
| }, | ||
| availabilityStatus: { | ||
| type: "string", | ||
| label: "Availability Status", | ||
| description: "Limits the response to agent objects whose availability_status value matches the parameter value", | ||
| options: [ | ||
| "AVAILABLE", | ||
| "UNAVAILABLE", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| maxResults: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "maxResults", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| try { | ||
| const response = await this.freshchat.getPaginatedResults({ | ||
| fn: this.freshchat.listAgents, | ||
| args: { | ||
| $, | ||
| params: { | ||
| groups: this.groupId, | ||
| is_deactivated: this.isDeactivated, | ||
| availability_status: this.availabilityStatus, | ||
| }, | ||
| }, | ||
| resourceKey: "agents", | ||
| max: this.maxResults, | ||
| }); | ||
| $.export("$summary", `Listed ${response.length} agent${response.length === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return response; | ||
| } catch (e) { | ||
| if (e.status === 404) { | ||
| $.export("$summary", "No agents found"); | ||
| } else { | ||
| throw new ConfigurationError(e); | ||
| } | ||
| } | ||
| }, | ||
| }; |
41 changes: 41 additions & 0 deletions
41
components/freshchat/actions/list-channels/list-channels.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,41 @@ | ||
| import freshchat from "../../freshchat.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "freshchat-list-channels", | ||
| name: "List Channels", | ||
| description: "Lists all channels in Freshchat. [See the documentation](https://developers.freshchat.com/api/#channels-(topics))", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| freshchat, | ||
| locale: { | ||
| type: "string", | ||
| label: "Locale", | ||
| description: "Limits the response to topics whose locale value matches the parameter value. Must be specified in the ISO-639 format. E.g. `en`", | ||
| optional: true, | ||
| }, | ||
| maxResults: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "maxResults", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const channels = await this.freshchat.getPaginatedResults({ | ||
| fn: this.freshchat.listChannels, | ||
| resourceKey: "channels", | ||
| args: { | ||
| $, | ||
| params: { | ||
| locale: this.locale, | ||
| }, | ||
| }, | ||
| max: this.maxResults, | ||
| }); | ||
| $.export("$summary", `Listed ${channels.length} channel${channels.length === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return channels; | ||
| }, | ||
| }; |
64 changes: 64 additions & 0 deletions
64
components/freshchat/actions/send-message-in-chat/send-message-in-chat.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,64 @@ | ||
| import freshchat from "../../freshchat.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "freshchat-send-message-in-chat", | ||
| name: "Send Message in Chat", | ||
| description: "Sends a message in a specific conversation. [See the documentation](https://developers.freshchat.com/api/#send_message_to_conversation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| freshchat, | ||
| userId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "userId", | ||
| ], | ||
| }, | ||
| conversationId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "conversationId", | ||
| (c) => ({ | ||
| userId: c.userId, | ||
| }), | ||
| ], | ||
| }, | ||
| message: { | ||
| type: "string", | ||
| label: "Message", | ||
| description: "The content of themessage to send", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const data = { | ||
| message_parts: [ | ||
| { | ||
| text: { | ||
| content: this.message, | ||
| }, | ||
| }, | ||
| ], | ||
| actor_type: "user", | ||
| actor_id: this.userId, | ||
| user_id: this.userId, | ||
| }; | ||
| try { | ||
| await this.freshchat.sendMessageInChat({ | ||
| $, | ||
| conversationId: this.conversationId, | ||
| data, | ||
| }); | ||
| } catch { | ||
| // Sends message, but always returns the error | ||
| /* { | ||
| "code": 400, | ||
| "status": "INVALID_VALUE", | ||
| "message": "com.demach.konotor.model.fragment.TextFragment cannot be cast to | ||
| com.demach.konotor.model.fragment.EmailFragment" | ||
| } | ||
| */ | ||
| } | ||
| $.export("$summary", `Sent message in conversation ${this.conversationId}`); | ||
| return data; | ||
| }, | ||
| }; | ||
63 changes: 63 additions & 0 deletions
63
components/freshchat/actions/update-conversation-status/update-conversation-status.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,63 @@ | ||
| import freshchat from "../../freshchat.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| key: "freshchat-update-conversation-status", | ||
| name: "Update Conversation Status", | ||
| description: "Updates the status of a specific conversation. [See the documentation](https://developers.freshchat.com/api/#update_a_conversation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| freshchat, | ||
| userId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "userId", | ||
| ], | ||
| }, | ||
| conversationId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "conversationId", | ||
| (c) => ({ | ||
| userId: c.userId, | ||
| }), | ||
| ], | ||
| }, | ||
| status: { | ||
| type: "string", | ||
| label: "Status", | ||
| description: "Status of the conversation", | ||
| options: [ | ||
| "new", | ||
| "assigned", | ||
| "resolved", | ||
| "reopened", | ||
| ], | ||
| }, | ||
| agentId: { | ||
| propDefinition: [ | ||
| freshchat, | ||
| "agentId", | ||
| ], | ||
| description: "The ID of an agent to assign the conversation to. Required if status is `assigned`", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (this.status === "assigned" && !this.agentId) { | ||
| throw new ConfigurationError("Agent ID is required when status is `assigned`"); | ||
| } | ||
|
|
||
| const response = await this.freshchat.updateConversation({ | ||
| $, | ||
| conversationId: this.conversationId, | ||
| data: { | ||
| status: this.status, | ||
| assigned_agent_id: this.agentId, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Updated conversation status to ${this.status}`); | ||
| 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.