

Then, you need to click on “More” and select Add to Group:Īnd select the Telegram group you want to add the chatbot to: So, you can just go to your Telegram chatbot (mine is called “Pizza-DF-Bot”) and click on the Top Bar: Now we’ve created our Telegram group and we need to add our chatbot. Here, you need to select the members you want to add (probably some friends/colleagues of yours), give a name to the group (for example “Bot Test”) and click on Create:
#Translate bot for telegram install#
If you are on a desktop, just install Telegram, click on the Pen icon in the top-left corner and select New group: So the first step we need to do, is create our own Telegram group.


Let Telegram Bot respond to all messages in the group.Only reply if you mention the Telegram Chatbot.In this function, the bot will read the dictionary.csv file, randomly picking one word, then send the word and the audio file back to the user and wrap it in a function called send_word. Let’s create a function for our bot’s main task. from telegram.ext import Updater, CommandHandler import pandas as pd import logging logging.basicConfig(level=logging.DEBUG, format='%(levelname)s - %(message)s') logger = logging.getLogger() tLevel(logging.ERROR)

mp3 file.įirst, import the libraries and set the logging function (this is for debugging your bot if it encounters some errors). Every time the user sends /word command, we are going to take one random word from dictionary.csv, and send it with the corresponding. Great! The dataset is ready, let’s create the bot. mp3 files in the audio folder and dictionary.csv. python dataset.pyĪfter running the script, you will see now, we have. 704418931:AAEtcZ*************Ĭool! Run the script from the terminal (do not forget to create folder audio first in the same path as dataset.py). You can go to your bot by accessing this URL: your token should looks like this. Follow the steps until you get the username and token for your bot. Go to the BotFather, then create a new bot by sending the /newbot command. When we register our bot, we will get the token to access the Telegram API. If you want to make a bot in Telegram, you have to register your bot first before using it. json (for this tutorial, let’s name it creds.json) and you should have the environment variable GOOGLE_APPLICATION_CREDENTIALS points to your creds.json path. In the Before you begin section, follow the guideline until you finish setting the environment variable in step 5.Īfter this step, you should have a credential in the format of. Go to the Google Text-to-Speech API guidelines. Enable Google Text-to-Speech API and set a credential pip install requests beautifulsoup4 google-cloud-texttospeech pandas python-telegram-bot 2.
#Translate bot for telegram how to#
We are going to use Requests and BeautifulSoup to scrape the website, Google Text-to-Speech API to create the audio on how to pronounce the Hangeul, Pandas to help us manipulate the data, and python-telegram-bot to create the bot.
