Skip to content

Conversation

@SokolovskyiK
Copy link
Contributor

@SokolovskyiK SokolovskyiK commented Apr 25, 2025

No description provided.

@vercel
Copy link

vercel bot commented Apr 25, 2025

@SokolovskyiK is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Apr 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 25, 2025 10:17am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

Walkthrough

This update introduces several new action modules and utility scripts for integrating with the Freshdesk API. The changes add actions to assign tickets to agents or groups, close tickets, set ticket priority or status, and update ticket attributes. Additionally, scripts are included for creating groups, creating tickets, and fetching group IDs from Freshdesk. Each action defines its own properties, leverages Freshdesk’s API endpoints, and returns a summary message along with the API response. The modules collectively enhance the ability to programmatically manage Freshdesk tickets and related entities.

Changes

File(s) Change Summary
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs New action: Assigns a Freshdesk ticket to a specific agent by updating the responder_id via API.
components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs New action: Assigns a Freshdesk ticket to a group by updating the group_id via API.
components/freshdesk/actions/close-ticket/close-ticket.mjs New action: Closes a Freshdesk ticket by setting its status to "Closed" via API.
components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs New script: Creates a group in Freshdesk using the API; includes authentication and error handling.
components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs New script: Creates a Freshdesk ticket with various fields using the API; includes authentication.
components/freshdesk/actions/freshdesk-update-ticket/freshdesk-update-ticket.mjs New action: Updates multiple fields of a Freshdesk ticket; validates input and calls the update API endpoint.
components/freshdesk/actions/freshdesk-update-ticket/get-group-id.mjs New script: Fetches and logs all group names and IDs from Freshdesk via API.
components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs New action: Updates the priority of a Freshdesk ticket via API.
components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs New action: Updates the status of a Freshdesk ticket via API.
components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs New action: Updates various attributes of a Freshdesk ticket; validates input and calls the update API endpoint.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActionModule
    participant FreshdeskAPI

    User->>ActionModule: Provide ticket and update details
    ActionModule->>FreshdeskAPI: Send PUT/POST request with update data
    FreshdeskAPI-->>ActionModule: Return API response
    ActionModule-->>User: Return summary and response
Loading

Suggested labels

User submitted

Suggested reviewers

  • luancazarine

Poem

In the warren of code, new actions appear,
Freshdesk tickets now managed with cheer!
Assign, update, close, or set—
Each script ensures your needs are met.
Groups and agents, priorities too,
The API’s magic, all thanks to you!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/freshdesk/actions/close-ticket/close-ticket.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 7 others
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@adolfo-pd adolfo-pd added the User submitted Submitted by a user label Apr 25, 2025
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 15

🧹 Nitpick comments (13)
components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs (2)

1-1: Update formatting for dynamic import

The dynamic import pattern has formatting issues that should be fixed to maintain consistent code style.

-const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
+const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 1-1:
Strings must use doublequote


[failure] 1-1:
A space is required after '{'


[failure] 1-1:
A space is required before '}'


27-27: Add newline at end of file

Add a newline at the end of the file to comply with common coding standards.

 createGroup();
+
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 27-27:
Newline required at end of file but not found

components/freshdesk/actions/freshdesk-update-ticket/get-group-id.mjs (2)

1-1: Update formatting for dynamic import

The dynamic import pattern has formatting issues that should be fixed to maintain consistent code style.

-const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
+const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));

28-28: Add newline at end of file

Add a newline at the end of the file to comply with common coding standards.

 getGroups();
+
components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs (1)

43-43: Add newline at end of file

Add a newline at the end of the file to comply with common coding standards.

 createTicket();
+
components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs (1)

35-35: Add newline at end of file

Add a newline at the end of the file to comply with common coding standards.

 };
+
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 35-35:
Newline required at end of file but not found

components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs (2)

6-7: Add documentation link for consistency

For consistency with other actions (like close-ticket), consider adding a link to the Freshdesk API documentation.

