{"action":"created","comment":{"url":"https://api.github.com/repos/auth0/blog/pulls/comments/33758405","id":33758405,"diff_hunk":"@@ -0,0 +1,155 @@\n+---\n+layout: post\n+title: \"If This Then [Node.js]\"\n+description: Extending IFTTT With Webtask.io\n+date: 2015-07-01 15:39\n+author: \n+  name: Milo Mordaunt\n+  url: https://twitter.com/bananaoomarang\n+  mail: milo@auth0.com\n+  avatar: https://en.gravatar.com/userimage/24343392/119d3a13b6da0d9eabbcde831f163c4b.jpeg\n+design: \n+  bg_color: \"#297BC3\"\n+  image: https://cldup.com/8iklT4GjWO.png\n+tags: \n+- webtasks\n+- ifttt\n+- pocket\n+- tutorial\n+---\n+\n+![Simples](https://docs.google.com/drawings/d/1Ab0L0_5914Xs7wTKzu2uSJuk4_lFoSDUYaHravjlq-8/pub?w=566&h=218)\n+\n+If you've ever used IFTTT as a developer and thought something like: \"Gee, I wish I could write my own scripts as channels\", you may just be in luck, webtasks have you covered. In this article we'll build a simple IFTTT channel which logs words used in the headers and bylines of articles we save to [Pocket](https://getpocket.com/), so they are sortable by frequency.\n+\n+## What's a Webtask?\n+\n+```js\n+return function (done) {\n+  done(null, 'Hello, Webtasks!');\n+}\n+```\n+\n+A webtask is a snippet of code that runs an entry function on a GET request, returning the result. The above is a very simple example but, as we will see in a moment, they can be extended as much as you wish. Their major benefits include:\n+\n++ Ease of use. No complicated setup, just code.\n++ Vastly simplifies/eliminates the need for backend code, boiling it down into reusable, functional pieces.\n++ Tamper proof (uses JSON Webtokens behind the scenes), and encrypted where they need to be\n+\n+You can play with the service online [here](https://webtask.io/tryit), and read more about it [here](https://webtask.io/docs), but what it amounts to is a safe and frictionless way to run custom micro-services. Perfect for extending IFTTT.\n+\n+## Setup\n+\n+Firstly we need to install the command line application, to make task management easier. To set it up all we need is:\n+\n+```\n+$ npm i -g auth0/wt-cli\n+$ wt init\n+```\n+\n+To test if it's working after the setup, make the file `hello-webtasks.js` and write either the following, or something to that effect:\n+\n+```js\n+\"use latest\";\n+\n+return (done) => {\n+  done(null, 'Hello, Webtasks!');\n+}\n+```\n+\n+The only requirement is that you return an entry function to be run on Webtask.io's servers, here we just send back a simple message. Just run:\n+\n+`$ wt create hello-webtasks.js` \n+\n+And you should be given a URL. Visit it in you're browser of choice and you can see the message is returned. It's pretty neat, right?\n+\n+![Cool beans.](https://cldup.com/C-syWsAP8w-300x300.jpeg \"Hello There!\")\n+\n+Even neater is the ability to add some context to the request (through a query string), and access it like so:\n+\n+```js\n+\"use latest\";\n+\n+return (ctx, done) => {\n+  let { name } = ctx.data;\n+\n+  done(null, 'Hello, ' + name);\n+}\n+```\n+\n+Generate a new URL with `wt create`, but this time when you visit it add `&name=<your name>` to the end of the address, and you're webtask will greet you!\n+\n+## Backend, What Backend?","path":"_posts/2015-07-01-if-this-then-node-dot-js-extending-ifttt-with-webtask-dot-io.markdown","position":82,"original_position":82,"commit_id":"2e94489914ee220f0dff741d5f7209c6745ff9be","original_commit_id":"2e94489914ee220f0dff741d5f7209c6745ff9be","user":{"login":"tjanczuk","id":822369,"avatar_url":"https://avatars.githubusercontent.com/u/822369?v=3","gravatar_id":"","url":"https://api.github.com/users/tjanczuk","html_url":"https://github.com/tjanczuk","followers_url":"https://api.github.com/users/tjanczuk/followers","following_url":"https://api.github.com/users/tjanczuk/following{/other_user}","gists_url":"https://api.github.com/users/tjanczuk/gists{/gist_id}","starred_url":"https://api.github.com/users/tjanczuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjanczuk/subscriptions","organizations_url":"https://api.github.com/users/tjanczuk/orgs","repos_url":"https://api.github.com/users/tjanczuk/repos","events_url":"https://api.github.com/users/tjanczuk/events{/privacy}","received_events_url":"https://api.github.com/users/tjanczuk/received_events","type":"User","site_admin":false},"body":"Not sure what we do about capitalization of titles on our blog, but we should be consistent.","created_at":"2015-07-02T08:56:27Z","updated_at":"2015-07-02T08:56:27Z","html_url":"https://github.com/auth0/blog/pull/40#discussion_r33758405","pull_request_url":"https://api.github.com/repos/auth0/blog/pulls/40","_links":{"self":{"href":"https://api.github.com/repos/auth0/blog/pulls/comments/33758405"},"html":{"href":"https://github.com/auth0/blog/pull/40#discussion_r33758405"},"pull_request":{"href":"https://api.github.com/repos/auth0/blog/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/auth0/blog/pulls/40","id":39025165,"html_url":"https://github.com/auth0/blog/pull/40","diff_url":"https://github.com/auth0/blog/pull/40.diff","patch_url":"https://github.com/auth0/blog/pull/40.patch","issue_url":"https://api.github.com/repos/auth0/blog/issues/40","number":40,"state":"open","locked":false,"title":"Added IFTTT + Webtasks post","user":{"login":"bananaoomarang","id":815831,"avatar_url":"https://avatars.githubusercontent.com/u/815831?v=3","gravatar_id":"","url":"https://api.github.com/users/bananaoomarang","html_url":"https://github.com/bananaoomarang","followers_url":"https://api.github.com/users/bananaoomarang/followers","following_url":"https://api.github.com/users/bananaoomarang/following{/other_user}","gists_url":"https://api.github.com/users/bananaoomarang/gists{/gist_id}","starred_url":"https://api.github.com/users/bananaoomarang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bananaoomarang/subscriptions","organizations_url":"https://api.github.com/users/bananaoomarang/orgs","repos_url":"https://api.github.com/users/bananaoomarang/repos","events_url":"https://api.github.com/users/bananaoomarang/events{/privacy}","received_events_url":"https://api.github.com/users/bananaoomarang/received_events","type":"User","site_admin":false},"body":"Added Webtasks tutorial post","created_at":"2015-07-01T21:05:22Z","updated_at":"2015-07-02T08:56:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"698bc8d02d9c3d159121be5fa8a4a2a7dead9f84","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/auth0/blog/pulls/40/commits","review_comments_url":"https://api.github.com/repos/auth0/blog/pulls/40/comments","review_comment_url":"https://api.github.com/repos/auth0/blog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/auth0/blog/issues/40/comments","statuses_url":"https://api.github.com/repos/auth0/blog/statuses/2e94489914ee220f0dff741d5f7209c6745ff9be","head":{"label":"bananaoomarang:ifttt-article","ref":"ifttt-article","sha":"2e94489914ee220f0dff741d5f7209c6745ff9be","user":{"login":"bananaoomarang","id":815831,"avatar_url":"https://avatars.githubusercontent.com/u/815831?v=3","gravatar_id":"","url":"https://api.github.com/users/bananaoomarang","html_url":"https://github.com/bananaoomarang","followers_url":"https://api.github.com/users/bananaoomarang/followers","following_url":"https://api.github.com/users/bananaoomarang/following{/other_user}","gists_url":"https://api.github.com/users/bananaoomarang/gists{/gist_id}","starred_url":"https://api.github.com/users/bananaoomarang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bananaoomarang/subscriptions","organizations_url":"https://api.github.com/users/bananaoomarang/orgs","repos_url":"https://api.github.com/users/bananaoomarang/repos","events_url":"https://api.github.com/users/bananaoomarang/events{/privacy}","received_events_url":"https://api.github.com/users/bananaoomarang/received_events","type":"User","site_admin":false},"repo":{"id":38394947,"name":"blog","full_name":"bananaoomarang/blog","owner":{"login":"bananaoomarang","id":815831,"avatar_url":"https://avatars.githubusercontent.com/u/815831?v=3","gravatar_id":"","url":"https://api.github.com/users/bananaoomarang","html_url":"https://github.com/bananaoomarang","followers_url":"https://api.github.com/users/bananaoomarang/followers","following_url":"https://api.github.com/users/bananaoomarang/following{/other_user}","gists_url":"https://api.github.com/users/bananaoomarang/gists{/gist_id}","starred_url":"https://api.github.com/users/bananaoomarang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bananaoomarang/subscriptions","organizations_url":"https://api.github.com/users/bananaoomarang/orgs","repos_url":"https://api.github.com/users/bananaoomarang/repos","events_url":"https://api.github.com/users/bananaoomarang/events{/privacy}","received_events_url":"https://api.github.com/users/bananaoomarang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bananaoomarang/blog","description":"auth0 blog","fork":true,"url":"https://api.github.com/repos/bananaoomarang/blog","forks_url":"https://api.github.com/repos/bananaoomarang/blog/forks","keys_url":"https://api.github.com/repos/bananaoomarang/blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bananaoomarang/blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bananaoomarang/blog/teams","hooks_url":"https://api.github.com/repos/bananaoomarang/blog/hooks","issue_events_url":"https://api.github.com/repos/bananaoomarang/blog/issues/events{/number}","events_url":"https://api.github.com/repos/bananaoomarang/blog/events","assignees_url":"https://api.github.com/repos/bananaoomarang/blog/assignees{/user}","branches_url":"https://api.github.com/repos/bananaoomarang/blog/branches{/branch}","tags_url":"https://api.github.com/repos/bananaoomarang/blog/tags","blobs_url":"https://api.github.com/repos/bananaoomarang/blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bananaoomarang/blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bananaoomarang/blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/bananaoomarang/blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bananaoomarang/blog/statuses/{sha}","languages_url":"https://api.github.com/repos/bananaoomarang/blog/languages","stargazers_url":"https://api.github.com/repos/bananaoomarang/blog/stargazers","contributors_url":"https://api.github.com/repos/bananaoomarang/blog/contributors","subscribers_url":"https://api.github.com/repos/bananaoomarang/blog/subscribers","subscription_url":"https://api.github.com/repos/bananaoomarang/blog/subscription","commits_url":"https://api.github.com/repos/bananaoomarang/blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/bananaoomarang/blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/bananaoomarang/blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/bananaoomarang/blog/issues/comments{/number}","contents_url":"https://api.github.com/repos/bananaoomarang/blog/contents/{+path}","compare_url":"https://api.github.com/repos/bananaoomarang/blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bananaoomarang/blog/merges","archive_url":"https://api.github.com/repos/bananaoomarang/blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bananaoomarang/blog/downloads","issues_url":"https://api.github.com/repos/bananaoomarang/blog/issues{/number}","pulls_url":"https://api.github.com/repos/bananaoomarang/blog/pulls{/number}","milestones_url":"https://api.github.com/repos/bananaoomarang/blog/milestones{/number}","notifications_url":"https://api.github.com/repos/bananaoomarang/blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bananaoomarang/blog/labels{/name}","releases_url":"https://api.github.com/repos/bananaoomarang/blog/releases{/id}","created_at":"2015-07-01T21:03:39Z","updated_at":"2015-07-01T21:03:40Z","pushed_at":"2015-07-01T22:14:05Z","git_url":"git://github.com/bananaoomarang/blog.git","ssh_url":"git@github.com:bananaoomarang/blog.git","clone_url":"https://github.com/bananaoomarang/blog.git","svn_url":"https://github.com/bananaoomarang/blog","homepage":"https://auth0.com/blog","size":16788,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"auth0:master","ref":"master","sha":"830abe9513fb51c50556470753c3d1d5aada232a","user":{"login":"auth0","id":2824157,"avatar_url":"https://avatars.githubusercontent.com/u/2824157?v=3","gravatar_id":"","url":"https://api.github.com/users/auth0","html_url":"https://github.com/auth0","followers_url":"https://api.github.com/users/auth0/followers","following_url":"https://api.github.com/users/auth0/following{/other_user}","gists_url":"https://api.github.com/users/auth0/gists{/gist_id}","starred_url":"https://api.github.com/users/auth0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auth0/subscriptions","organizations_url":"https://api.github.com/users/auth0/orgs","repos_url":"https://api.github.com/users/auth0/repos","events_url":"https://api.github.com/users/auth0/events{/privacy}","received_events_url":"https://api.github.com/users/auth0/received_events","type":"Organization","site_admin":false},"repo":{"id":7830124,"name":"blog","full_name":"auth0/blog","owner":{"login":"auth0","id":2824157,"avatar_url":"https://avatars.githubusercontent.com/u/2824157?v=3","gravatar_id":"","url":"https://api.github.com/users/auth0","html_url":"https://github.com/auth0","followers_url":"https://api.github.com/users/auth0/followers","following_url":"https://api.github.com/users/auth0/following{/other_user}","gists_url":"https://api.github.com/users/auth0/gists{/gist_id}","starred_url":"https://api.github.com/users/auth0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auth0/subscriptions","organizations_url":"https://api.github.com/users/auth0/orgs","repos_url":"https://api.github.com/users/auth0/repos","events_url":"https://api.github.com/users/auth0/events{/privacy}","received_events_url":"https://api.github.com/users/auth0/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/auth0/blog","description":"auth0 blog","fork":false,"url":"https://api.github.com/repos/auth0/blog","forks_url":"https://api.github.com/repos/auth0/blog/forks","keys_url":"https://api.github.com/repos/auth0/blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/auth0/blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/auth0/blog/teams","hooks_url":"https://api.github.com/repos/auth0/blog/hooks","issue_events_url":"https://api.github.com/repos/auth0/blog/issues/events{/number}","events_url":"https://api.github.com/repos/auth0/blog/events","assignees_url":"https://api.github.com/repos/auth0/blog/assignees{/user}","branches_url":"https://api.github.com/repos/auth0/blog/branches{/branch}","tags_url":"https://api.github.com/repos/auth0/blog/tags","blobs_url":"https://api.github.com/repos/auth0/blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/auth0/blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/auth0/blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/auth0/blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/auth0/blog/statuses/{sha}","languages_url":"https://api.github.com/repos/auth0/blog/languages","stargazers_url":"https://api.github.com/repos/auth0/blog/stargazers","contributors_url":"https://api.github.com/repos/auth0/blog/contributors","subscribers_url":"https://api.github.com/repos/auth0/blog/subscribers","subscription_url":"https://api.github.com/repos/auth0/blog/subscription","commits_url":"https://api.github.com/repos/auth0/blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/auth0/blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/auth0/blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/auth0/blog/issues/comments{/number}","contents_url":"https://api.github.com/repos/auth0/blog/contents/{+path}","compare_url":"https://api.github.com/repos/auth0/blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/auth0/blog/merges","archive_url":"https://api.github.com/repos/auth0/blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/auth0/blog/downloads","issues_url":"https://api.github.com/repos/auth0/blog/issues{/number}","pulls_url":"https://api.github.com/repos/auth0/blog/pulls{/number}","milestones_url":"https://api.github.com/repos/auth0/blog/milestones{/number}","notifications_url":"https://api.github.com/repos/auth0/blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/auth0/blog/labels{/name}","releases_url":"https://api.github.com/repos/auth0/blog/releases{/id}","created_at":"2013-01-25T22:57:37Z","updated_at":"2015-06-29T18:31:27Z","pushed_at":"2015-07-01T22:14:05Z","git_url":"git://github.com/auth0/blog.git","ssh_url":"git@github.com:auth0/blog.git","clone_url":"https://github.com/auth0/blog.git","svn_url":"https://github.com/auth0/blog","homepage":"https://auth0.com/blog","size":16788,"stargazers_count":5,"watchers_count":5,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":4,"forks":8,"open_issues":4,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/auth0/blog/pulls/40"},"html":{"href":"https://github.com/auth0/blog/pull/40"},"issue":{"href":"https://api.github.com/repos/auth0/blog/issues/40"},"comments":{"href":"https://api.github.com/repos/auth0/blog/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/auth0/blog/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/auth0/blog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/auth0/blog/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/auth0/blog/statuses/2e94489914ee220f0dff741d5f7209c6745ff9be"}}}}