Uptime Slackbot: Getting Started
Tags: uptime, slackbot, firebase
Published: 2023-04-04 20:43:00

---
title: Uptime Slackbot: Getting Started
published: true
description: Learn how to monitor the availability of your website using Firebase and Slack in this informative guide, which explains the process step by step and helps you set up your own monitoring system without relying on paid services.
tags: #Uptime #Slackbot #Firebase
series: Uptime Slackbot with Firebase Cloud Functions
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
published_at: 2023-04-04 20:43 +0000
---
> **TLDR:** the whole source code for this project is on GitHub: [https://github.com/nico-martin/uptime-slackbot](https://github.com/nico-martin/uptime-slackbot)

For several years I have been using UptimeRobot, a service that monitors the availability of my site and sends me a message in a Slack channel when the site is down. Until the end of 2022, this worked great with my free plan. However, after an [adjustment to the pricing structure](https://blog.uptimerobot.com/december-2022-we-are-introducing-sub-users-and-new-plans/), Slack integration is now only available on the "Solo." Plan.

Of course I understand that the operation of the platform has to be financed and yes, $84 per year is quite reasonable. But for my private projects this is not really worth it.
Moreover, it should be quite easy to build such a monitoring system yourself, right?

So what do I need exactely. I need a service that requests a Website every five minutes. If the request has a status code of 300 or higher, its concidered as "down". If lower than 300 it is "up".
"Down" should send me a notification. Furthermore it should recheck every 2 seconds and notify me again when the site is back up. So far so good.

Let's take the individual parts apart.
1. I need a reliable service that executes the requests and attempts retries when a request fails.
2. I need a database that tracks the attempts.
3. I need to set up a messaging system through slack.
 
So far so good. I was able to answer the first fundamental question very quickly. No, I do not want to be responsible for hosting an application myself, for which high availability is absolutely necessary. So it had to be a cloud provider. And a quick comparison of the developer experience immediately led me to [Firebase](https://firebase.google.com/).
With Cloud Functions I have an easy way to execute certain tasks in time intervals and with the Firestore Database I have a highly available database to store the status of my requests.

## Initialize Firebase

The setup in Firebase is pretty simple.
Communicationis handled by `firebase-tools`, which is best installed globally right away:
```
npm install -g firebase-tools
```
After that you can go to your project folder and install some dependencies:
```
npm install firebase-functions@latest firebase-admin@latest --save
```
The initial setup can then be completed with the following steps:
1. Run `npx firebase login`, this allows you to login via the browser
2. `npx firebase init firestore` this will initialize your project. I guess you will need to create a new project if you haven't created the project already.
3. `npx firebase init functions` now you can set up the cloud functions for the same project before. You will also be asked if you want to use TypeScript or JavaScript. In this example, I choose TypeScript.
4. As the last step, all dependencies will be installed for you together with the whole folder structure.
5. Additionally I have installed prettier for automatic code formatting in the `functions` folder: `npm install prettier eslint-config-prettier --save-dev`. To make the setup work exactly the same as in my example I recommend to compare your [eslint](https://github.com/nico-martin/uptime-slackbot/blob/main/functions/.eslintrc.js) and [typescript](https://github.com/nico-martin/uptime-slackbot/blob/main/functions/tsconfig.json) configuration with mine.

And with that we are ready to start with the implementation. More about this in the [second part](https://dev.to/nicomartin/uptime-monitoring-with-firebase-4off).