Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neumanf/grammy-vercel-boilerplate
grammY boilerplate to develop and host telegram bots on Vercel
https://github.com/neumanf/grammy-vercel-boilerplate
boilerplate grammy telegram-bot vercel vercel-now
Last synced: about 2 months ago
JSON representation
grammY boilerplate to develop and host telegram bots on Vercel
- Host: GitHub
- URL: https://github.com/neumanf/grammy-vercel-boilerplate
- Owner: neumanf
- License: mit
- Created: 2021-07-30T13:36:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-31T13:59:04.000Z (almost 3 years ago)
- Last Synced: 2024-08-01T22:52:58.989Z (5 months ago)
- Topics: boilerplate, grammy, telegram-bot, vercel, vercel-now
- Language: TypeScript
- Homepage:
- Size: 211 KB
- Stars: 17
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# grammY Vercel boilerplate
[grammY](https://grammy.dev/) boilerplate to develop and host telegram bots on [Vercel](https://vercel.com/).
## Features
- Typescript support
- Linting and formatting preconfigured
- Development friendly environment with Nodemon## Development
```bash
# Copy the .env example and change the BOT_TOKEN to match yours
$ cp .env.example .env
# Install the dependencies
$ npm install
# Run the development environment
$ npm run dev
```## Deployment
#### Terminal
```bash
# Install vercel cli if you don't have it yet
$ npm i -g vercel
# Deploy the project
$ vercel --prod
```#### Vercel
On your project's page, go to Settings > Environment Variables and add the following variables:
| Name | Value |
| ----------- | ---------------- |
| `BOT_TOKEN` | _your bot token_ |> You can also set the webhook URL manually accessing `https://api.telegram.org/bot/setWebhook?url=` on your browser
Finally, you should see a "Hello, world!" from the bot when typing `/hello` in chat.
## Using Express instead of Vercel's API
By default `grammy-vercel-boilerplate` does not use extra dependencies, but in case you want to use Express, first add it as a dependency
```sh
$ npm install express
```And then edit the contents of `api/index.ts` to
```js
require("../src/index");import express from "express";
import { webhookCallback } from "grammy";import bot from "../src/core/bot";
const app = express();
app.use(express.json());
app.use(`/api/index`, webhookCallback(bot));export default app;
```## Contributing
Pull requests are welcome. If you have any suggestions, you can also create an [issue](https://github.com/neumanf/grammy-vercel-boilerplate/issues).
## License
[MIT](https://choosealicense.com/licenses/mit/)