Node.js external libraries are not working in a custom Freshdesk application

I am making a custom application on Freshdesk Platform, for which I will be requiring the need of npm_packages like “bcrypt” and “axios”.
I have installed these libraries in the application and kept all its working code in server.js file according to the documentation : External Libraries

But I still find that my code is not working as I have followed all the steps as given in the Developer Documentation.
It would be very helpful if you could give guidance or provide the exact working and implementation of node.js external libraries in the Freshdesk application.

Hi and welcome mrinal,

What error are you encountering? I tried to replicate it, but the code seems to run fine.

Please note that external libraries can only be executed in the server.js file.

manifest.json:

{
  "platform-version": "2.3",
  "product": {
    "freshdesk": {
      "events": {
        "onTicketCreate": {
          "handler": "onTicketCreateHandler"
        }
      }
    }
  },
  "dependencies": {
    "bcryptjs": "^2.4.3"
  },
  "engines": {
    "node": "18.16.0",
    "fdk": "9.0.4"
  }
}

server.js:

var bcrypt = require('bcryptjs');
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync("B4c0/\/", salt);


exports = {

  onTicketCreateHandler: async function () {
    bcrypt.compareSync("B4c0/\/", hash); // true
    console.log(bcrypt.compareSync("B4c0/\/", hash)); // true
    console.log(bcrypt.compareSync("B4c1/\/", hash)); // false
  },
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.