Member-only story
How To Send Excel Files With Python Telegram Bot (Or Any Other Binary File)
3 min readMay 18, 2022
I spent way more time googling for the solution and trying to figure this out than I would have liked, so hopefully this saves you the frustration of doing so if you happen to be attempting the same thing.
Installing The Relevant Library
pip install python-telegram-bot
Replace pip
with pip3
if you’re using MacOS
Some Basic Python Telegram Bot Code
from telegram.ext import *TOKEN = "TELEGRAM BOT TOKEN FROM BOTFATHER"def route(update, context):
text = update.message.text
update.message.reply_text(text)updater = Updater(TOKEN, use_context=True)
updater.dispatcher.add_handler(MessageHandler(Filters.text, route))
updater.start_polling()print()
print("Your telegram bot is running!")
print()updater.idle()
When we run this chunk of code, we get this output:
And when we send stuff to our bot, our bot replies with whatever we send it (the update.message.reply_text
method in the route
function).