-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[ACTIONS] Freshdesk. Add update-ticket and SET actions #16450
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
@SokolovskyiK is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
""" WalkthroughThis update introduces several new action modules for the Freshdesk integration. These modules provide functionality to assign tickets to agents or groups, close tickets, set ticket priority, set ticket status, and update various ticket attributes. Each action is implemented as a separate module, exporting an object with the necessary properties and an asynchronous method that interacts with the Freshdesk API via PUT requests to update ticket data accordingly. The actions utilize property definitions from the Freshdesk app integration and return summaries with the results of each operation. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ActionModule
participant FreshdeskAPI
User->>ActionModule: Provide ticketId and update parameters
ActionModule->>FreshdeskAPI: PUT /tickets/{ticketId} with update data
FreshdeskAPI-->>ActionModule: API response
ActionModule-->>User: Return summary and response
Assessment against linked issues
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/freshdesk/actions/close-ticket/close-ticket.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (2)
1-36
: Well-structured implementation of the set-ticket-priority actionThe implementation follows the Pipedream action pattern correctly, properly importing the Freshdesk app and defining the necessary properties. The action makes appropriate use of propDefinitions from the Freshdesk app for consistency.
A minor improvement suggestion would be to add an API documentation link in the description, similar to what's in the close-ticket action.
- description: "Update the priority of a ticket in Freshdesk", + description: "Update the priority of a ticket in Freshdesk. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
24-32
: Consider adding basic error handlingWhile the _makeRequest method likely handles API errors internally, it would be beneficial to add some basic error handling specifically for this action to provide more context when failures occur.
async run({ $ }) { - const response = await this.freshdesk._makeRequest({ - $, - method: "PUT", - url: `/tickets/${this.ticketId}`, - data: { - priority: this.ticketPriority, - }, - }); + try { + const response = await this.freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${this.ticketId}`, + data: { + priority: this.ticketPriority, + }, + }); + $.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`); + return response; + } catch (error) { + $.export("$summary", `Failed to update ticket priority: ${error.message}`); + throw error; + }components/freshdesk/actions/close-ticket/close-ticket.mjs (1)
18-32
: Consider adding error handling for better user feedbackSimilar to the suggestion for the set-ticket-priority action, adding try/catch error handling would improve the user experience when something goes wrong.
async run({ $ }) { const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed' - const response = await this.freshdesk._makeRequest({ - $, - method: "PUT", - url: `/tickets/${this.ticketId}`, - data: { - status: CLOSED_STATUS, - }, - }); - - $.export("$summary", `Ticket ${this.ticketId} closed successfully`); - return response; + try { + const response = await this.freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${this.ticketId}`, + data: { + status: CLOSED_STATUS, + }, + }); + + $.export("$summary", `Ticket ${this.ticketId} closed successfully`); + return response; + } catch (error) { + $.export("$summary", `Failed to close ticket: ${error.message}`); + throw error; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs
(1 hunks)components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs
(1 hunks)components/freshdesk/actions/close-ticket/close-ticket.mjs
(1 hunks)components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs
(1 hunks)components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs
(1 hunks)components/freshdesk/actions/update-ticket/update-ticket.mjs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Publish TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (6)
components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs (1)
1-36
: Looks good! A clear and focused implementation of ticket status updates.This action module is well-structured and properly implements the necessary functionality for updating a ticket's status. The code follows a clean pattern with appropriate imports, property definitions, and API request handling.
components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs (1)
1-35
: Solid implementation of ticket group assignment functionality.The action is well-structured with clear property definitions and appropriate API request implementation. It follows the same consistent pattern as the other ticket management actions.
components/freshdesk/actions/update-ticket/update-ticket.mjs (2)
127-129
: Good validation to ensure at least one field is provided.This validation ensures that users don't make empty update requests, improving the user experience.
4-141
: Comprehensive ticket update implementation with flexibility.The action provides a wide range of options for updating ticket properties in a single API call, which is excellent for complex ticket updates. The code handles null entries appropriately and includes good documentation links.
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs (1)
1-35
: Well-implemented ticket agent assignment action.The implementation is clean, focused on a single responsibility, and follows the established pattern for Freshdesk ticket actions.
components/freshdesk/actions/close-ticket/close-ticket.mjs (1)
1-33
: Well-implemented close-ticket action with proper documentationThe implementation is clean and follows the Pipedream action pattern. Good job on defining the CLOSED_STATUS constant with a helpful comment explaining its purpose, and including the API documentation link in the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs (1)
24-40
: Consider adding error handling for ticket or agent assignment failuresThe implementation correctly retrieves the ticket name and makes the appropriate API call to update the ticket's responder. The summary message is informative and includes all relevant details.
Consider adding error handling to provide more specific feedback when a ticket doesn't exist or the agent assignment fails:
async run({ $ }) { + try { const ticketName = await this.freshdesk.getTicketName(this.ticketId); const response = await this.freshdesk._makeRequest({ $, method: "PUT", url: `/tickets/${this.ticketId}`, data: { responder_id: this.responder_id, }, }); $.export("$summary", `Ticket "${ticketName}" (ID: ${this.ticketId}) assigned to agent ${this.responder_id}`); return response; + } catch (error) { + if (error.response) { + const { status, data } = error.response; + if (status === 404) { + throw new Error(`Ticket with ID ${this.ticketId} not found.`); + } + throw new Error(`Failed to assign ticket: ${data?.description || error.message}`); + } + throw error; + } },components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (1)
24-50
: Consider adding error handling for failed API requestsThe main run method correctly retrieves the ticket name, makes the appropriate API call, and generates an informative summary. Similar to the assign-ticket-to-agent action, adding error handling would improve the robustness of this action.
Consider implementing error handling similar to the one suggested for the assign-ticket-to-agent action:
async run({ $ }) { + try { const ticketName = await this.freshdesk.getTicketName(this.ticketId); const response = await this.freshdesk._makeRequest({ $, method: "PUT", url: `/tickets/${this.ticketId}`, data: { priority: this.ticketPriority, }, }); const priorityLabels = { }; const priorityLabel = priorityLabels[this.ticketPriority] || this.ticketPriority; $.export("$summary", `Ticket ${ticketName} (ID: ${this.ticketId}) priority updated to "${priorityLabel}".`); return response; + } catch (error) { + if (error.response) { + const { status, data } = error.response; + if (status === 404) { + throw new Error(`Ticket with ID ${this.ticketId} not found.`); + } + throw new Error(`Failed to update ticket priority: ${data?.description || error.message}`); + } + throw error; + } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs
(1 hunks)components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs
(1 hunks)components/freshdesk/actions/close-ticket/close-ticket.mjs
(1 hunks)components/freshdesk/actions/create-company/create-company.mjs
(1 hunks)components/freshdesk/actions/create-contact/create-contact.mjs
(1 hunks)components/freshdesk/actions/create-ticket/create-ticket.mjs
(1 hunks)components/freshdesk/actions/get-ticket/get-ticket.mjs
(1 hunks)components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs
(1 hunks)components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs
(1 hunks)components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs
(1 hunks)components/freshdesk/actions/update-ticket/update-ticket.mjs
(1 hunks)components/freshdesk/freshdesk.app.mjs
(3 hunks)components/freshdesk/package.json
(1 hunks)components/freshdesk/sources/new-contact/new-contact.mjs
(1 hunks)components/freshdesk/sources/new-ticket/new-ticket.mjs
(1 hunks)
✅ Files skipped from review due to trivial changes (7)
- components/freshdesk/actions/create-contact/create-contact.mjs
- components/freshdesk/actions/create-ticket/create-ticket.mjs
- components/freshdesk/actions/create-company/create-company.mjs
- components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs
- components/freshdesk/sources/new-contact/new-contact.mjs
- components/freshdesk/actions/get-ticket/get-ticket.mjs
- components/freshdesk/sources/new-ticket/new-ticket.mjs
🚧 Files skipped from review as they are similar to previous changes (5)
- components/freshdesk/package.json
- components/freshdesk/actions/update-ticket/update-ticket.mjs
- components/freshdesk/actions/close-ticket/close-ticket.mjs
- components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs
- components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (7)
components/freshdesk/freshdesk.app.mjs (4)
41-61
: Well-structured Agent prop definition with good UI formattingThe
agentId
prop definition is well-implemented with appropriate type, label, and description. Your approach to formatting the agent label with name and email creates a user-friendly selection experience. The pagination implementation is also properly handled.
62-81
: Good implementation of Group selection with proper paginationThe
groupId
prop definition follows best practices with clear labeling and description. The fallback toGroup ${group.id}
when name isn't available is a nice touch for ensuring all options have meaningful labels. The pagination parameters (page and per_page) are correctly implemented.
253-258
: Helpful utility for retrieving ticket subjectsThis helper method effectively reuses the existing
getTicket
method and extracts just the subject, which will be useful for creating meaningful summary messages in the various ticket actions.
259-268
: Well-implemented JSON parsing utility with proper error handlingThe
parseIfJSONString
method is robustly implemented with:
- Type checking before attempting to parse
- Proper try/catch error handling
- Appropriate fallback to original input on parsing failure
- Support for non-string inputs
This will be particularly useful for handling custom fields that might be provided as JSON strings in the update-ticket action.
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs (1)
3-23
: Well-structured component definition following naming conventionsThe component is properly defined with:
- Key following the
app_name_slug-slugified-component-name
convention- Clear name and description with API documentation link
- Appropriate version number
- Well-defined props utilizing the app's propDefinitions
components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (2)
3-23
: Good component structure with appropriate API documentationThe component definition follows best practices with:
- Properly formatted key
- Clear name and description
- Link to relevant API documentation
- Appropriate version number
- Well-defined props using the app's propDefinitions
37-45
: Nice UX touch with priority label mappingThe implementation of a mapping between numeric priority values and human-readable labels improves the user experience by displaying meaningful priority names in the summary message. The fallback to using the raw value if not found in the mapping is a good defensive programming practice.
Fixes #16419
What's Included
• Full Update Action "update-ticket"
Allows setting status, priority, subject, description, responder ID, group ID, tags, and more.
Designed for flexibility and full control over ticket properties.
Tested with multiple field combinations.
• Small Modular "Set" Actions
Added targeted actions for common one-field updates:
"set-ticket-status", "set-ticket-priority", "assign-ticket-to-agent"
"assign-ticket-to-group", "close-ticket"
Each action accepts only the minimal required input (e.g. ticket ID + new value)
Useful for quick one-off updates
• Testing
All actions tested with real API responses.
Summary by CodeRabbit