Connecting Telegram chatbot to API.chat consists of two steps.
1. Create a Telegram chatbot and obtain a token
There are Telegram bots and there are API.chat bots. Telegram bot is third-party applications that run inside Telegram, and API.chat bot is a scenario that moves it. For simplicity, we will name Telegram bots (and any other messengers bots) as Channels everywhere outside this section. Please don't mistake this with the actual Telegram channel.
We support a lot of channels, but for a quick start let's start with the most advanced and easiest to use - Telegram.
To create a Telegram bot use @BotFather bot. It will help you create new bots and change settings for existing ones.
- Use the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authorization token for your new bot.
- The name of your bot is displayed in contact details and elsewhere.
- The Username is a short name, to be used in mentions and t.me links. Usernames are 5-32 characters long and are case insensitive, but may only include Latin characters, numbers, and underscores. Your bot's username must end in 'bot', e.g. 'tetris_bot' or 'TetrisBot'.
- The token is a string like 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw which is required to send requests to the Bot API. You will use this token later to connect the created channel to API.chat chatbot.
2. Provide the token to the Telegram Channel API POST method
Use channels APIs to connect Telegram channel to API.chat chatbot.
HTTP Request must be as follow
If the token applied successfully you will receive 201 Created answers with an added Telegram chatbot name
If the token already assigned to another chatbot under the current subscription, it will be removed and set for the current chatbot. If token assigned to a chatbot in another subscription 409 Conflict response will be returned.
3. Removing Telegram token
If you need to connect Telegram chatbot to another API.chat bot use DELETE request on channels endpoint.
Successful delete will return you 200 OK