R
RunPod6mo ago
raz5020

connecting a telegram bot to a serverless pod

Hey guys, would love ur assist on the following issue, i have a serverless function and i have an api endpoint from runpod, to which i can access using curl when providing an autorization in the http header, the problem is when using /setWebhook when creating a telegram bot i need to provide an endpoint and i can't pass on parameters in the http request, how should i approach this? i'd like to be able to send a message to a telegram bot that will trigger my serverless function that uses gpu
36 Replies
Marcus
Marcus6mo ago
Google how to build Telegram bots and then make an API call from your telegram bot code that you host on a VPS.
raz5020
raz5020OP6mo ago
is there a way to solve this without having a private server running at all time? if somehow i could expose an api endpoint that doesn't need authonication that would be ideal
Marcus
Marcus6mo ago
You can use AWS Lambda or RunPod CPU serverless You can't use a RunPod serverless endpoint without auth
raz5020
raz5020OP6mo ago
with its sole purpose of adding the authorization to the api call? is that what everyone who connects their gpu instance to a telegram bot does?
Marcus
Marcus6mo ago
Why would you want to do that? Peoplc can abuse it and rack up your RunPod account, its a very bad idea
raz5020
raz5020OP6mo ago
yea i guess im just setting up an initial POC, was going to worry about authorization later, allowing people to create users etc.. runpod cpu serverless would still need to be authorized no? its the same problem
nerdylive
nerdylive6mo ago
Yes If you use /run on serverless itll need your runpod API key like the default gpu serverless but for pods its more customizable
raz5020
raz5020OP6mo ago
@nerdylive is there a way to both not have a running server at all time and to be able to forward the request without authenticating?
nerdylive
nerdylive6mo ago
Im not sure how telegram bot works
raz5020
raz5020OP6mo ago
One thing that might help is if I can transfer the autorization to run pod in the url, maybe as a query parameter? Not sure if that is possible Telegram allows u to connect a message to a post request to a url, but u can't authenticate using an http header authorization parameter
nerdylive
nerdylive6mo ago
sure as a body, unless you're using pods you can pass it as query Hm no then, serverless needs auth header
raz5020
raz5020OP6mo ago
Hmm, that's strange since in the history of the chats in this discord people have created telegram bots that communicated with a serverless function, so I think I'm missing something
nerdylive
nerdylive6mo ago
Where?
Marcus
Marcus6mo ago
Its very easy to do it but you can't just magically run a telegram bot without infrastructure to host it.
nerdylive
nerdylive6mo ago
I think so yeah you need a proxy in the middle to communicate to runpod serverless
raz5020
raz5020OP6mo ago
I have just searched phrases like "telegram Bot" and seen people talking about theirs connecting to a serverless function
Marcus
Marcus6mo ago
Exactly and it also needs to process the telegram messages.
nerdylive
nerdylive6mo ago
you need an server to receive the message and act accordingly ( send request to runpod serverless )
Marcus
Marcus6mo ago
Use AWS Lambda, you don't need an API key
raz5020
raz5020OP6mo ago
And then the lambda just adds the api key and calls run pod?
Marcus
Marcus6mo ago
Lambda is pretty cheap and can receive and send telegram messages and call RunPod Serverless API with the API key
nerdylive
nerdylive6mo ago
You can store RP \api key somewhere within it yeah
raz5020
raz5020OP6mo ago
I guess that will work, but I was thinking if aws lambda can expose a public api then so can the runpod 🥲
Marcus
Marcus6mo ago
You can use AWS secrets manager for storing the API key
raz5020
raz5020OP6mo ago
I guess I'll do that then, thank u guys!
Marcus
Marcus6mo ago
That is not how RunPod serverless works
nerdylive
nerdylive6mo ago
Hmm what if runpod serverless allows that would that be ok
Marcus
Marcus6mo ago
This kind of thing makes me concerned that people are going to come crying to RunPod when their balance is depleted. RunPod serverless required authentication for a very good reason.
raz5020
raz5020OP6mo ago
I mean if aws allows that I don't really see the difference
Marcus
Marcus6mo ago
AWS also lets you expose any endpoint you want, not just /run, /runsync etc So you are comparing apples with lemons
nerdylive
nerdylive6mo ago
yeah sohuld be only for cpu hahah
raz5020
raz5020OP6mo ago
Aws lambda specifically does allow u to expose the public api and that's the same as runpod cpu in my eyes Yea maybe only for cpu
Marcus
Marcus6mo ago
Incorrect, the design and architecture are completely different.
raz5020
raz5020OP6mo ago
For sure behind the scenes, for they are intended for similar purposes product wise
nerdylive
nerdylive6mo ago
Feel free to write it on #🧐|feedback raz
yhlong00000
yhlong000006mo ago
Typically, you’d combine Lambda with API Gateway, which handles authentication or makes it open. Lambda itself often doesn’t need authentication because it’s mainly integrated with other AWS services like API Gateway, S3, and event processing. It also uses IAM roles to control access to other resource.
Want results from more Discord servers?
Add your server