Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
Created December 20, 2016 17:28
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 sunnygleason/dedfa027e97ddb381a0c04758ef445e1 to your computer and use it in GitHub Desktop.
Save sunnygleason/dedfa027e97ddb381a0c04758ef445e1 to your computer and use it in GitHub Desktop.
PubNub Time Series AI w/ Falkonry BLOCK
function process(request) {
const xhr = require('xhr');
const token = 'YOUR_FALKONRY_API_TOKEN';
const webhookUrl = 'https://sandbox.falkonry.ai/webhook/YOUR_FALKONRY_WEBHOOK';
try {
request.message.time = new Date().getTime();
var params = {
method: 'POST',
headers: {
Authorization: 'Token ' + token,
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: request.message
};
return xhr.fetch(webhookUrl, params).then(function (r) {
console.log(r);
return request.ok();
});
} catch (e) {
console.error('Uncaught exception:', e);
return request.ok();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment