Telegram bot
As a final step, the Telegram chatbot using the trained model was implemented. To be able to run it, you need to install the python-telegram-bot
extra package into your virtual environment using pip install
.
Another step you need to take to start the bot is to obtain the API token by registering the new bot. The complete process is described in the documentation, https://core.telegram.org/bots#6-botfather. The resulting token is a string of the form 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
.
The bot requires this string to be placed in a configuration file in ~/.config/rl_Chapter14_bot.ini
, and the structure of this file is shown in the Telegram bot source code as follows. The logic of the bot is not very different from the other two tools used to experiment with the model: it receives the phrase from the user and replies with the sequence generated by the decoder.
#!/usr/bin/env python3
# This module requires python-telegram-bot
import os
import sys
import...