Discussions
How to setup a webhook addon for jobs status change using Simple function nodeJS
11 days ago by Motaz Mohamed
I am trying to create my own addon webhook here but it doesnt seem to trigger and its always telling me invalid function
any pointers would be helpful to tell me what i am missing or not doing correctly
here is my manifest
{
"name": "xxxxxx",
"version": "6.0",
"iconURL": "https:\/\/www.servicem8.com\/images\/addon-sdk-sample-icon.png",
"supportURL": "https:\/\/support.exampleaddon.com",
"supportEmail": "support@exampleaddon.com",
"oauth": {
"scope": "manage_jobs read_jobs"
},
"actions": [],
"menuItems": [],
"webhooks": [{
"object": "job",
"fields": [
"status"
]}
]
}
and here is my simple function
var request = require('request');
exports.handler = (event, context, callback) => {
var strJobUUID = event.eventArgs.entry[0].uuid;
var strAccessToken = event.auth.accessToken;
var jobData = {
status: 'Completed',
uuid: strJobUUID
};
request.post({
url: 'third_party_endpoint',
headers: {
accept: 'application/json',
'User-Agent': 'Mozilla/5.0',
// 'Authorization': authorizationHeader
},
body: JSON.stringify(jobData)
}, function (err, httpResponse, body) {
callback(null, {result: "job added to third party"});
});
callback(null, {result: "job added to third party"});
the addon keeps telling me invalid function
Not Ready (Function Not Valid)