Telegram Bot and Custom client - telegram

I would like know if I can use Bot (taken from the Telegram Bot store) in a custom telegram client
I think so but I didn't found documentation about it.

Yes, of course, you can use any bot from any client that support Telegram protocol.

Related

telegram importContacts method not working

Could you please let me know why some of the telegram methods are not working?
for example "https://api.telegram.org/bot{token}/sendMessage" works fine and it never returns 404 error whereas https://api.telegram.org/bot{token}/importContacts and many others are not working at all.
You can find the list of all methods here and you can try them
https://core.telegram.org/methods
Thanks for responding
The Telegram platform offers two separate APIs.
Telegram Bot API which is documented at Telegram bot docs and relies on the HTTPS protocol. api.telegram.org is the entry point for this API.
Telegram Client API which is documented at Telegram core documentation and relies on the MTProto protocol.
The Telegram bot protocol is significantly more limited than the Telegram Core API, if you're looking to create a client to use your own account, you need to use the MTProto API.

How to view a telegram account by chat id?

I'm wondering if there is any possibility to view or message a non-contact person who has no username, with his/her chat id?
I only got a chat id.
You can use sendMessage method and pass chat_id as chat_id you have it and then send message to that user.
https://api.telegram.org/bot<YOUR_API_TOKEN>/sendMessage?chat_id=<chat id you have>&text=Hello world
If your bot have received messages from that user, you can use inline mention, and your user account can view his profile/PM him.
But unfortunately, bot account can't initiate chat for now :(
I do not know exactly what programming language you use but I think you can use some Telegram client library like Telethon
Telethon is Telegram client implementation in Python 3 which uses the latest available API of Telegram
If you use PHP, use MadelineProto instead.

What is the web request to send a message to my telegram bot?

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.

Automate posting messages to a Telegram channel via API

I am new to the Telegram API.
I would like to automate posting messages to my public telegram channel.
I read a few posts that with bots I can achieve this, but I am not sure if that's the best way and whether the API has an option to directly post to a channel.
I would like to get some start points on how to achieve this?
Which API should I use?
Whether I need a dev account or bot, etc?
You can use bots to send message to channels. But there is some limitation, like size of files.
create your bot, by sending message to #botfather
add the bot to your channel. stackoverflow
write a code to send message to your channel. bot api
After 1 year of working with telegram API, I wanted to update this answer for best possible ways to interact with telegram API.
For posting to channels, both telegram API and telegram bot API can post to channels.
I worked directly with both the APIs, but I found the following clients for telegram API and bot API to be faster and easier to interact with telegram.
Telegram API client:
https://github.com/LonamiWebs/Telethon
Telegram bot API:
https://github.com/python-telegram-bot/python-telegram-bot
It is impossible to read messages from Telegram channels using Telegram Bot API.
In order to be able to scrape messages from Telegram channels that you do not own, you need to develop you own Telegram client that is capable of:
Joining your desired channels by links
Forwarding messages, arriving to the channels your client is subscribed to, to your own Telegram channel
In order to develop your own Telegram client, you need to use some implementation of MTProto.
You can find a lot of implementations of MTProto on https://github.com using mtproto keyword.
A few examples of well-documented implementations:
In PHP: https://github.com/danog/MadelineProto
In Python: http://github.com/LonamiWebs/Telethon
But probably it would be an overkill to develop your own solution to this problem if the only thing you want is to have several redirections from existing Telegram channels to your own channel.
There are applications that provide such a service.
For example, there is MultiFeed Bot from telespace.me team:
https://telespace.me/apps/multifeed_bot
It allows you to setup forwarding of messages within Telegram as well as redirections to external services.

Can I use telegram api for my commercial app?

I'm more confused how to use Telegram MTProto API, but still I want to know the truth, Can I use telegram API for mobile number verification or sending messages in my own commercial app(not related to telegram)?
Can I use telegram API for mobile number verification
I don't think so.
or sending messages in my own commercial app(not related to telegram)?
You can use Telegram Bot APIs (https://core.telegram.org/bots/api). In this case (bot service), Telegram is very open and explicitely declared to me the freedom to use Bot apps for commercial/profit purposes: see my twitter page: http://www.twitter.com/solyarisoftware !
You can also use channels for commercial messages.
your Question is Unclear
Actually, you can Create your own commercial app for yourself
to do that, you should use Telegram API, so your app is related to telegram
But it's completely not related to the telegram application you use now
for example mobile apps or windows application
Now, you write your own commercial app
you should Authenticate your phoneNumber with your own app
So, You should use telegram API for mobile number verification
Good Luck !!!

Resources