Git Product home page Git Product logo

anchovy-bot's Introduction

Serverless Telegram Bot

Create a serverless Telegram Bot with a database to keep track of users using Netlify Functions and FaunaDB

Deploy to Netlify

Getting Started

  • Getting Telegram Bot token and FaunaDB key
  • Deploy to Netlify
  • Hooking up the Bot

Getting Telegram Bot token and FaunaDB key

On Telegram, create a new Telegram bot by talking to @botfather and thereafter get the token for the Telegram Bot.

On FaunaDb site, create a collection with the name user (optionally, generate an index for the collection and specify the term for the id to be unique). Head to the security section and generate a FaunaDB key for the collection.

Deploy to Netlify

Deploy to Netlify either by linking to this repository manually or by clicking the "Deploy to netlify" above.

Remember to fill in the environment variables on netlify - TELEGRAM_BOT_TOKEN, FAUNA_SECRET_KEY with the token and the secret key obtained respectively

Hooking up the Bot

Thereafter, you need to specify and tell telegram where your bot should direct the messages it received to. Do so by simply visiting this url (without the {, })

https://api.telegram.org/bot{your_bot_token}/setWebhook?url={your_netlify_domain_url}/api/bot

If it is set up correctly, it should respond back with

{
  "ok": true,
  "result": true,
  "description": "Webhook was set"
}

Afterwhich, YOU ARE DONE!๐ŸŽ‰๐ŸŽ‰

Try typing /start to your bot and watch as the user ID of the Telegram user is stored inside your FaunaDB database

Extending Telegram Bot Functionality

This bot uses telegraf.js for its Telegram Bot functionality. Head to its website to find out how to extend the functionality of the bot you have created :)

anchovy-bot's People

Contributors

annchouz avatar olgadorio avatar

Watchers

 avatar

Forkers

annchouz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.