Skip to content

Instantly share code, notes, and snippets.

@ypcode
Last active January 5, 2020 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ypcode/6e79a259a6ee98ed2cae85a8e24793bc to your computer and use it in GitHub Desktop.
Save ypcode/6e79a259a6ee98ed2cae85a8e24793bc to your computer and use it in GitHub Desktop.
module.exports = async function (context, req) {
context.log('Executing Webhook endpoint...');
// Validate the subscription creation
if (req.query.validationToken) {
context.log('Validating new subscription...');
context.log('Validation token:');
context.log(req.query.validationToken);
context.res = {
headers: {
'Content-Type': 'text/plain'
},
body: req.query.validationToken
};
}
else {
context.log('Received new notification...');
context.log('Notification: ');
context.log(JSON.stringify(req.body));
context.res = { body: "" };
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment