jsjoeio / telegram-bot-template

A Telegram bot template that uses telegraf.js + Vercel serverless functions
34 stars 4 forks source link

First suggestion #1

Closed waptik closed 3 years ago

waptik commented 3 years ago

I was building a bot months ago using blitz and prisma + telegraf, and i must say it was hella of a tedious work getting telegram user data in sync with the database(Checking if the telegram user is already available in the db at each incoming updates). I made use of telegraf sessions but it was not stable(i might have done things wrongly).

Well, i think that's it.

Bot pooling vs bot webhook, which one is must suitable for this? I usually use webhook when the bot is hosted on the cloud.

jsjoeio commented 3 years ago

Make use of session(optional, if you don't use).

I don't yet, but I want to!

Preferably typescript with supabase tables, response types definition if it's not much to ask.

I don't have this yet but would want it!

I made use of telegraf sessions but it was not stable(i might have done things wrongly)

Good to know! I haven't touched them yet but really really want to. Maybe we can figure that out together.

Bot pooling vs bot webhook, which one is must suitable for this? I usually use webhook when the bot is hosted on the cloud.

I went with the webhook approach because it seemed easiest to deploy.

jsjoeio commented 3 years ago

Sweet! Thank you @waptik for opening this! I will add to my todo list and should get to this in September! 🙌

waptik commented 3 years ago

Sweet! Thank you @waptik for opening this! I will add to my todo list and should get to this in September! 🙌

Awesome. Can't wait to see how the first iteration turns out. I'll help in anyway i can.

jsjoeio commented 3 years ago

Hey @waptik - I finally found some time to make a very basic template. Feel free to check it out, ask questions here and then I'll close this after!

waptik commented 3 years ago

@jsjoeio Gave it a try. It's indeed very basic but works. Also saw that no pooling when in dev environment(did some for my template at https://github.com/waptik/telegram-bot-boilerplate-now-serverless-api/blob/master/src/lib/telegram.ts#L28). Quick question though, why telegraf 3 and not v4?

jsjoeio commented 3 years ago

Awesome!

Also saw that no pooling when in dev environment

Yeah, not familiar with that or not using it in my env but hoping that you can get it working?

Quick question though, why telegraf 3 and not v4?

I'm not 100% sure. I think the main reason was the documentation for v3 was way better. Looking at v4 release notes, I can't see why it wouldn't work though. Feel free to try and let me know!

waptik commented 3 years ago

Yeah, not familiar with that or not using it in my env but hoping that you can get it working?

Yup, got the long pooling working in localhost just made a checker(if statements) for the server environment and use bot.launch() if in local environment.

I'm not 100% sure. I think the main reason was the documentation for v3 was way better. Looking at v4 release notes, I can't see why it wouldn't work though. Feel free to try and let me know!

I agree with you on the docs. Docs for v3 are way better than v4 as v4 looks more typeDoc than actual docs. Reason why i've started using grammY . It's pretty cool and comes with typescript by default.

jsjoeio commented 3 years ago

Yup, got the long pooling working in localhost just made a checker(if statements) for the server environment and use bot.launch() if in local environment.

Fantastic!!

I agree with you on the docs. Docs for v3 are way better than v4 as v4 looks more typeDoc than actual docs. Reason why i've started using grammY . It's pretty cool and comes with typescript by default.

Oh wow, yeah, that does look really nice. Maybe it was in beta when I started my project? Either way, APIs look fairly similar. Guess it could be worth switching over down the road.

Happy you got this working! Gonna close this issue for now. Thanks for the push to make this!