Creating a Chatbot for Slack with Node.js in 17 lines

Creating a chatbot for Slack, the easy to setup group chat for teams was surprisingly easy. In this post we’re going to go over creating a chat bot that can reply to queries and take an action on simple keywords.

We’re going to use a node module called BotKit, which will enable us to connect to Slack easily. Actually Botkit offers a GUI (paid plans) and also connects to Microsoft Teams, Spark, Twilio and even Facebook.

One of the things I like the most about it is that you can kind of build a bot once and then re-use components across different platforms, which is super cool.

This post is written with

  • node 9.3.0

but will probably be up and downwards compatible fairly far since the dependency has been around for a while.

Continue reading “Creating a Chatbot for Slack with Node.js in 17 lines”

Typescript and Node.js Tutorial for the Backend (Beginner)

Typescript has become a popular tool to reduce errors when writing JavaScript. It was developed by Microsoft and gained a lot of popularity when Angular adopted it as a first level citizen. When Angular 2 was nearing completion, the only docs available were for Typescript.

Typescript doesn’t only work for browser or frontend code, you can also choose to write your backend applications in it if you want to use Node.js but have some additional type safety and the other abstraction that the language brings.

Typescript and Node Starter

Continue reading “Typescript and Node.js Tutorial for the Backend (Beginner)”

Building a Simple Searchable API with Express (Backend)

Express is still one of the most prominent server side frameworks for node. This little guide will show you how you can build a simple API and connect it with your frontend framework of choice.

If you’re trying to build a site that features a list of items, stores, products or similar on your front page, read on. Examples of this could be sites like or the Google Play Store.

Continue reading “Building a Simple Searchable API with Express (Backend)”

Taking Full Page Screenshots with Headless Chrome

A returning subject on this blog, how to automate device screenshots with Node.js and Chrome. This post will cover installation and running the script on either Mac OS or Linux. If you’re brave, you can use Windows too 😉

Continue reading “Taking Full Page Screenshots with Headless Chrome”

Node.js / GHOST theme development and deployment

Few weeks ago we decided to switch our static site to GHOST and write a theme for it. Now, GHOST isn’t an optimal choice for a photography portfolio and we’ll get into why that’s the case in a bit, but we both like blogging to, so we wanted to give it a shot.

Continue reading “Node.js / GHOST theme development and deployment”

Express, Passport and JSON Web Token (jwt) Authentication for Beginners

This post is going to be about creating an authentication with JSON Web Tokens for your project, presumably an API that’s going to be used by Angular, Vue.js or similar frontend frameworks. We’re going to send the jwt with every request, meaning that we don’t rely on sessions, but simply put the token on every request we make to the API. This way you don’t have to worry about cookies, but you can save it in localStorage or other places on the frontend.

In essence this tutorial will go through:

  • creating a /login route to acquire a token
  • creating a /secret route, that only is available to logged in users with a JSON web token

If you’re curious about the final result and don’t want the step by step guide, check out the final jwt express gist.

Continue reading “Express, Passport and JSON Web Token (jwt) Authentication for Beginners”

Crawling an entire Domain / Website

This post is going to be about crawling an entire domain in Node.js. You can find the first posts of the series here: Web Scraping / Web Crawling Pages with Node.js.

For testing purposes I have created a simple set of HTML pages, that should resemble a generic website. It has some page and we want our crawler to go through them and make sure it finds all of them, where they’re linked. That means when our crawler hits a page, it should keep track of the links it finds and then only proceed to pages it has not crawled yet.

Continue reading “Crawling an entire Domain / Website”

Web Crawling with Node.js #2: Building the Page Object

Welcome to part 2 of the series crawling the web with Node.js. In this article we’re going to have a look at what valuable content we can grab from a page. Important parts when writing a crawler are obviously links, because our crawler wouldn’t know where to go next without them.

The data I’m going to extract from a page are not necessarily the ones you’ll want and it really all depends what you want with the project. Maybe you only want the content of specific tags or status codes. I’ll just put up some examples and you can see from there what’s possible and see what would make sense for your purpose.

Continue reading “Web Crawling with Node.js #2: Building the Page Object”

Web Scraping / Web Crawling Pages with Node.js

This post series is going to discuss and illustrate how to write a web crawler in node.js. I’m going to write some posts on a topic that are database agnostic and the database part split up into the respective different databases you could imagine using.

Continue reading “Web Scraping / Web Crawling Pages with Node.js”

How to: enable CORS in express.js (node.js)

Express.js is one of the most popular node.js frameworks for serving websites or building APIs. This article is about how to enable Cross Origin Resource Sharing, also known as CORS. For that we need to set the correct headers in the response, which allow a browser to make use of the data from any domain.

Continue reading “How to: enable CORS in express.js (node.js)”