-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Zendesk ticket tags #17603
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
Zendesk ticket tags #17603
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,7 +5,7 @@ export default { | |||||||||||||
key: "freshdesk-update-ticket", | ||||||||||||||
name: "Update a Ticket", | ||||||||||||||
description: "Update status, priority, subject, description, agent, group, etc. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", | ||||||||||||||
version: "0.0.1", | ||||||||||||||
version: "0.0.2", | ||||||||||||||
type: "action", | ||||||||||||||
props: { | ||||||||||||||
freshdesk, | ||||||||||||||
|
@@ -71,6 +71,19 @@ export default { | |||||||||||||
description: "Used when creating a contact with phone but no email.", | ||||||||||||||
optional: true, | ||||||||||||||
}, | ||||||||||||||
internalNote: { | ||||||||||||||
type: "boolean", | ||||||||||||||
label: "Internal note (private)", | ||||||||||||||
description: "If enabled, the comment will be added as an internal note (not visible to requester).", | ||||||||||||||
optional: true, | ||||||||||||||
default: false, | ||||||||||||||
}, | ||||||||||||||
noteBody: { | ||||||||||||||
type: "string", | ||||||||||||||
label: "Note Body", | ||||||||||||||
description: "The content of the internal note to add.", | ||||||||||||||
optional: true, | ||||||||||||||
}, | ||||||||||||||
type: { | ||||||||||||||
type: "string", | ||||||||||||||
label: "Type", | ||||||||||||||
|
@@ -95,28 +108,44 @@ export default { | |||||||||||||
const { | ||||||||||||||
freshdesk, | ||||||||||||||
ticketId, | ||||||||||||||
internalNote, | ||||||||||||||
noteBody, | ||||||||||||||
...fields | ||||||||||||||
} = this; | ||||||||||||||
|
||||||||||||||
const data = removeNullEntries(fields); | ||||||||||||||
|
||||||||||||||
const ticketName = await freshdesk.getTicketName(ticketId); | ||||||||||||||
|
||||||||||||||
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 (!Object.keys(data).length) { | ||||||||||||||
throw new Error("Please provide at least one field to update."); | ||||||||||||||
} | ||||||||||||||
Comment on lines
135
to
137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Adjust validation logic to handle internal note scenarios. The current validation will fail if a user only provides internal note fields since they're excluded from the -if (!Object.keys(data).length) {
+if (!Object.keys(data).length && !(internalNote && noteBody)) {
throw new Error("Please provide at least one field to update.");
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||
|
||||||||||||||
if (data.custom_fields) freshdesk.parseIfJSONString(data.custom_fields); | ||||||||||||||
|
||||||||||||||
const response = await freshdesk._makeRequest({ | ||||||||||||||
$, | ||||||||||||||
method: "PUT", | ||||||||||||||
url: `/tickets/${ticketId}`, | ||||||||||||||
data, | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
$.export("$summary", `Ticket "${ticketName}" (ID: ${this.ticketId}) updated successfully`); | ||||||||||||||
return response; | ||||||||||||||
}, | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import app from "../../zendesk.app.mjs"; | ||
|
||
export default { | ||
key: "zendesk-add-ticket-tags", | ||
name: "Add Ticket Tags", | ||
description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#add-tags).", | ||
type: "action", | ||
version: "0.0.1", | ||
props: { | ||
app, | ||
ticketId: { | ||
propDefinition: [ | ||
app, | ||
"ticketId", | ||
], | ||
}, | ||
ticketTags: { | ||
propDefinition: [ | ||
app, | ||
"ticketTags", | ||
], | ||
description: "Array of tags to add to the ticket. These will be appended to any existing tags.", | ||
}, | ||
customSubdomain: { | ||
propDefinition: [ | ||
app, | ||
"customSubdomain", | ||
], | ||
}, | ||
}, | ||
async run({ $: step }) { | ||
const { | ||
ticketId, | ||
ticketTags, | ||
customSubdomain, | ||
} = this; | ||
|
||
const response = await this.app.addTicketTags({ | ||
step, | ||
ticketId, | ||
tags: ticketTags, | ||
customSubdomain, | ||
}); | ||
|
||
step.export("$summary", `Successfully added ${ticketTags.length} tag(s) to ticket ${ticketId}`); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import app from "../../zendesk.app.mjs"; | ||
|
||
export default { | ||
key: "zendesk-remove-ticket-tags", | ||
name: "Remove Ticket Tags", | ||
description: "Remove specific tags from a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#remove-tags).", | ||
type: "action", | ||
version: "0.0.1", | ||
props: { | ||
app, | ||
ticketId: { | ||
propDefinition: [ | ||
app, | ||
"ticketId", | ||
], | ||
}, | ||
ticketTags: { | ||
propDefinition: [ | ||
app, | ||
"ticketTags", | ||
], | ||
description: "Array of tags to remove from the ticket.", | ||
}, | ||
customSubdomain: { | ||
propDefinition: [ | ||
app, | ||
"customSubdomain", | ||
], | ||
}, | ||
}, | ||
async run({ $: step }) { | ||
const { | ||
ticketId, | ||
ticketTags, | ||
customSubdomain, | ||
} = this; | ||
|
||
const response = await this.app.removeTicketTags({ | ||
step, | ||
ticketId, | ||
tags: ticketTags, | ||
customSubdomain, | ||
}); | ||
|
||
step.export("$summary", `Successfully removed ${ticketTags.length} tag(s) from ticket ${ticketId}`); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import app from "../../zendesk.app.mjs"; | ||
|
||
export default { | ||
key: "zendesk-set-ticket-tags", | ||
name: "Set Ticket Tags", | ||
description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#set-tags).", | ||
type: "action", | ||
version: "0.0.1", | ||
props: { | ||
app, | ||
ticketId: { | ||
propDefinition: [ | ||
app, | ||
"ticketId", | ||
], | ||
}, | ||
ticketTags: { | ||
propDefinition: [ | ||
app, | ||
"ticketTags", | ||
], | ||
}, | ||
customSubdomain: { | ||
propDefinition: [ | ||
app, | ||
"customSubdomain", | ||
], | ||
}, | ||
}, | ||
async run({ $: step }) { | ||
const { | ||
ticketId, | ||
ticketTags, | ||
customSubdomain, | ||
} = this; | ||
|
||
const response = await this.app.setTicketTags({ | ||
step, | ||
ticketId, | ||
tags: ticketTags, | ||
customSubdomain, | ||
}); | ||
|
||
step.export("$summary", `Successfully set ${ticketTags.length} tag(s) on ticket ${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
Consider supporting both internal note and ticket update in a single action call.
The current implementation creates an either/or scenario - users can either add an internal note OR update ticket fields, but not both. This limits the action's flexibility and may not align with user expectations.
Consider refactoring to support both operations:
Then update the summary logic to reflect both operations when performed.
📝 Committable suggestion
🤖 Prompt for AI Agents