Serverless Telegram Bot with Firebase

Firebase + Telegram = pure love

1. Create your Bot

  1. Search in telegram @BotFather or open this link
  2. Write the command “/newBot “
  3. Follow all the steps
  4. Write down 2 things :
  5. bot name (finished in ‘bot’): In our example firebase_bot
  6. Secret Token (don’t miss it): in our example LONG_STRING_TOKEN
Telegram bot creation

2. Create your Firebase project

  1. Go to your firebase console
  2. Add a new project
  3. Write down the id of the project: in our example firebase-bot-560a7
Firebase project creation

3. The code

3.1 Set the enviroment

  1. Install globally firebase-tools: npm install -g firebase-tools
  2. Login into firebase: firebase login
  3. Create a folder and run inside: npm init
  4. Init firebase in the same folder: firebase init
  5. Choose: Functions: Configure and deploy Cloud Functions
  6. Select a default Firebase project:
    6.1 — We have a firebase project id created on the point 2.3, if this is shown in the options choose it
    6.2 — If the project is not there choose [create a new project] (we will pick the project later)
  7. Javascript or Typescript: (IMHO) Typescript
  8. TSLint: Yes
  9. install npm dependencies: Yes
  10. If in the point 6 you didn’t choose your firebase project set it now with: firebase use firebase-bot-560a7 (this has to be the id of your firebase project, point 2.3)
  11. install functions dependencies:
  • cd functions folder
  • npm install — save express cors
Firebase init your code

3.2 The actual code

  1. In the root of your project run: firebase deploy only --functions
  2. Wait until the process finish and write down the router function url: in our case
Firebase deploying router function

4. Bind the bot to Firebase

  1. Go to your browser and put the bold text with your data, we have defined TOKEN in 1.4.2 and the url in 3.3.2 MAIN LAST “/”
  2. Check is set correctly going to
Telegram bot and firebase binded

5. Check the results


An web artisan too old for the hype. 📜 "I hear and I forget. I see and I remember. I do and I understand."

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Taraxa Weekly Update — Week 33

TFT Seer Patch 2.0 Notes

Before and After GIF of the TFT Seer home page

Univers forms a Strategic Partnership with Polygon Studios

Git Commands

Kotlin Advanced Programming (Part 4)

The Dichotomy of Discipline in Software Development

Launching Flutter Task Listing App Theme

How To Run Java APIs on AWS App Runner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Francisco Gutiérrez

Francisco Gutiérrez

An web artisan too old for the hype. 📜 "I hear and I forget. I see and I remember. I do and I understand."

More from Medium

Firebase Deployment

Sentiment Analysis (BERT) with MongoDB Atlas, Realm and Change Streams

Deploy Node App in 4 EASY Steps Using Caddy

Python|Build FARM Stack App|0. 介紹