feathers-studio / telegraf-docs

Documentation for Telegraf - the modern Bot API framework
https://telegraf.js.org
MIT License
303 stars 32 forks source link

Is express example working? #18

Closed painkkiller closed 11 months ago

painkkiller commented 11 months ago

I am trying to make my first bot on base express framework. Example from here https://github.com/feathers-studio/telegraf-docs/blob/master/examples/webhook/express.ts not works. I am testing webhooks with ngrok, when I am making URI for webhook with express on my own I am getting calls from telegram and everything is OK. But I am unable to make bot work on commands, I suppose this line simply not works: app.use(await bot.createWebhook({ domain: webhookDomain, path: URI }));

So I am unable to make my bot react on webhooks call from telegram

painkkiller commented 11 months ago

I also tried to handle updates from webhook via this:

expressApp.post(URI, (req, res) => {
  console.log('post', req.body);
  /* 
    we need to respond back with 200 to let telegram know that we 
    have received the update. Failing to do so will result in telegram 
    not sending further updates after the first one.
  */
  return bot.handleUpdate(req.body, res);
}); 

but looks method handleUpdate don't work nowdays, bot still can't react on commands

MKRhere commented 11 months ago

Both should work. Maybe you have an over-enthusiastic middleware that doesn't call next?

painkkiller commented 11 months ago

I've already found the culprit in my code. Thanks. Closing this ticket.