-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Complete Freshservice integration to match Freshdesk functionality #17608
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
Open
seynadio
wants to merge
1
commit into
PipedreamHQ:master
Choose a base branch
from
seynadio:freshservice-complete-implementation-clean
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions
37
components/freshservice/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,37 @@ | ||
import freshservice from "../../freshservice.app.mjs"; | ||
|
||
export default { | ||
key: "freshservice-assign-ticket-to-agent", | ||
name: "Assign Ticket to Agent", | ||
description: "Assign a ticket to an agent in Freshservice. [See the documentation](https://api.freshservice.com/v2/#update_ticket)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshservice, | ||
ticketId: { | ||
propDefinition: [ | ||
freshservice, | ||
"ticketId", | ||
], | ||
}, | ||
responder_id: { | ||
propDefinition: [ | ||
freshservice, | ||
"agentId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.freshservice.updateTicket({ | ||
ticketId: this.ticketId, | ||
data: { | ||
responder_id: this.responder_id, | ||
}, | ||
$, | ||
}); | ||
|
||
const ticketName = await this.freshservice.getTicketName(this.ticketId); | ||
$.export("$summary", `Successfully assigned ticket "${ticketName}" to agent`); | ||
return response; | ||
}, | ||
}; |
37 changes: 37 additions & 0 deletions
37
components/freshservice/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,37 @@ | ||
import freshservice from "../../freshservice.app.mjs"; | ||
|
||
export default { | ||
key: "freshservice-assign-ticket-to-group", | ||
name: "Assign Ticket to Group", | ||
description: "Assign a ticket to a group in Freshservice. [See the documentation](https://api.freshservice.com/v2/#update_ticket)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshservice, | ||
ticketId: { | ||
propDefinition: [ | ||
freshservice, | ||
"ticketId", | ||
], | ||
}, | ||
group_id: { | ||
propDefinition: [ | ||
freshservice, | ||
"groupId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.freshservice.updateTicket({ | ||
ticketId: this.ticketId, | ||
data: { | ||
group_id: this.group_id, | ||
}, | ||
$, | ||
}); | ||
|
||
const ticketName = await this.freshservice.getTicketName(this.ticketId); | ||
$.export("$summary", `Successfully assigned ticket "${ticketName}" to group`); | ||
return response; | ||
}, | ||
}; |
31 changes: 31 additions & 0 deletions
31
components/freshservice/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,31 @@ | ||
import freshservice from "../../freshservice.app.mjs"; | ||
|
||
export default { | ||
key: "freshservice-close-ticket", | ||
name: "Close Ticket", | ||
description: "Close a ticket in Freshservice. [See the documentation](https://api.freshservice.com/v2/#update_ticket)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshservice, | ||
ticketId: { | ||
propDefinition: [ | ||
freshservice, | ||
"ticketId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.freshservice.updateTicket({ | ||
ticketId: this.ticketId, | ||
data: { | ||
status: 5, // Closed | ||
}, | ||
$, | ||
}); | ||
|
||
const ticketName = await this.freshservice.getTicketName(this.ticketId); | ||
$.export("$summary", `Successfully closed ticket "${ticketName}"`); | ||
return response; | ||
}, | ||
}; |
109 changes: 109 additions & 0 deletions
109
components/freshservice/actions/create-company/create-company.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,109 @@ | ||
import freshservice from "../../freshservice.app.mjs"; | ||
import { removeNullEntries } from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "freshservice-create-company", | ||
name: "Create Company", | ||
description: "Create a new company in Freshservice. [See the documentation](https://api.freshservice.com/v2/#create_company)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshservice, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "Name of the company", | ||
}, | ||
description: { | ||
type: "string", | ||
label: "Description", | ||
description: "Description of the company", | ||
optional: true, | ||
}, | ||
note: { | ||
type: "string", | ||
label: "Note", | ||
description: "Note about the company", | ||
optional: true, | ||
}, | ||
domains: { | ||
type: "string[]", | ||
label: "Domains", | ||
description: "Domains associated with the company", | ||
optional: true, | ||
}, | ||
primary_email: { | ||
type: "string", | ||
label: "Primary Email", | ||
description: "Primary email of the company", | ||
optional: true, | ||
}, | ||
phone: { | ||
type: "string", | ||
label: "Phone", | ||
description: "Phone number of the company", | ||
optional: true, | ||
}, | ||
address: { | ||
type: "string", | ||
label: "Address", | ||
description: "Address of the company", | ||
optional: true, | ||
}, | ||
city: { | ||
type: "string", | ||
label: "City", | ||
description: "City of the company", | ||
optional: true, | ||
}, | ||
state: { | ||
type: "string", | ||
label: "State", | ||
description: "State of the company", | ||
optional: true, | ||
}, | ||
zip_code: { | ||
type: "string", | ||
label: "Zip Code", | ||
description: "Zip code of the company", | ||
optional: true, | ||
}, | ||
country: { | ||
type: "string", | ||
label: "Country", | ||
description: "Country of the company", | ||
optional: true, | ||
}, | ||
custom_fields: { | ||
type: "object", | ||
label: "Custom Fields", | ||
description: "Custom fields as a JSON object", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
custom_fields, | ||
domains, | ||
...otherProps | ||
} = this; | ||
|
||
const data = removeNullEntries(otherProps); | ||
|
||
if (custom_fields) { | ||
data.custom_fields = this.freshservice.parseIfJSONString(custom_fields); | ||
} | ||
|
||
if (domains && domains.length > 0) { | ||
data.domains = domains; | ||
} | ||
|
||
const response = await this.freshservice.createCompany({ | ||
data, | ||
$, | ||
}); | ||
|
||
$.export("$summary", `Successfully created company: ${response.company?.name}`); | ||
return response; | ||
}, | ||
}; |
110 changes: 110 additions & 0 deletions
110
components/freshservice/actions/create-contact/create-contact.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,110 @@ | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
import freshservice from "../../freshservice.app.mjs"; | ||
import { removeNullEntries } from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "freshservice-create-contact", | ||
name: "Create Contact", | ||
description: "Create a new contact in Freshservice. [See the documentation](https://api.freshservice.com/v2/#create_requester)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
freshservice, | ||
first_name: { | ||
type: "string", | ||
label: "First Name", | ||
description: "First name of the contact", | ||
}, | ||
last_name: { | ||
type: "string", | ||
label: "Last Name", | ||
description: "Last name of the contact", | ||
optional: true, | ||
}, | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "Primary email address of the contact", | ||
optional: true, | ||
}, | ||
secondary_emails: { | ||
type: "string[]", | ||
label: "Secondary Emails", | ||
description: "Additional email addresses of the contact", | ||
optional: true, | ||
}, | ||
phone: { | ||
type: "string", | ||
label: "Phone", | ||
description: "Phone number of the contact", | ||
optional: true, | ||
}, | ||
mobile: { | ||
type: "string", | ||
label: "Mobile", | ||
description: "Mobile number of the contact", | ||
optional: true, | ||
}, | ||
job_title: { | ||
type: "string", | ||
label: "Job Title", | ||
description: "Job title of the contact", | ||
optional: true, | ||
}, | ||
department_id: { | ||
type: "string", | ||
label: "Department ID", | ||
description: "Department ID of the contact", | ||
optional: true, | ||
}, | ||
company_id: { | ||
propDefinition: [ | ||
freshservice, | ||
"companyId", | ||
], | ||
optional: true, | ||
}, | ||
address: { | ||
type: "string", | ||
label: "Address", | ||
description: "Address of the contact", | ||
optional: true, | ||
}, | ||
time_zone: { | ||
type: "string", | ||
label: "Time Zone", | ||
description: "Time zone of the contact", | ||
optional: true, | ||
}, | ||
language: { | ||
type: "string", | ||
label: "Language", | ||
description: "Language of the contact", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
secondary_emails, | ||
...otherProps | ||
} = this; | ||
|
||
if (!this.email && !this.phone) { | ||
throw new ConfigurationError("Either email or phone must be provided"); | ||
} | ||
|
||
const data = removeNullEntries(otherProps); | ||
|
||
if (secondary_emails && secondary_emails.length > 0) { | ||
data.secondary_emails = secondary_emails; | ||
} | ||
|
||
const response = await this.freshservice.createContact({ | ||
data, | ||
$, | ||
}); | ||
|
||
$.export("$summary", `Successfully created contact: ${response.requester?.first_name} ${response.requester?.last_name || ""}`); | ||
return response; | ||
}, | ||
}; |
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.
🛠️ Refactor suggestion
Use constants instead of hardcoded status values.
The status value
5
for "Closed" is hardcoded. Consider importing and using theTICKET_STATUS
constants from the constants file for better maintainability.+import { TICKET_STATUS } from "../../common/constants.mjs";
Then update the status assignment:
Or if the constants file exports the actual status values:
🤖 Prompt for AI Agents