6 ms·
Building a server-less Telegram bot over a weekend
- snaky 9y agoThis is especially confusing to use 'server-less' buzzword (meaning 'on the bunch of servers in The Cloud') wrt messengers and p2p things where things could be actually serverless.
- fenwick67 9y agoThe word "server" is totally meaningless in 2017... it can mean "program that interfaces with other programs" (like X server), it can mean "computer on a rack", "dedicated VPS", "program listening on an external TCP port"... we really need better terminology.
- mosessoh 9y agoI totally agree with this btw. The benefits / challenges that come with choosing this setup aren't really captured by the term "serverless" at all.
- snaky 9y agoIt's not that total actually. Of course we cannot always clearly and formally distinguish bare metal server from virtual server, and both of them from just a server program coexisting on workstation or laptop with other programs. But when I say 'a bunch of server racks', you know what I mean, don't you? BTW AFAIK a server in X Window System is called 'server' because it does 'listen', so formally it is, and so it wasn't a question back then.
- zitterbewegung 9y agoWe should replace the term with something like managed function or server / cloud function.
- banku_brougham 9y agoA question about ngrok: If ngrok is exposing a local server to the internet, does it also open an attack surface to vulnerabilities on my machine?
- kevin_b_er 9y agoYes. If Flask has any insecurities, you've just exposed it to the internet and any rights Flask has (likely your local user account), plus any local privilege escalation.
- mosessoh 9y agoI definitely wouldn't start sharing the URL around. But this isn't the end goal. The end goal is to host your server code on AWS Lambda and use the endpoint that provides. ngrok's exposing of a local server just makes it easier for you to develop more quickly. Otherwise, you'd have to deploy any changes to Lambda, hit your bot's endpoint, and then check the cloud logs for any bugs. I was doing this for awhile - it really slows down development. I'm writing another post on AWS Lambda and Zappa next - hope that's useful!
- patrickdavey 9y agoFantastic write up. I'm really looking forward to part 2 now! I recently used the telegram bot API for a raspberry pi motion detection setup. If I'm away from the house and there's movement, I get a photo uploaded into the chatroom. Super simple to get started with the API :)
- mosessoh 9y agothat's a very cool use case. i like thinking about these cases where an app might be over-featured :) you're welcome, I'm glad you found it useful!
- sixhobbits 9y agoNice post! Especially adding ngrok for speeding up development. I've written a couple of similar tutorials about Telegram bots, so shameless self plug: Building a Telegram Bot with Python [0] is a beginner-focused basic ToDo bot in a few parts Building a Serverless Chatbot with AWS, Zappa, Telegram, and api.ai [1] is a slightly more advanced one that shows how to integrate an off-the-shelf "AI" into the bot. Some of the code snippets looked pretty similar. Would love to hear if you saw my posts before writing this one. In response to people being confused by "serverless" -- I think GCE + AWS have successfully established the term to mean "running code in the cloud without having to worry about maintaining updates etc". I've never heard this term used in regards to a P2P system of bots. [0] https://www.codementor.io/garethdwyer/building-a-telegram-bot-using-python-part-1-goi5fncay https://www.codementor.io/garethdwyer/building-a-telegram-bo... [1] http://www.developintelligence.com/blog/2017/08/building-serverless-chatbot-aws-zappa-telegram-api-ai/ http://www.developintelligence.com/blog/2017/08/building-ser...
- mosessoh 9y agoI hadn’t! These are exactly what I had in mind - ngrok really sped up development, but the production stack and tools were the same as yours.