Hi there!
tl;dr: Some models (deep learning) take a long time to finish. Even some data preparation scripts. We can be notified that the process ended by Telegram sending messages from R.
Get notify by Telegram bot
This section is entirely based on the documentation of telegram.bot package, by Ernest Benedito. Please visit the site to get used of the full capabilities of this package.
The idea of getting notify by Telegram is we can see the notification either on our cellphone or in the web version.
Step 1: Create a bot
Find @BotFather
on telegram. Send the message: \start
. Then \newbot
. And follow the instructions.
Save the bot token and never share publicly.
Step 2: Set-up the bot
After your bot is created. You have to send the message \start
. And the bot is finally configurated!
Step 3: Use it with R
Put the bot token in the .Renviron
:
1 |
|
This should look something like this:
Now restart R.
1 |
|
1 |
|
Time to use in the R workflow! We will send a test message and a plot:
Note 1: chat_id
=message.chat.id
.Note 2: R_TELEGRAM_BOT_{the name of your bot}
1 |
|
The results on telegram web:
Note: I also tested: telegram package and it works. However the telegram.bot seems more complete due to the bot options.
Check the full list of options to interact with the bot 🤖.
Get notify by sound Another way of getting notified is by producing a sound: 🔔 beep!
1 |
|
Thanks for reading 🚀
Blog | 📗 Data Science Live Book |
Related