# Telegram bot to code and run programs in Julia

**URL:** <https://discourse.julialang.org/t/telegram-bot-to-code-and-run-programs-in-julia/55434>\
**Category:** Tooling\
**Tags:** community, teaching\
**Created:** [February 17, 2021, 2:19am UTC](https://discourse.julialang.org/t/telegram-bot-to-code-and-run-programs-in-julia/55434 "2021-02-17T02:19:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ata0k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ata0k/32/29440_2.png) [@Ata0k](https://discourse.julialang.org/u/Ata0k)\
**Post date:** [February 17, 2021, 2:19am UTC](https://discourse.julialang.org/t/telegram-bot-to-code-and-run-programs-in-julia/55434/1 "2021-02-17T02:19:15Z")

</div>

I would like to share with you a simple program to generate Telegram-bot for code and run the programs.

First, you need to generate a Telegram bot via the @BotFather bot ( send the message /newbot to @BotFather and follow the instructions). Then you need to obtain the token of your new bot. For this, in the @BotFather bot, you send the message /token and follow the instructions.

Once you have your bot, a simple way to code inside telegram is to run the following program (based on Telegram Package):

using Telegram, Telegram.API

tg = TelegramClient(“Your\_Token”)

run\_bot() do msg  
try  
x = eval(Meta.parse(msg.message.text))

```
    if typeof(x) == Plots.Plot{Plots.GRBackend}
        savefig("test.png")
        sendPhoto(photo = open("test.png", "r"), chat_id = msg.message.chat.id)
    else
        sendMessage(text = "$x", chat_id = msg.message.chat.id)
    end
catch
    
end

```

end

Here the plot works only with Plots package, but you can modify it to make it works width other packages.

Then, you need just open a conversation with the bot. If you send a message that is a Julia code, it will evaluate it on your computer and return the result as a message in telegram.

It is not a perfect program but is really simple and useful (for example for teaching and advising).

Note: If you want to make a group with your new bot such that everybody can make a contribution, you need to give the bot admin privileges.
