-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3162811
Add update ticket action and set actions
SokolovskyiK 57d8eb5
Ammend
SokolovskyiK 8022b19
Ammend
SokolovskyiK 12a994c
Merge branch 'freshdesk' of https://github.com/SokolovskyiK/pipedream…
SokolovskyiK 45ee9b1
Fix after QA
SokolovskyiK 2ca978d
versions
michelle0927 29ec067
pnpm-lock.yaml
michelle0927 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
41 changes: 41 additions & 0 deletions
41
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.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,41 @@ | ||
import freshdesk from "../../freshdesk.app.mjs"; | ||
|
||
export default { | ||
key: "freshdesk-assign-ticket-to-agent", | ||
name: "Assign Ticket to Agent", | ||
description: "Assign a Freshdesk ticket to a specific agent. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshdesk, | ||
ticketId: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketId", | ||
], | ||
}, | ||
responder_id: { | ||
propDefinition: [ | ||
freshdesk, | ||
"agentId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
|
||
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; | ||
}, | ||
}; |
42 changes: 42 additions & 0 deletions
42
components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.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,42 @@ | ||
import freshdesk from "../../freshdesk.app.mjs"; | ||
|
||
export default { | ||
key: "freshdesk-assign-ticket-to-group", | ||
name: "Assign Ticket to Group", | ||
description: "Assign a Freshdesk ticket to a specific group [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshdesk, | ||
ticketId: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketId", | ||
], | ||
}, | ||
group_id: { | ||
propDefinition: [ | ||
freshdesk, | ||
"groupId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
|
||
const ticketName = await this.freshdesk.getTicketName(this.ticketId); | ||
|
||
const response = await this.freshdesk._makeRequest({ | ||
$, | ||
method: "PUT", | ||
url: `/tickets/${this.ticketId}`, | ||
data: { | ||
group_id: this.group_id, | ||
}, | ||
}); | ||
|
||
$.export("$summary", | ||
`Ticket "${ticketName}" (ID: ${this.ticketId}) assigned to group ${this.group_id}`); | ||
|
||
return response; | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
components/freshdesk/actions/close-ticket/close-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,33 @@ | ||
import freshdesk from "../../freshdesk.app.mjs"; | ||
|
||
export default { | ||
key: "freshdesk-close-ticket", | ||
name: "Close Ticket", | ||
description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshdesk, | ||
ticketId: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketId", | ||
], | ||
}, | ||
}, | ||
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; | ||
}, | ||
}; |
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
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
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
51 changes: 51 additions & 0 deletions
51
components/freshdesk/actions/set-ticket-priority/set-ticket-priority.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,51 @@ | ||
import freshdesk from "../../freshdesk.app.mjs"; | ||
|
||
export default { | ||
key: "freshdesk-set-ticket-priority", | ||
name: "Set Ticket Priority", | ||
description: "Update the priority of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshdesk, | ||
ticketId: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketId", | ||
], | ||
}, | ||
ticketPriority: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketPriority", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
|
||
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 = { | ||
1: "Low", | ||
2: "Medium", | ||
3: "High", | ||
4: "Urgent", | ||
}; | ||
|
||
const priorityLabel = priorityLabels[this.ticketPriority] || this.ticketPriority; | ||
|
||
$.export("$summary", | ||
`Ticket ${ticketName} (ID: ${this.ticketId}) priority updated to "${priorityLabel}".`); | ||
|
||
return response; | ||
}, | ||
}; |
53 changes: 53 additions & 0 deletions
53
components/freshdesk/actions/set-ticket-status/set-ticket-status.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,53 @@ | ||
import freshdesk from "../../freshdesk.app.mjs"; | ||
|
||
export default { | ||
key: "freshdesk-set-ticket-status", | ||
name: "Set Ticket Status", | ||
description: "Update the status of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshdesk, | ||
ticketId: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketId", | ||
], | ||
}, | ||
ticketStatus: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketStatus", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
|
||
const ticketName = await this.freshdesk.getTicketName(this.ticketId); | ||
|
||
const response = await this.freshdesk._makeRequest({ | ||
$, | ||
method: "PUT", | ||
url: `/tickets/${this.ticketId}`, | ||
data: { | ||
status: this.ticketStatus, | ||
}, | ||
}); | ||
|
||
const statusLabels = { | ||
2: "Open", | ||
3: "Pending", | ||
4: "Resolved", | ||
5: "Closed", | ||
}; | ||
|
||
const statusLabel = statusLabels[this.ticketStatus] || this.ticketStatus; | ||
|
||
$.export( | ||
"$summary", | ||
`Ticket "${ticketName}" (ID: ${this.ticketId}) status updated to "${statusLabel}".`, | ||
); | ||
|
||
return response; | ||
}, | ||
}; |
122 changes: 122 additions & 0 deletions
122
components/freshdesk/actions/update-ticket/update-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,122 @@ | ||
import freshdesk from "../../freshdesk.app.mjs"; | ||
import { removeNullEntries } from "../../common/utils.mjs"; | ||
|
||
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", | ||
type: "action", | ||
props: { | ||
freshdesk, | ||
ticketId: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketId", | ||
], | ||
}, | ||
status: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketStatus", | ||
], | ||
optional: true, | ||
}, | ||
priority: { | ||
propDefinition: [ | ||
freshdesk, | ||
"ticketPriority", | ||
], | ||
optional: true, | ||
}, | ||
subject: { | ||
type: "string", | ||
label: "Subject", | ||
description: "Ticket subject", | ||
optional: true, | ||
}, | ||
description: { | ||
type: "string", | ||
label: "Description", | ||
description: "Detailed ticket description (HTML allowed)", | ||
optional: true, | ||
}, | ||
group_id: { | ||
propDefinition: [ | ||
freshdesk, | ||
"groupId", | ||
], | ||
}, | ||
responder_id: { | ||
propDefinition: [ | ||
freshdesk, | ||
"agentId", | ||
], | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
email: { | ||
type: "string", | ||
label: "Requester Email (replaces requester)", | ||
description: "Updates the requester. If no contact with this email exists, a new one will be created and assigned to the ticket.", | ||
optional: true, | ||
}, | ||
phone: { | ||
type: "string", | ||
label: "Requester Phone (replaces requester)", | ||
description: "If no contact with this phone number exists, a new one will be created. If used without email, 'name' is required.", | ||
optional: true, | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Requester Name (required with phone if no email)", | ||
description: "Used when creating a contact with phone but no email.", | ||
optional: true, | ||
}, | ||
type: { | ||
type: "string", | ||
label: "Type", | ||
description: "Type of ticket (must match one of the allowed values)", | ||
optional: true, | ||
options: [ | ||
"Question", | ||
"Incident", | ||
"Problem", | ||
"Feature Request", | ||
"Refund", | ||
], | ||
}, | ||
custom_fields: { | ||
type: "object", | ||
label: "Custom Fields", | ||
description: "Custom fields as key-value pairs (make sure types match your config)", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
freshdesk, | ||
ticketId, | ||
...fields | ||
} = this; | ||
|
||
const data = removeNullEntries(fields); | ||
|
||
const ticketName = await freshdesk.getTicketName(ticketId); | ||
|
||
if (!Object.keys(data).length) { | ||
throw new Error("Please provide at least one field to update."); | ||
} | ||
|
||
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; | ||
}, | ||
}; | ||
|
Oops, something went wrong.
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.