Skip to content
47 changes: 39 additions & 8 deletions components/zoho_desk/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Create Contact",
description: "Creates a contact in your help desk portal. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Contacts#Contacts_CreateContact)",
type: "action",
version: "0.0.6",
version: "0.0.7",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -48,6 +48,27 @@ export default {
description: "Mobile number of the contact",
optional: true,
},
accountId: {
propDefinition: [
zohoDesk,
"accountId",
({ orgId }) => ({
orgId,
}),
],
},
title: {
type: "string",
label: "Title",
description: "Job title of the contact",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "Description about the contact",
optional: true,
},
},
async run({ $ }) {
const {
Expand All @@ -57,19 +78,29 @@ export default {
email,
phone,
mobile,
accountId,
title,
description,
} = this;

const data = {
lastName,
};

// Add optional fields
if (firstName) data.firstName = firstName;
if (email) data.email = email;
if (phone) data.phone = phone;
if (mobile) data.mobile = mobile;
if (accountId) data.accountId = accountId;
if (title) data.title = title;
if (description) data.description = description;

const response = await this.zohoDesk.createContact({
headers: {
orgId,
},
data: {
lastName,
firstName,
email,
phone,
mobile,
},
data,
});

$.export("$summary", `Successfully created a new contact with ID ${response.id}`);
Expand Down
109 changes: 102 additions & 7 deletions components/zoho_desk/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Create Ticket",
description: "Creates a ticket in your helpdesk. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Createaticket)",
type: "action",
version: "0.0.6",
version: "0.0.7",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -48,6 +48,75 @@ export default {
description: "Description in the ticket",
optional: true,
},
status: {
propDefinition: [
zohoDesk,
"ticketStatus",
],
},
priority: {
propDefinition: [
zohoDesk,
"ticketPriority",
],
},
assigneeId: {
propDefinition: [
zohoDesk,
"assigneeId",
({ orgId }) => ({
orgId,
}),
],
},
channel: {
propDefinition: [
zohoDesk,
"channel",
],
},
classification: {
propDefinition: [
zohoDesk,
"classification",
],
},
category: {
propDefinition: [
zohoDesk,
"category",
],
},
subCategory: {
propDefinition: [
zohoDesk,
"subCategory",
],
},
dueDate: {
propDefinition: [
zohoDesk,
"dueDate",
],
},
email: {
type: "string",
label: "Email",
description: "Email address for the ticket",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "Phone number for the ticket",
optional: true,
},
productId: {
propDefinition: [
zohoDesk,
"productId",
],
},
},
async run({ $ }) {
const {
Expand All @@ -56,18 +125,44 @@ export default {
contactId,
subject,
description,
status,
priority,
assigneeId,
channel,
classification,
category,
subCategory,
dueDate,
email,
phone,
productId,
} = this;

const data = {
departmentId,
contactId,
subject,
};

// Add optional fields
if (description) data.description = description;
if (status) data.status = status;
if (priority) data.priority = priority;
if (assigneeId) data.assigneeId = assigneeId;
if (channel) data.channel = channel;
if (classification) data.classification = classification;
if (category) data.category = category;
if (subCategory) data.subCategory = subCategory;
if (dueDate) data.dueDate = dueDate;
if (email) data.email = email;
if (phone) data.phone = phone;
if (productId) data.productId = productId;

const response = await this.zohoDesk.createTicket({
headers: {
orgId,
},
data: {
departmentId,
contactId,
subject,
description,
},
data,
});

$.export("$summary", `Successfully created a new ticket with ID ${response.id}`);
Expand Down
145 changes: 145 additions & 0 deletions components/zoho_desk/actions/list-tickets/list-tickets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import zohoDesk from "../../zoho_desk.app.mjs";

export default {
key: "zoho_desk-list-tickets",
name: "List Tickets",
description: "Lists all tickets in your help desk with optional filtering. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Listalltickets)",
type: "action",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
zohoDesk,
orgId: {
propDefinition: [
zohoDesk,
"orgId",
],
},
departmentId: {
propDefinition: [
zohoDesk,
"departmentId",
({ orgId }) => ({
orgId,
}),
],
},
status: {
propDefinition: [
zohoDesk,
"ticketStatus",
],
},
priority: {
propDefinition: [
zohoDesk,
"ticketPriority",
],
},
assigneeId: {
propDefinition: [
zohoDesk,
"assigneeId",
({ orgId }) => ({
orgId,
}),
],
},
channel: {
propDefinition: [
zohoDesk,
"channel",
],
},
contactId: {
propDefinition: [
zohoDesk,
"contactId",
({ orgId }) => ({
orgId,
}),
],
},
sortBy: {
propDefinition: [
zohoDesk,
"ticketSortBy",
],
},
from: {
propDefinition: [
zohoDesk,
"from",
],
},
limit: {
propDefinition: [
zohoDesk,
"limit",
],
},
maxResults: {
propDefinition: [
zohoDesk,
"maxResults",
],
},
include: {
type: "string",
label: "Include",
description: "Additional resources to include in the response (comma-separated). For example: `contacts,products,assignee`",
optional: true,
},
},
async run({ $ }) {
const {
orgId,
departmentId,
status,
priority,
assigneeId,
channel,
contactId,
sortBy,
from,
limit,
maxResults,
include,
} = this;

const params = {};

// Add optional filter parameters
if (departmentId) params.departmentId = departmentId;
if (status) params.status = status;
if (priority) params.priority = priority;
if (assigneeId) params.assignee = assigneeId;
if (channel) params.channel = channel;
if (contactId) params.contactId = contactId;
if (sortBy) params.sortBy = sortBy;
if (from) params.from = from;
if (limit) params.limit = limit;
if (include) params.include = include;

const tickets = [];
const stream = this.zohoDesk.getTicketsStream({
headers: {
orgId,
},
params,
max: maxResults,
});

for await (const ticket of stream) {
tickets.push(ticket);
}

$.export("$summary", `Successfully retrieved ${tickets.length} ticket(s)`);

return tickets;
},
};
Loading
Loading