-  description: "Assign a Freshdesk ticket to a specific agent",
+  description: "Assign a Freshdesk ticket to a specific agent. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",

23-34: Consider adding error handling

The action doesn't include any explicit error handling. While errors might be handled by the _makeRequest helper, it would be good to add specific error handling for clarity.

Consider adding try/catch for better error handling:

  async run({ $ }) {
+   try {
      const response = await this.freshdesk._makeRequest({
        $,
        method: "PUT",
        url: `/tickets/${this.ticketId}`,
        data: {
          responder_id: this.responder_id,
        },
      });
      $.export("$summary", `Ticket ${this.ticketId} assigned to agent ${this.responder_id}`);
      return response;
+   } catch (error) {
+     $.export("$summary", `Failed to assign ticket ${this.ticketId} to agent ${this.responder_id}: ${error.message}`);
+     throw error;
+   }
  },
components/freshdesk/actions/close-ticket/close-ticket.mjs (1)

18-32: Consider adding error handling

The action doesn't include any explicit error handling. While errors might be handled by the _makeRequest helper, it would be good to add specific error handling for clarity.

Consider adding try/catch for better error handling:

  async run({ $ }) {
    const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed'

+   try {
      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;
+   } catch (error) {
+     $.export("$summary", `Failed to close ticket ${this.ticketId}: ${error.message}`);
+     throw error;
+   }
  },
components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (2)

6-7: Add documentation link for consistency

For consistency with the close-ticket action, consider adding a link to the Freshdesk API documentation.

-  description: "Update the priority of a ticket in Freshdesk",
+  description: "Update the priority of a ticket in Freshdesk. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",

24-35: Consider adding error handling

The action doesn't include any explicit error handling. While errors might be handled by the _makeRequest helper, it would be good to add specific error handling for clarity.

