I created chat bot and wrote a simple java application to send https request to
https://api.telegram.org/bot(botcredentials)/sendMessage?chat_id={chatid}&text="+telegramMessage
and it works for my telegram account, I tried to connect some more users to this bot and they can't see any updates (I mean I receive message for myself, but no one else could see them).
Perhaps I should make my bot ?public?
Or every user has its own chat_id with my bot?
Every chat with your bot has its own id. You can get the chat id of your bot with another user as soon as someone interacts with your bot through the Update object received either through getUpdates method or a Webhook.
Related
I develop a telegram bot in Java. One of the wanted function in my bot I want to see is the opportunity to invite users by other ones. I tried to make it works next way: the user sends forwarded message from the user he wants to invite to bot, program extract chat id of invited user by:
update.getMessage().getForwardFrom().getId();
and then send a message for invited user. But Telegram doesn't allow to start a conversation with a user before he tapped to "/start" button, and after user has done this, described function stops having any sense.
So what I'm looking is some way to send message to user from regular(not bot) account by using, for example, json request such as we can use in bot api. Is there some way to do it?
Yes, there is the MTProto Protocol which allows you to build a custom Telegram application, There are several libraries that implemented it.
It basically lets you program a user-bot, which gets triggered by particular commands/events and responds correspondingly.
A java library I found is telegram-s/telegram-mt but it doesn't seem to be active at all.
I suggest you implement it easily in Python with libraries such as Pyrogram.
I have a web application.
I'm sending some photo to telegram bot using:
https://api.telegram.org/<token>/sendPhoto.
By executing this command from my web app, bot receiving image.
How can I make bot react on this incoming events?
Unfortunately, you can only use query strings with the availed methods to send messages/photos from a bot to a specified user i.e
https://api.telegram.org/bot<token>/sendMessage?chat_id=<id>&text=<string>
Hitting the endpoint below opens your bot in the telegram web app which is not helpful in your situation
https://telegram.me/<botNname>?start
Bottom line is that you cannot send updates to a bot using a URL,
In my project, i have implemented Twilio for one to one chat, user can initiate chat from mobile app and operator will respond from web application.
So if chat is going on between user and operator and suddenly user close the chat then how operator will come to know that user has left the chat and vise-versa?
I am looking to send a facebook message from my application server without
the need to prompt the user for input each time.
I have been looking over the facebook chat API but it only works with facebook UI
which means that the user must be prompted every time I want to use the chat.
Is there a workaround or am I missing something?
I am using JAVA on my server.
I am writing a chat application on app engine using xmpp. My idea is to allow users to chat to one another. I can get messages to send to a google talk account, by taking the logged in user and removing the #gmail.com part of the address and replacing it with #appid.appspotchat.com )so for example if the logged in user is bob#gmail.com, the jid used to send from will be bob#appid.appspotchat.com). You can then send messages to an google talk account, e.g. jeff#gmail.com.
My problem is in receiving the messages back again. The developer pages show how the app itself can receive messages to the appid#appspot.com jid, but how do you get it to receive messages to the appid.appspot.com jid, and then present these messages tp the logged in user? The overall idea is when a user logs in, I will retrieve thri contact list, get the presence of their contacts (replacing gmail.com with appid.appspotchat.com) then present the available contacts to the user.
If this is not possible, is there a way to let the logged in user chat to other users in a different way? Ive briefly looked at the channel api but i don't think this is suitable?
You could use the Channel API to send a message down to a client when your server gets a message intended for that user. There's no facility to direct a XMPP message directly to a user on your own page; the XMPP API is used to send messages to users signed in to XMPP clients (such as Gmail, Pidgin, etc).
You can't use anything#your_app_id.appspot.com. Instead you must use anything#your_app_id.appspotchat.com as described in XMPP Addresses.