A Kafka Connect source for Telegram
The Telegram connect plugin needs a bot to communicate with.
Currently you must use and create your own bot, e.g. the KafkaConnectBot using the BotFather
- Start Telegram app and Open the BotFather.
- Use the
/newbotcommand 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
nameof your bot is displ§ayed in contact details and elsewhere. - The
usernameis a short name, to be used in mentions and telegram.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.KafkaConnectBot. - The
tokenis a string along the lines of110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsawthat is required to authorize the bot and send requests to the Bot API.
- The
- (Optional) Set the picture of the bot, using the Logo
- Type
/setuserpicin theBotFatherfollowed by the name of the bot, e.g.@KafkaConnectBotand the logo.
- Type
- Enable adding the bot to a group
- Type
/setjoingroupsin theBotFatherfollowed by the name of the bot, e.g.@KafkaConnectBotand the logo andenablejoining.
- Type
- Create a new group, i.e.
Burglar-alerts - Add the bot to the group
- Select the
@KafkaConnectBotand chooseAdd to group, select theBurglar-alertsgroup. - Confirm to add the bot to the group.
- Select the
- Send the message
/testto the group; this should be sent to the bot as well, even in privacy mode
- The group chat id can be retrieved from the Telegram API, using the output fom the following command, replacing
XXtokenXXby the actual tokencurl https://api.telegram.org/botXXtokenXX/getUpdates- Note that
botmust always be present—it's justXXtokenXXthat you need to replace
- Note that
- In the JSON response, e.g
chat":{"id":-999991234,"title":"Burglar-alerts","type":"group"you can find the chat id, here -999991234
- Your bot should be able to send using a simple curl command:
curl -X POST -H "Content-Type: application/json" -d '{"chat_id":"-999991234", "text":"Hello world!"}' https://api.telegram.org/botXXtokenXX/sendMessage