Consider adding try/catch for better error handling:

  async run({ $ }) {
+   try {
      const response = await this.freshdesk._makeRequest({
        $,
        method: "PUT",
        url: `/tickets/${this.ticketId}`,
        data: {
          priority: this.ticketPriority,
        },
      });
      $.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`);
      return response;
+   } catch (error) {
+     $.export("$summary", `Failed to update priority for ticket ${this.ticketId}: ${error.message}`);
+     throw error;
+   }
  },
components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs (2)

6-7: Add documentation link for consistency

For consistency with the close-ticket action, consider adding a link to the Freshdesk API documentation.

-  description: "Update the status of a ticket in Freshdesk",
+  description: "Update the status of a ticket in Freshdesk. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",

24-35: Consider adding error handling

The action doesn't include any explicit error handling. While errors might be handled by the _makeRequest helper, it would be good to add specific error handling for clarity.

Consider adding try/catch for better error handling:

  async run({ $ }) {
+   try {
      const response = await this.freshdesk._makeRequest({
        $,
        method: "PUT",
        url: `/tickets/${this.ticketId}`,
        data: {
          status: this.ticketStatus,
        },
      });
      $.export("$summary", `Ticket ${this.ticketId} status updated to ${this.ticketStatus}`);
      return response;
+   } catch (error) {
+     $.export("$summary", `Failed to update status for ticket ${this.ticketId}: ${error.message}`);
+     throw error;
+   }
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9aa6c79 and addf466.

📒 Files selected for processing (10)
  • components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs (1 hunks)
  • components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs (1 hunks)
  • components/freshdesk/actions/close-ticket/close-ticket.mjs (1 hunks)
  • components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs (1 hunks)
  • components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs (1 hunks)
  • components/freshdesk/actions/freshdesk-update-ticket/freshdesk-update-ticket.mjs (1 hunks)
  • components/freshdesk/actions/freshdesk-update-ticket/get-group-id.mjs (1 hunks)
  • components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (1 hunks)
  • components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs (1 hunks)
  • components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint Code Base
components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs

[failure] 1-1:
Strings must use doublequote


[failure] 1-1:
A space is required after '{'


[failure] 1-1:
A space is required before '}'


[failure] 27-27:
Newline required at end of file but not found

components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs

[failure] 14-14:
A linebreak is required after '['


[failure] 14-14:
There should be a linebreak after this element


[failure] 14-14:
There should be a linebreak after this element


[failure] 14-14:
A linebreak is required before ']'

components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs

[failure] 35-35:
Newline required at end of file but not found

components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs

[failure] 35-35:
Newline required at end of file but not found

🪛 GitHub Actions: Pull Request Checks
components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs

[error] 35-35: ESLint: Newline required at end of file but not found (eol-last)

🪛 Biome (1.9.4)
components/freshdesk/actions/freshdesk-update-ticket/freshdesk-update-ticket.mjs

[error] 44-49: This property value named type is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type

(lint/suspicious/noDuplicateObjectKeys)

components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs

[error] 44-49: This property value named type is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type

(lint/suspicious/noDuplicateObjectKeys)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (7)
components/freshdesk/actions/close-ticket/close-ticket.mjs (2)

6-7: Good documentation with API link

The description includes a link to the Freshdesk API documentation, which is great for users who need more information.


19-19: Good use of constant with explanatory comment

Using a named constant with a comment for the status code is a good practice that makes the code more maintainable and easier to understand.

components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs (1)

1-36: Overall implementation looks good

The implementation follows the same pattern as the other Freshdesk actions and correctly updates the ticket priority.

components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs (1)

1-36: Overall implementation looks good

The implementation follows the same pattern as the other Freshdesk actions and correctly updates the ticket status. This provides a more general version of the close-ticket action, allowing any status to be set.

components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs (3)

5-6: LGTM: Clear action name and key

The action key and name clearly communicate the purpose of this component, which is important for discoverability.


100-146: LGTM: Well-structured run method with proper validation

The run method efficiently extracts properties, removes null entries, validates input requirements, and handles the API request appropriately.


1-147:

✅ Verification successful

Consider consistent naming convention for property names

Some properties use camelCase (ticketStatus, ticketPriority), while others use snake_case (group_id, responder_id). Although this likely mirrors Freshdesk's API naming, it might be confusing for users.

Consider whether this mixed naming is aligned with how Freshdesk returns these properties in responses, and with other components in your codebase.


🏁 Script executed:

#!/bin/bash
# Check how other Freshdesk components handle property naming
fd -e mjs -e js --exec grep -l "group_id\|responder_id" {} \; --exec echo "File: {}" \; --exec grep -A 5 -B 5 "group_id\|responder_id" {} \; components/freshdesk/

Length of output: 561


🏁 Script executed:

#!/bin/bash
# Search for snake_case and camelCase prop names across Freshdesk components
echo "Searching for group_id and responder_id..."
rg -n -e "group_id" -e "responder_id" components/freshdesk

echo ""
echo "Searching for ticketStatus and ticketPriority..."
rg -n -e "ticketStatus" -e "ticketPriority" components/freshdesk

Length of output: 5411


Naming Convention Aligns with API and Is Consistently Applied

We intentionally use camelCase for local props (ticketStatus, ticketPriority) that map to the API’s generic status and priority fields, and snake_case for props that directly mirror Freshdesk’s snake_case API fields (group_id, responder_id, custom_fields). This pattern is already applied uniformly across all Freshdesk action components:

  • ticketStatus / ticketPriority defined in freshdesk.app.mjs and used in all actions, mapping to API’s status/priority.
  • group_id / responder_id used in update-ticket, assign-ticket-to-group, assign-ticket-to-agent, and create-ticket, matching the API’s field names.

No changes needed.

🧰 Tools
🪛 Biome (1.9.4)

[error] 44-49: This property value named type is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type

(lint/suspicious/noDuplicateObjectKeys)

Comment on lines +3 to +5
// 🔧 Replace these with your real values
const API_KEY = "YfaK2hd0KP3og3KbqV";
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove hardcoded API credentials

The script contains what appears to be a real API key and domain. Hardcoding credentials in source code is a security risk even in test scripts.

-// 🔧 Replace these with your real values
-const API_KEY = "YfaK2hd0KP3og3KbqV";
-const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
+// 🔧 Replace these with your real values
+const API_KEY = "your_api_key";
+const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 🔧 Replace these with your real values
const API_KEY = "YfaK2hd0KP3og3KbqV";
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
// 🔧 Replace these with your real values
const API_KEY = "your_api_key";
const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com

Comment on lines +7 to +25
const createGroup = async () => {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "My Team",
}),
});

const data = await res.json();
if (!res.ok) {
console.error("❌ Group create error:", data);
return;
}
console.log("✅ Group created:", data);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for network failures

The function handles API error responses but not network errors. Add try/catch to handle potential network failures.

 const createGroup = async () => {
+  try {
     const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
       method: "POST",
       headers: {
         "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
         "Content-Type": "application/json",
       },
       body: JSON.stringify({
         name: "My Team",
       }),
     });

     const data = await res.json();
     if (!res.ok) {
       console.error("❌ Group create error:", data);
       return;
     }
     console.log("✅ Group created:", data);
+  } catch (error) {
+    console.error("❌ Network error:", error.message);
+  }
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const createGroup = async () => {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "My Team",
}),
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Group create error:", data);
return;
}
console.log("✅ Group created:", data);
};
const createGroup = async () => {
try {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "My Team",
}),
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Group create error:", data);
return;
}
console.log("✅ Group created:", data);
} catch (error) {
console.error("❌ Network error:", error.message);
}
};

Comment on lines +7 to +26
const getGroups = async () => {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
});

const data = await res.json();

if (!res.ok) {
console.error("❌ Failed to fetch groups:", data);
return;
}

console.log("✅ Group List:");
data.forEach(group => {
console.log(`- ${group.name}: ${group.id}`);
});
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for network failures

The function handles API error responses but not network errors. Add try/catch to handle potential network failures.

 const getGroups = async () => {
+  try {
     const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
       headers: {
         "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
         "Content-Type": "application/json",
       },
     });

     const data = await res.json();

     if (!res.ok) {
       console.error("❌ Failed to fetch groups:", data);
       return;
     }

     console.log("✅ Group List:");
     data.forEach(group => {
       console.log(`- ${group.name}: ${group.id}`);
     });
+  } catch (error) {
+    console.error("❌ Network error:", error.message);
+  }
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const getGroups = async () => {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Failed to fetch groups:", data);
return;
}
console.log("✅ Group List:");
data.forEach(group => {
console.log(`- ${group.name}: ${group.id}`);
});
};
const getGroups = async () => {
try {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Failed to fetch groups:", data);
return;
}
console.log("✅ Group List:");
data.forEach(group => {
console.log(`- ${group.name}: ${group.id}`);
});
} catch (error) {
console.error("❌ Network error:", error.message);
}
};

Comment on lines +3 to +5
// 🔧 Replace these with your real values
const API_KEY = "YfaK2hd0KP3og3KbqV";
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove hardcoded API credentials

The script contains what appears to be a real API key and domain. Hardcoding credentials in source code is a security risk even in test scripts.

-// 🔧 Replace these with your real values
-const API_KEY = "YfaK2hd0KP3og3KbqV";
-const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
+// 🔧 Replace these with your real values
+const API_KEY = "your_api_key";
+const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 🔧 Replace these with your real values
const API_KEY = "YfaK2hd0KP3og3KbqV";
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
// 🔧 Replace these with your real values
const API_KEY = "your_api_key";
const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com

Comment on lines +8 to +22
const payload = {
subject: "Test ticket for full update suite",
description: "<strong>This is a test ticket</strong><br>With rich HTML content.",
type: "Question",
priority: 2, // Medium
status: 2, // Open
tags: ["api-test", "pipedream", "full-update"],
email: "[email protected]", //
// Uncomment and customize if you have these
group_id: 157001089898,
responder_id: 157005992678, //Agent ID
custom_fields: {
// Example: "cf_customer_type": "premium"
},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove potentially sensitive information from payload

The ticket payload contains what appears to be real IDs, emails, and specific values. These should be replaced with placeholders in test scripts.

 // 🎟️ Ticket payload
 const payload = {
   subject: "Test ticket for full update suite",
   description: "<strong>This is a test ticket</strong><br>With rich HTML content.",
   type: "Question",
   priority: 2,  // Medium
   status: 2,    // Open
-  tags: ["api-test", "pipedream", "full-update"],
-  email: "[email protected]", // 
+  tags: [
+    "api-test",
+    "pipedream",
+    "full-update"
+  ],
+  email: "[email protected]", // 
   // Uncomment and customize if you have these
-  group_id: 157001089898,
-  responder_id: 157005992678, //Agent ID
+  group_id: 123456,
+  responder_id: 123456, //Agent ID
   custom_fields: {
     // Example: "cf_customer_type": "premium"
   },
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const payload = {
subject: "Test ticket for full update suite",
description: "<strong>This is a test ticket</strong><br>With rich HTML content.",
type: "Question",
priority: 2, // Medium
status: 2, // Open
tags: ["api-test", "pipedream", "full-update"],
email: "[email protected]", //
// Uncomment and customize if you have these
group_id: 157001089898,
responder_id: 157005992678, //Agent ID
custom_fields: {
// Example: "cf_customer_type": "premium"
},
};
const payload = {
subject: "Test ticket for full update suite",
description: "<strong>This is a test ticket</strong><br>With rich HTML content.",
type: "Question",
priority: 2, // Medium
status: 2, // Open
tags: [
"api-test",
"pipedream",
"full-update"
],
email: "[email protected]", //
// Uncomment and customize if you have these
group_id: 123456,
responder_id: 123456, //Agent ID
custom_fields: {
// Example: "cf_customer_type": "premium"
},
};
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 14-14:
A linebreak is required after '['


[failure] 14-14:
There should be a linebreak after this element


[failure] 14-14:
There should be a linebreak after this element


[failure] 14-14:
A linebreak is required before ']'

Comment on lines +44 to +49
type: {
type: "string",
label: "Type",
description: "Type of ticket (e.g. Question, Incident, etc.)",
optional: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix duplicate 'type' property definition

There's a duplicate property definition for 'type' in the props object. The first definition (lines 44-49) is being overwritten by the second definition (lines 80-92) with predefined options.

Delete the first 'type' property definition:

-    type: {
-      type: "string",
-      label: "Type",
-      description: "Type of ticket (e.g. Question, Incident, etc.)",
-      optional: true,
-    },

Also applies to: 80-92

🧰 Tools
🪛 Biome (1.9.4)

[error] 44-49: This property value named type is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type

(lint/suspicious/noDuplicateObjectKeys)

Comment on lines +114 to +115
tags,
custom_fields,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add missing 'tags' property definition

The 'tags' property is used in the run method and included in the data object, but it's not defined in the props object.

Add the tags property definition:

    custom_fields: {
      type: "object",
      label: "Custom Fields",
      description: "Custom fields as key-value pairs (make sure types match your config)",
      optional: true,
    },
+    tags: {
+      type: "string[]",
+      label: "Tags",
+      description: "Tags to be associated with the ticket",
+      optional: true,
+    },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tags,
custom_fields,
export default {
// …
props: {
// … other props …
custom_fields: {
type: "object",
label: "Custom Fields",
description: "Custom fields as key-value pairs (make sure types match your config)",
optional: true,
},
+ tags: {
+ type: "string[]",
+ label: "Tags",
+ description: "Tags to be associated with the ticket",
+ optional: true,
+ },
// … any remaining props …
},
async run({ axios, $ }) {
// …
const data = {
subject,
description,
status,
- tags,
- custom_fields,
+ tags,
+ custom_fields,
// … other fields …
};
// …
},
};

Comment on lines +1 to +147
import freshdesk from "../../freshdesk.app.mjs";
import { removeNullEntries } from "../../common/utils.mjs";

export default {
key: "freshdesk-update-ticket-testpd",
name: "Update a Ticket",
description: "Update status, priority, subject, description, agent, group, tags, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
version: "0.0.5",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
ticketStatus: {
propDefinition: [
freshdesk,
"ticketStatus",
],
optional: true,
},
ticketPriority: {
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,
},
type: {
type: "string",
label: "Type",
description: "Type of ticket (e.g. Question, Incident, etc.)",
optional: true,
},
group_id: {
type: "integer",
label: "Group ID",
description: "ID of the group to assign this ticket to",
optional: true,
},
responder_id: {
type: "integer",
label: "Agent ID",
description: "ID of the agent to assign this ticket to",
optional: true,
},
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,
ticketStatus,
ticketPriority,
subject,
description,
type,
group_id,
responder_id,
email,
phone,
name,
tags,
custom_fields,
} = this;

const data = removeNullEntries({
status: ticketStatus,
priority: ticketPriority,
subject,
description,
type,
group_id,
responder_id,
email,
phone,
name,
tags,
custom_fields,
});

if (!Object.keys(data).length) {
throw new Error("Please provide at least one field to update.");
}

const response = await freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${ticketId}`,
data,
});

