Hi! I am having a issue with serverless freshdesk app.
Im trying to call a function inside server.js, but im getting the following response:
Error while executing serverless function: {message: “Requested function ‘serverMethod’ not found or registered”, status: 404, errorSource: ‘APP’}’
Can anyone please tell me what i am doing wrong?
This is the configuration ive done:
App.js:
const payload = {
name: "John",
age: 30
};
client.request.invoke('serverMethod', payload).then(function(response) {
console.log("Serverless function executed successfully:", response);
}).catch(function(error) {
console.log("Error while executing serverless function:", error);
});
Server.js:
exports = {
serverMethod: async function (request) {
return new Promise((resolve, reject) => {
// Your serverless function code here
const data = request.data;
if (data.name && data.age) {
const response = `Hello ${data.name}, you are ${data.age} years old`;
resolve(response);
} else {
const error = 'Invalid data';
reject(error);
}
});
}
};
Manifest.json:
{
"platform-version": "2.2",
"product": {
"freshdesk": {
"serverless": {
"functions": {
"serverMethod": {
"handler": "serverMethod"
}
}
},
"location": {
"cti_global_sidebar": {
"url": "Customerlookup.html",
"icon": "nice.png"
}
}
}
},
"engines": {
"node": "14.20.0",
"fdk": "8.6.7"
},
"whitelisted-domains": [
"https://*.freshdesk.com",
]
}
Thanks!