My First Telegram Bot
Tags: machinelearning, pdftoimage, pdfconverter, telegrambot
Published: 2020-12-31 14:24:49

---
title: My First Telegram Bot
published: true
date: 2020-10-05 01:18:48 UTC
tags: machinelearning,pdftoimage,pdfconverter,telegrambot
canonical_url: https://medium.com/@bervianto.leo/my-first-telegram-bot-431514316f36
---

#### Convert PDF to JPEGs

![](https://cdn-images-1.medium.com/max/1024/0*jciVx4RZ4rLLmQDn)<figcaption>Photo by <a href="https://unsplash.com/@williamtm?utm_source=medium&amp;utm_medium=referral">William Hook</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption>

### Background

I have though to build an application that automated my task. I usually do screen capture use print page as pdf after that convert it into images. I use print page because need the full pages. I know, why I’m not decided to find/create extension for that browser. I want this because I want not too specific browser. My solution should work for another task too. It’s good when I can cut some tasks.

My previous task is

1. Print as PDF
2. Open the PDF use GIMP
3. Export as JPEG

The task will more complicated when I need convert much PDF. :( Also if I ended to use CLI tools that can convert JPEG also not really bring impact for me. So I decide to create a bot, you can just upload and receive the result. For me, that is easy task. :D

### Finding the Libraries

The first time, I decide try to use NodeJS + Typescript to do this. I want to use this because I more familiar than Python. Unfortunatelly, I can’t find good libraries that meet my requirement to convert PDF to images. Maybe I’m not spend much time to find it, so I decide to change my plan. I use Python, I see the libraries very comfort to me.

### The problems

![](https://cdn-images-1.medium.com/max/1024/0*YtBwt2qOTOBlP9z9)<figcaption>Photo by <a href="https://unsplash.com/@punttim?utm_source=medium&amp;utm_medium=referral">Tim Gouw</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption>

Yeah, I have code and debug about +6 hours. I’m not familiar with Python also my big problem is **Documentation**. Why? I think, I wrong to decide the telegram libraries that I will be used. I use a library that not bring me enough documentation, how to process the file, how to process the upload file, my core code not explained at the docs! I need to find out from issues, commit, and the source code itself. It bring me some frustration situation.

### The Result

[My first telegram bot, use to help me convert pdf to images automatically, I need this. 😅 Spend much times, because long time not use python and very limited documentation about library that I want to be used, so I spend time to read the source code too. So bad I thing. 🙄 But, I'm happy, finally have own tool to convert it automatically, just upload. Not like my previous step, need manually convert it. 🤣 Btw, why I don't use another free tools. I can't know how safe the privacy. So, I use my own. 😃](https://www.instagram.com/p/CF7UbgqHPPY/)

You can see my result in my instagram. :D Actually this is really spend much time. The first taught, I will do it in small times, but no, so sad for me.

[bervProject/my-telegram-bot](https://github.com/bervProject/my-telegram-bot)

I also want to share my Github Link. Feel free bring me some suggestion to update it! I’m so sorry not bring full details how technically I create the bot. You can ask me for the details if you need. :)

![](https://cdn-images-1.medium.com/max/1024/0*R5ec3HvgmLJeg5h8)<figcaption>Photo by <a href="https://unsplash.com/@aussiep?utm_source=medium&amp;utm_medium=referral">Austin Park</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption>

### Next step

For the next step or my next plan, I want to add feature to have image recognition. Such as for classification. I also think to have text classification about News Categories, but it is about HOAX! So my idea, you can only bring me the link, I will give you the classification, is it the news HOAX or not. I am really interested with the Machine Learning or AI for now. How wonderful. Thank you so much for read my little article.