$.export("$summary", `Ticket ${ticketId} updated successfully`);
return response;
},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Duplicate component with testing suffix

This component appears to be a duplicate of components/freshdesk/actions/update-ticket/freshdesk-update-ticket.mjs with a test suffix in the key and a lower version number. Having two nearly identical components in different paths will lead to maintenance issues.

Choose one location for this component and remove the duplicate. Based on the version numbers, the other file (0.0.6) seems to be the production version, suggesting this one (-testpd, 0.0.5) should be removed.

🧰 Tools
🪛 Biome (1.9.4)

[error] 44-49: This property value named type is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type

(lint/suspicious/noDuplicateObjectKeys)

Comment on lines +44 to +49
type: {
type: "string",
label: "Type",
description: "Type of ticket (e.g. Question, Incident, etc.)",
optional: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix duplicate 'type' property definition

There's a duplicate property definition for 'type' in the props object. The first definition (lines 44-49) is being overwritten by the second definition (lines 80-92) with predefined options.

Delete the first 'type' property definition:

-    type: {
-      type: "string",
-      label: "Type",
-      description: "Type of ticket (e.g. Question, Incident, etc.)",
-      optional: true,
-    },

Also applies to: 80-92

🧰 Tools
🪛 Biome (1.9.4)

[error] 44-49: This property value named type is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named type

(lint/suspicious/noDuplicateObjectKeys)

Comment on lines +114 to +115
tags,
custom_fields,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add missing 'tags' property definition

The 'tags' property is used in the run method and included in the data object, but it's not defined in the props object.

Add the tags property definition:

    custom_fields: {
      type: "object",
      label: "Custom Fields",
      description: "Custom fields as key-value pairs (make sure types match your config)",
      optional: true,
    },
+    tags: {
+      type: "string[]",
+      label: "Tags",
+      description: "Tags to be associated with the ticket",
+      optional: true,
+    },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tags,
custom_fields,
custom_fields: {
type: "object",
label: "Custom Fields",
description: "Custom fields as key-value pairs (make sure types match your config)",
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "Tags to be associated with the ticket",
optional: true,
},

@SokolovskyiK SokolovskyiK changed the title Freshdesk actions .. Apr 25, 2025
@SokolovskyiK SokolovskyiK changed the title .. accident Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

User submitted Submitted by a user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants