-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Freshdesk - add support for notes #17598
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
@seynadio is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe update introduces two new optional properties, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Action
participant FreshdeskAPI
User->>Action: Invoke update-ticket with props
alt Adding internal note
Action->>FreshdeskAPI: POST /tickets/{ticketId}/notes (private)
FreshdeskAPI-->>Action: Note creation response
Action-->>User: Return note creation summary
else Updating ticket fields
Action->>FreshdeskAPI: PUT /tickets/{ticketId}
FreshdeskAPI-->>Action: Ticket update response
Action-->>User: Return ticket update result
end
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/update-ticket/update-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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
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 (1)
components/freshdesk/actions/update-ticket/update-ticket.mjs (1)
74-86
: Properties look good but consider validation enhancement.The new properties are well-defined with clear descriptions and appropriate types.
Consider adding validation to ensure
noteBody
is provided wheninternalNote
is true:noteBody: { type: "string", label: "Note Body", description: "The content of the internal note to add.", optional: true, + reloadProps: true, },
Or add a conditional requirement in the property definition.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/freshdesk/actions/update-ticket/update-ticket.mjs
(3 hunks)
🔇 Additional comments (3)
components/freshdesk/actions/update-ticket/update-ticket.mjs (3)
8-8
: LGTM: Version increment is appropriate.The version bump from 0.0.1 to 0.0.2 correctly reflects the addition of new functionality.
111-112
: LGTM: Destructuring correctly extracts new properties.The destructuring properly extracts the new properties while maintaining the existing
...fields
pattern.
135-149
: LGTM: Existing logic preserved correctly.The existing ticket update logic remains intact and functions as expected when not adding internal notes.
if (internalNote && noteBody) { | ||
const response = await freshdesk._makeRequest({ | ||
$, | ||
method: "POST", | ||
url: `/tickets/${ticketId}/notes`, | ||
data: { | ||
body: noteBody, | ||
private: true, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`); | ||
return response; | ||
} |
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.
🛠️ Refactor suggestion
Address the either/or behavior limitation and validation gap.
The current implementation has two design issues:
-
Either/or limitation: Users can either add an internal note OR update ticket fields, but not both in the same action call. This may not meet user expectations.
-
Validation gap: If
internalNote
is true butnoteBody
is empty/falsy, the function proceeds to regular update logic, potentially throwing a confusing "Please provide at least one field to update" error.
Consider these improvements:
Option 1: Allow both operations in sequence
if (internalNote && noteBody) {
- const response = await freshdesk._makeRequest({
+ await freshdesk._makeRequest({
$,
method: "POST",
url: `/tickets/${ticketId}/notes`,
data: {
body: noteBody,
private: true,
},
});
-
- $.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`);
- return response;
+ }
+
+ if (internalNote && !noteBody) {
+ throw new Error("Note Body is required when Internal note is enabled.");
}
Option 2: Add validation for the either/or scenario
+ if (internalNote && !noteBody) {
+ throw new Error("Note Body is required when Internal note is enabled.");
+ }
+
if (internalNote && noteBody) {
// existing logic
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (internalNote && noteBody) { | |
const response = await freshdesk._makeRequest({ | |
$, | |
method: "POST", | |
url: `/tickets/${ticketId}/notes`, | |
data: { | |
body: noteBody, | |
private: true, | |
}, | |
}); | |
$.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`); | |
return response; | |
} | |
if (internalNote && noteBody) { | |
await freshdesk._makeRequest({ | |
$, | |
method: "POST", | |
url: `/tickets/${ticketId}/notes`, | |
data: { | |
body: noteBody, | |
private: true, | |
}, | |
}); | |
} | |
if (internalNote && !noteBody) { | |
throw new Error("Note Body is required when Internal note is enabled."); | |
} |
🤖 Prompt for AI Agents
In components/freshdesk/actions/update-ticket/update-ticket.mjs around lines 120
to 133, the code currently only allows adding an internal note or updating
ticket fields, not both, and lacks validation when internalNote is true but
noteBody is empty. To fix this, modify the logic to support performing both
actions sequentially if both internalNote and ticket updates are provided, or
alternatively, add validation to check if internalNote is true but noteBody is
missing and return a clear error before proceeding. This ensures users can
update tickets and add notes in one call or receive proper feedback if required
inputs are missing.
WHY
New Features
Chores
Summary by CodeRabbit