Skip to content

Instantly share code, notes, and snippets.

@gijsepping
Last active September 23, 2020 11:52
Show Gist options
  • Save gijsepping/c9cf1ea32923f0af6a1519bf0dc70e8f to your computer and use it in GitHub Desktop.
Save gijsepping/c9cf1ea32923f0af6a1519bf0dc70e8f to your computer and use it in GitHub Desktop.
Roam zend block to zapier zap
document.addEventListener('input', function(e){
if ('_webhookHook' in window) {
setTimeout(function(){ window._webhookHook(e); }, 0);
}
});
window._webhookHook = async function(e) {
// logging
window._e = e;
// exit if not target
var elem = e.target
console.log(elem.value);
var res = elem.value.match(/#zap/g);
if(res){
elem.value = elem.value.replace('#zap', '#really-done');
(async () => {
const rawResponse = await fetch('https://hooks.zapier.com/hooks/catch/2323232323236/', {
method: 'POST',
headers: {
'Accept': 'application/json'
},
body: JSON.stringify({zap: 'teams', message: elem.value})
});
const content = await rawResponse.json();
console.log(content);
})();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment