I want to display information from a getChat method in a WebApp, and then update chat title (via setChatTitle Bot API method). I take it I cannot send the setChatTitle request directly from a WebApp as that would require me to expose Bot Token in a client app. And calling sendData function provided to WebApp initData closes the WebApp. So is there a way to call Bot API methods from the Web App, directly or through requests to a bot?
If possible, I would prefer the solution with the bot hosted on Telegram servers.
It's not possible to call Bot API directly from the web app. You should have your own server running as a layer between your web app and telegram bot API.
Related
So i'm making an app using React JS, Cordova, node backend and a mongo database. I want to integrate firebase cloud messaging (FCM) into my platform. I'm quite new to firebase, and developing in general, and i'm not quite sure where to initialise firebase. I currently have it integrated into the front-end and it's requesting permission to receive notifications, generating tokens, and receiving messages from the firebase console. However i'm not entirely sure where to go from here. Do I add it to my backend as-well?
If you can receive messages in your client app, your front-end work is done for the moment.
But to send messages programmatically, you will need to write back-end code indeed. That's because sending messages through FCM requires that you specify the FCM server key to the API, and as its name implies that key should only be used in a trusted environment, such as your development machine, a server you control, or Cloud Functions.
For more on this, have a look at:
The architectural overview of FCM
The documentation on your server and FCM
My answer to How to send one to one message using Firebase Messaging
You have to get the FCM token from the frontend (or, client app).
After getting the token, just send it to your backend server using a POST method.
Then, store the token in whatever database you're using in your backend. It can be MongoDB, PostgreSQL, etc.
I am using Mesibo SDKs on my Android app for chat and so far all my requirements are fulfilled. All of my Mesibo APIs and token information are stored on server side only. The android app fetches user token from the backend server.
Recently, my app started working unexpectedly such as chat messages not sent/received, user account not created and add group not working at Mesibo side. The backend APIs are all working fine. Upon calling one of the Mesibo API from PostMan, I got this response.
Request:
{'token':$appToken,
'op':'groupadd',
'name':$roomName,
'flag':0,
'expiry':$expiry,
'expiryext'"$expiry,
'active':1
}
Response:
{"op":"groupadd","result":false,"error":"TOKENBREACH"}
This error is new to me and I do not know how to resolve this. Any help would be highly appreciated.
TOKENBREACH indicates that backend API and app token are used from multiple IP addresses which jeopardizes your app security. You are likely to be using an app token from the client-side and hence breach has been flagged.
Read here https://mesibo.com/documentation/api/backend-api/
I need to handle social activity events in my web app application developed using Vue JS framework and Firebase.
I want to show to the user “Facebook like” notifications when some activity happen in the application, for example:
“John liked your post”.
Is Firebase Cloud Messaging useful for this scenario? Or do I have to develop some custom solution from scratch?
If Firebase Cloud Messaging do the job, is it possible to send messages directly from user web client?
You should not try to send messages directly from the web client. FCM is intended to be used via a secure backend where your code runs to send messages. The reason a backend is needed is to prevent your private server key from being exposed to the world, which can cause security issues in your app.
You will have to arrange on your backend to determine when events occur that should generate messages, and use the Firebase Admin SDK to send those message, or work with the REST API directly.
I tried this:
https://api.telegram.org/botXXtokenxx/sendMessage?chat_id=chat_id&text=text
But this is to send a message from the bot.
But what I need to do to send to the bot? (not from the bot)
You can either use a regular Telegram client (Telegram, Telegram X, Telegram Desktop, etc) to do it manually, or if you need an API (for whatever reason)...
You need the client API.
https://core.telegram.org/#getting-started
Once you have an API key for the client API and all that, you can send messages as explained here.
https://core.telegram.org/method/messages.sendMessage
Note that a human should be triggering this, as Telegram encourages (may be against ToS?) using a bot API for programatic access rather than the client API.
i've set up a working telegram bot that get's triggered on a /mission command. I want to use the bot within groups to enable a fast response feedback system for my organization. the flow is like follows:
1) a API client (no bot, just pure api) sends a message to a group, triggering the bot using /mission .
2) the bot responds to the command and the feedback process starts..
As a normal user, I can trigger the bot whereas the api user won't even reach my bot using webhooks.
Is there any known limitation on what APIs can trigger?
thanks!
Telegram MTProto API has same limits and same benefits of a normal Telegram user. So, you can trigger all bots you want, but be careful with FLOOD_WAIT error: an user sends too much messages in one second or in one minute, Telegram blocks the user for x seconds.
If you don't want to setup tg-cli, and other stuff to run MTProto client on your server and control it, I suggest you to use PWRTelegram APIs, so logging in as user.