Skip to content

Instantly share code, notes, and snippets.

@spasiu
Created February 21, 2016 13:42
Show Gist options
  • Select an option

  • Save spasiu/d90b3a3368d6f5509e52 to your computer and use it in GitHub Desktop.

Select an option

Save spasiu/d90b3a3368d6f5509e52 to your computer and use it in GitHub Desktop.
create webhook with node.js
var request = require('superagent');
var jwt = require('jsonwebtoken');
var USER_ID = 'appUser _id';
var KEY_ID = 'your_key_id';
var SECRET = 'your_secret';
var token = jwt.sign({
scope: 'app'
},
SECRET,
{
headers: {
kid: KEY_ID
}
});
request
.post('https://api.smooch.io/v1/webhooks')
.send({target: 'http://example.com/callback'})
.set('authorization', 'Bearer ' + token)
.set('Accept', 'application/json')
.set('content-type', 'application/json')
.end(function(err, res) {
console.log(err, res.body, res.statusCode);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment