Serverless Telegram Bots Integration/Support #960
Replies: 3 comments 2 replies
-
As a starting point, you should be looking into webhooks: https://docs.rs/teloxide/0.12.2/teloxide/update_listeners/webhooks/index.html |
Beta Was this translation helpful? Give feedback.
-
I don't think that's true, graceful shutdown also makes sure that all the updates are actually processed, which you do want. Teloxide is not designed with serverless architecture in mind, so you'll have to reinvent something. I would suggest doing one of two things:
The second option can be tricky and cumbersome, so I'd probably go with the first one. In which case you just parse the update (I had the feeling you got this already?) and then insert |
Beta Was this translation helpful? Give feedback.
-
Sorry for reviving this but I am actually trying to create a teloxide bot that runs on AWS Lambda. I know it has been tried before but everything seems to work with a few caveats.
Now, everything separately is not really a problem, but together isn't really too usable. I have been thinking that it should be possible to (as also described earlier in here) have a way to handle a lambda event where the json is parsed and passed to a dispatcher that does not modify, poll or behave in any special case, just handling the messages that are being sent to the function. For me, this is very appealing as Rust + Lambda means that the bot does not have any kind of cold start and in my case I don't need to to be long lived to have some kind of cache or anything. It is just a matter of spinning up the function, responding and shutting down (maybe saving something to the database but it is optional). I have tried with a custom listener that does not call the What are your thoughts on creating a new feature Thanks! |
Beta Was this translation helpful? Give feedback.
-
Rust Teloxide Framework Integration with AWS Lambda for Serverless Telegram Bots
Hello Rustaceans and Teloxide enthusiasts! 🦀
I'm currently working on an exciting project where I aim to deploy a Telegram bot using the Teloxide framework within a serverless environment, specifically AWS Lambda Functions. The idea is to leverage the on-demand execution capabilities of AWS Lambda, where each incoming message from the Telegram API triggers a specific Lambda function via webhook endpoints.
Current Progress:
Tools & Frameworks:
The Challenge:
While I've made significant progress, I'm currently facing a challenge in integrating Teloxide, especially with its Dispatcher Tree (DPTree). My goal is to programmatically pass the incoming update JSON into Teloxide's DPTree. This would allow the DPTree to act as a router, checking the state and other filters, and then directing the Update to the appropriate function. After processing the update, the function would update the State/context, send a reply, and terminate the instance.
Given the nature of this setup, there's no need for a graceful shutdown since the webhook will remain set up. An alternative approach I considered was using a Docker image with an NGINX frontend to handle SSL and redirect internally to the Teloxide AXUM server. However, I believe the initial serverless approach would be more cloud-native and optimized.
Seeking Community Input:
I'm reaching out to the community, especially those familiar with Teloxide and serverless architectures, for recommendations and brainstorming:
I genuinely believe that with the combined knowledge and expertise of this community, we can come up with a robust and efficient solution. Looking forward to your insights and suggestions! And I would love, once I get this product working, to scaffold it and in the close future release a community-available serverless integration for Teloxide 😄.
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions