-
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fc704c0
fix issues
seynadio 7f30447
Refactor Freshdesk: Create separate add-note-to-ticket action
Afstkla 00fe76b
Update pnpm-lock.yaml
Afstkla 7803162
Update update-ticket.mjs
Afstkla 8a0841e
whitespace
Afstkla 65ee116
fix: Address PR review comments
Afstkla ff8a114
Merge branch 'master' into freshdesk
andrewjschuang 9163b2e
pnpm
andrewjschuang b9d9d58
bump version
andrewjschuang f185f5e
bump version
andrewjschuang 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
95 changes: 95 additions & 0 deletions
95
components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.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,95 @@ | ||
import freshdesk from "../../freshdesk.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "freshdesk-add-note-to-ticket", | ||
name: "Add Note to Ticket", | ||
description: "Add a note or conversation to an existing ticket. [See the documentation](https://developers.freshdesk.com/api/#add_note_to_a_ticket).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshdesk, | ||
ticketId: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketId", | ||
], | ||
}, | ||
body: { | ||
type: "string", | ||
label: "Note Body", | ||
description: "Content of the note in HTML format", | ||
}, | ||
private: { | ||
type: "boolean", | ||
label: "Private Note", | ||
description: "Set to true if the note is private (internal)", | ||
default: false, | ||
}, | ||
incoming: { | ||
type: "boolean", | ||
label: "Incoming", | ||
description: "Set to true if the note should be marked as incoming (false for outgoing)", | ||
default: false, | ||
optional: true, | ||
}, | ||
user_id: { | ||
propDefinition: [ | ||
freshdesk, | ||
"agentId", | ||
], | ||
label: "User ID", | ||
description: "ID of the user creating the note (defaults to the API user)", | ||
optional: true, | ||
}, | ||
notify_emails: { | ||
type: "string[]", | ||
label: "Notify Emails", | ||
description: "Array of email addresses to notify about this note", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
freshdesk, | ||
ticketId, | ||
body, | ||
private: isPrivate, | ||
incoming, | ||
user_id, | ||
notify_emails, | ||
} = this; | ||
|
||
if (!body || !body.trim()) { | ||
throw new ConfigurationError("Note body cannot be empty"); | ||
} | ||
|
||
const ticketName = await freshdesk.getTicketName(ticketId); | ||
|
||
const data = { | ||
body, | ||
private: isPrivate, | ||
}; | ||
|
||
if (incoming !== undefined) { | ||
data.incoming = incoming; | ||
} | ||
|
||
if (user_id) { | ||
data.user_id = Number(user_id); | ||
} | ||
|
||
if (notify_emails && notify_emails.length > 0) { | ||
data.notify_emails = notify_emails; | ||
} | ||
|
||
const response = await freshdesk.addNoteToTicket({ | ||
$, | ||
ticketId: Number(ticketId), | ||
data, | ||
}); | ||
|
||
$.export("$summary", `Note added to ticket "${ticketName}" (ID: ${ticketId})`); | ||
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
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.
💡 Verification agent
🧩 Analysis chain
Verify error handling for getTicketName method.
Ensure that if the ticket doesn't exist, the error is handled gracefully.
Run the following script to check if getTicketName has proper error handling:
🏁 Script executed:
Length of output: 64
To locate the
getTicketName
implementation and inspect its error handling, let’s search for its definition across the codebase:🏁 Script executed:
Length of output: 989
Let’s inspect the implementation around line 253 to see how errors are handled:
🏁 Script executed:
Length of output: 612
To verify how missing tickets are handled, let’s inspect the
getTicket
implementation:🏁 Script executed:
Length of output: 1134
Let’s inspect the
_makeRequest
implementation to see how it handles HTTP errors (e.g., 404 for non-existent tickets):🏁 Script executed:
Length of output: 805
Add explicit error handling for missing tickets in
getTicketName
The
getTicketName
helper currently propagates any errors (including 404s) up to the caller. We need to catch “ticket not found” errors and handle them gracefully—either by returningnull
(or a default) or by surfacing a clear, user-friendly error.Affected locations:
getTicketName
(around line 253)Proposed changes:
getTicketName
implementation in a try/catch and handle HTTP 404:null
(or fallback) at the action layer so the flow doesn’t break unexpectedly:This ensures that 404s don’t crash your action and that any other errors bubble up clearly.
📝 Committable suggestion
🤖 Prompt for AI Agents