Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example code for every single framework adapter #993

Open
eclipseeer opened this issue Feb 14, 2024 · 3 comments
Open

Add example code for every single framework adapter #993

eclipseeer opened this issue Feb 14, 2024 · 3 comments

Comments

@eclipseeer
Copy link

The example below doesn't contains all info about how dev can setup webhooks. Would be nice to provide more clear example for this:
image

for example:

import express from 'express';
import { Bot, webhookCallback } from 'grammy';

const app = express();
app.use(express.json());

const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN);
await bot.api.setWebhook('https://base_server_url');

bot.on('message', async (ctx) => { ... });

app.use(webhookCallback(bot, 'express'));
app.listen(8080);
@KnorpelSenf
Copy link
Member

I think at that point we need to provide code examples for every adapter. That would be reasonable anyway, as it's a common question.

It would be incorrect to call setWebhook the way you do, since many people use serverless deployments which would call that method way too many times. We can elaborate on setting the URL in a different way.

@eclipseeer
Copy link
Author

I'm quite new in Telegram bot development and dont sure on 100% about how to setup webhook in the proper way. Just saw the similar approuch in other libs like node-telegram-bot-api. This is why I posted this issue - would be helpfull to see the proper approuch in the lib docs.

@KnorpelSenf
Copy link
Member

"The proper way" depends on the exact framework you are using, and on where you host it. There is no one-size-fits-all solution, which is why the docs currently only give an example that is mostly relevant for a large audience, and that leaves the rest to the developer.

A few more examples can be found in the example bots repository, although it isn't exactly tailored towards your question.

@KnorpelSenf KnorpelSenf transferred this issue from grammyjs/grammY Feb 15, 2024
@KnorpelSenf KnorpelSenf changed the title Update docs - How to Use Webhooks Add example code for every single framework adapter Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants