hello everyone i am trying to display a notification on freshdesk based on external event , i am using the envoke methode to call server component no error dispalyed but i don’t see any notification in freshdesk.
////////
my server.js code:
exports = {
events: [
{ event: ‘onTicketUpdate’, callback: ‘eventCallbackMethod’ }
],
onExternalEventHandler: async function(payload) {
const { data } = payload;
generateTargetUrl()
.then(function(url) {
//Include API call to the third party to register your webhook
console.log("//////////////////// yees/: "+url);
console.log(data);
renderData(null, data)
},
function(err) {
console.log("//////////////////// no: ");
// Handle error
});
},
}
//////////
my app.js code:
function showNotification(status, message) {
client.interface.trigger(“showNotify”, {
type: status,
message: message
}).catch(function (error) {
console.error(‘failed to show notification’);
console.error(error);
});
};
//function NotifyUser() {
//const options = {“url”: “http://localhost:10001/event/hook/freshdesk”};
client.data.post(“http://localhost:10001/event/hook/freshdesk”).then(
function (data) {
console.log(“test”);
client.request.invoke(‘onExternalEventHandler’, data).then(function (data) {
console.info(‘Ticket create successfull’);
console.info(JSON.stringify(data));
console.log(data);
showNotification(‘success’, Ticket created successfully! Ticket ID: ${data}
);
renderData(null, data)
}).catch(function (error) {
console.error(‘Ticket create error’);
console.error(JSON.stringify(error));
showNotification(‘danger’, ‘Failed to create ticket.’);
});
},
function (error) {
console.error(‘Error: Failed to get ticket information’);
console.error(error);
showNotification(‘danger’, ‘Failed to get ticket information.’);
}
);