-
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 6 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
104 changes: 104 additions & 0 deletions
104
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,104 @@ | ||
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) || "Unknown Ticket"; | ||
|
||
const data = { | ||
body, | ||
private: isPrivate, | ||
}; | ||
|
||
if (incoming !== undefined) { | ||
data.incoming = incoming; | ||
} | ||
|
||
if (user_id) { | ||
const userId = Number(user_id); | ||
if (isNaN(userId)) { | ||
throw new ConfigurationError("User ID must be a valid number"); | ||
} | ||
data.user_id = userId; | ||
} | ||
|
||
if (notify_emails && notify_emails.length > 0) { | ||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | ||
const invalidEmails = notify_emails.filter((email) => !emailRegex.test(email)); | ||
if (invalidEmails.length > 0) { | ||
throw new ConfigurationError(`Invalid email addresses: ${invalidEmails.join(", ")}`); | ||
} | ||
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.
Uh oh!
There was an error while loading. Please reload this page.