Repository navigation
Deploying bot to Netlify/Vercel #1204
Replies: 2 comments
|
Hi! You should try this https://www.marclittlemore.com/serverless-telegram-chatbot-vercel, but I do not recommend that you post your hot on vercel/netlify, etc . You'd better use something like Render (Render.com ), he has a free tariff, which is more than enough in most cases. |
|
vercel works fine for this tbh, i run a webhook bot on it. the shape is different from polling though, so here is the mental model. you dont run a long living process. you make one api route, say api/webhook, that takes the post from telegram and hands it to bot processupdate. then you point telegram at it once with setwebhook to https://yourapp.vercel.app/api/webhook. polling off, token in an env var, never in code. two things that bit me and the guide link above doesnt mention. one, set a secret token when you call setwebhook, then check the x telegram bot api secret token header on every request, otherwise anyone can post fake updates to your endpoint. two, if you ever test locally with polling after the webhook is set, you get nothing until you delete the webhook, telegram wont deliver to both. getwebhookinfo is the quick way to check what is actually set and how many updates are stuck. on netlify its the same idea, a function that receives the update and calls processupdate. the only gotcha on serverless is keep the handler fast, telegram wants a 200 back quickly, so do heavy work after you respond or keep it light. the render suggestion in the other comment is valid too btw, if you want a normal always on server. but if you specifically want vercel or netlify, webhook route is the way, polling cant work there since theres no long running process. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I was creating a bot locally, so it was starting with
{ polling: true }. Then when it was time to deploy I understood that it's not a usual deployment. It should be a serverless one. And atm I'm a bit lost. I see there are examples for different platforms. But neither Vercel not Netlify are there. And these are the ones that I'm most familiar with.Is there a guide using
node-telegram-bot-apito deploy a bot with webhooks to one of these platforms?But actually any serverless deployment guide using this package will do.
All reactions