https://github.com/jokarz/netlify-fauna-telegram-bot
Create serverless Telegram bot with Netlify Function and FaunaDB for free!
https://github.com/jokarz/netlify-fauna-telegram-bot
fauna faunadb js netlify netlify-functions telegram-bot
Last synced: 4 months ago
JSON representation
Create serverless Telegram bot with Netlify Function and FaunaDB for free!
- Host: GitHub
- URL: https://github.com/jokarz/netlify-fauna-telegram-bot
- Owner: jokarz
- Created: 2019-12-10T08:59:58.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-01-22T09:58:50.000Z (over 2 years ago)
- Last Synced: 2023-03-07T22:03:38.651Z (over 2 years ago)
- Topics: fauna, faunadb, js, netlify, netlify-functions, telegram-bot
- Language: JavaScript
- Homepage:
- Size: 60.5 KB
- Stars: 34
- Watchers: 3
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Serverless Telegram Bot
Create a serverless Telegram Bot with a database to keep track of users using Netlify Functions and FaunaDB
[](https://app.netlify.com/start/deploy?repository=https://github.com/jokarz/netlify-fauna-telegram-bot)
# 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](https://telegram.me/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 **userId** 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
```json
{
"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](https://telegraf.js.org/#/) to find out how to extend the functionality of the bot you have created :)