Create your own Telegram bot with Django on Heroku – Part 11 – Apologies for the long pause! ?

Header Image showing Django, Telegram, Heroku logos
This entry is part 11 of 11 in the series Create your own Telegram bot with Django on Heroku

Django_Pony

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

The previous part of this series, in which we created a WebHook for our Telegram – bot, was written on December 5th, 2018. This is more than 20 months now without any update to this series – embarrassing ?. My sincere apologies for this! I had some changes in my job and was quite busy catching up.

This time, I will provide you with only a very (!) short update instead of a real article:
Since I recovered from this changed situation in the meantime, I’m planning to pick up this article series again. Since a lot of time has passed and most certainly even the most devoted readers forgot about the progress in previous parts in the meantime, I decided to add something new: A Git Repository which contains all changes so far, structured by tags that allow finding the proper entry point to the code, depending on which article you are reading, currently.

I hope to make the (re-)entry to the series a bit more easy and attractive by this.
I will also add results of future articles to that repository since I had a hard time why something so obvious came to my mind only so late in the article series …

Please find the Repository on GitHub.

Outlook for the next part of the series

So far, our bot is just capable to receive data. In the next article of this series, we will add a bit more functionality to the bot by adding a reply feature to it. I’m not 100% sure what this will be exactly yet, but I will try to come up with something interesting, educational and useful ?
Also, since this is about to become a bot to store your cash spendings, we will add pattern recognition logic to enable the bot to sum and track your spendings.
Also, when we saw that we ended up with a doubled record in our User table, we realized that the current string representation of the records for that table is not really helpful, displaying the same lines containing “Marc Richter” twice. Having displayed the same name twice made it hard to identify the correct record for deletion. We will change that as well and by that see how to make changes like this to a database that has already records stored to it, using Django’s workflows.

? Enjoy coding! ❤

Create your own Telegram bot with Django on Heroku – Part 10 – Creating a view for your bot’s webhook

Header Image showing Django, Telegram, Heroku logos
This entry is part 10 of 11 in the series Create your own Telegram bot with Django on Heroku

Django_Pony

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

In the previous part of this series, we created another database model named Message to hold the message-data from our Telegram – bot. I also explained the process of defining a SQL schema using a Django model, what to consider during that phase and how to bring the Django’s model field reference docs to a good use during that process. Last but not least, we learned what a HerokuOne-Off Dyno” is and how it can be used to execute administrative tasks on our production site like applying outstanding migrations to a database.

This time, I will provide you with the last piece of the puzzle to make your bot available to the world. You will learn how to write and wire the Python code to actually use all that we have prepared so far. At the end of this part, your bot will be able to receive and store each message sent to it by registered users. And since it’s already more than a month since I published the previous article in this series, let’s not waste any more time and jump right in!

Continue reading “Create your own Telegram bot with Django on Heroku – Part 10 – Creating a view for your bot’s webhook”

Create your own Telegram bot with Django on Heroku – Part 9 – Creating a model for your messages

Header Image showing Django, Telegram, Heroku logos
This entry is part 9 of 11 in the series Create your own Telegram bot with Django on Heroku

Django_Pony

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

In the previous part of this series, I explained what a database is good for in general and Django in special. I also told about what relational database systems (RDBS) are supported by Django, what migrations and models are and how to create and apply them. Further, I introduced and explained what the Django Admin-Backend is and how to use it to create, alter or delete data in tables resulting from having applied the migrations to SQL databases from a model definition.

Today, we will create another database model to hold the message-data forwarded to our webhook by the Telegram – bot in the future. I will try my best to make this a play-along part which invites everyone to follow step by step in another console. Hopefully, it gives you an idea what thoughts and considerations are involved in writing a model for a real-world problem and how to involve Django’s documentation resources.
Continue reading “Create your own Telegram bot with Django on Heroku – Part 9 – Creating a model for your messages”

Create your own Telegram bot with Django on Heroku – Part 8 – Integrating the database

Header Image showing Django, Telegram, Heroku logos
This entry is part 8 of 11 in the series Create your own Telegram bot with Django on Heroku

Django_Pony

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

In the previous part of this series, we had a bit of a term definition to make it easier for beginners of Django to understand what I am talking about. Also, we created a Django – App called “bot” and created a URL routing for it to be available at (https://dry-tundra-61874.herokuapp.com)/bot/* (or whatever your URL looks like) and how to direct URLs to a view.

Originally, I planned to also show how to start using a database in Django to hold your bot’s data. But since the article grew larger than I anticipated before, I had to cut that down, unfortunately (sorry for that ?).
Today, I will deliver that part in its own article. We will learn how to work with databases in Django, what migrations are and how to interact with the database from within Django’s Admin-Backend.
Continue reading “Create your own Telegram bot with Django on Heroku – Part 8 – Integrating the database”

Create your own Telegram bot with Django on Heroku – Part 7 – Introducing apps and URLconf

Header Image showing Django, Telegram, Heroku logos
This entry is part 7 of 11 in the series Create your own Telegram bot with Django on Heroku

 

Django_Pony

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

In the previous part of this series, we started with the basics for kicking off a new Django project. We prepared our virtualenv, installed needed modules to it, created and integrated a new Heroku – project for it and learned how to work with variables in Heroku to control our application with an easy example. We also learned how to check our results locally before we publish it to our production space and how we can add an addon to our Heroku project by adding a PostgreSQL database to it.

Today, we will learn what an “app” is in Django and how to create it. Also, we will learn about and create a so-called URLconf / routing to direct specific URLs to specific parts of our code.
Continue reading “Create your own Telegram bot with Django on Heroku – Part 7 – Introducing apps and URLconf”

Create your own Telegram bot with Django on Heroku – Part 6 – Creating the Django app

Header Image showing Django, Telegram, Heroku logos
This entry is part 6 of 11 in the series Create your own Telegram bot with Django on Heroku

 

 

Django_Pony

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

In the previous part of this series, I tried to give you a brief yet thorough introduction to hosting your projects with Heroku.
That part was special because it was a completely optional part of this series; if you prefer to host your applications on a different platform and skipped that article, I’d like to repeat that this is completely OK and that I had shown nothing you will need for anything different but interacting with Heroku. You will hopefully notice no blank spots in the following articles. There is no need to read that article if you do not plan to use Heroku for hosting your bot. But you should be familiar enough with your hosting solution of choice to adopt the Heroku – commands I show here to an adequate setup for your hosting solution.

Today we will finally start creating our bot with Django. What we did up until now was just some kind of preparation and establishing background. In this part, we will finally start with the real stuff. ?

Continue reading “Create your own Telegram bot with Django on Heroku – Part 6 – Creating the Django app”

Create your own Telegram bot with Django on Heroku – Part 3

Header Image showing Django, Telegram, Heroku logos
This entry is part 3 of 11 in the series Create your own Telegram bot with Django on Heroku

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

In the previous part of this series, I explained how to register bots on Telegram, how to configure it and how to validate everything is working.

Today I will explain a bit more on how the HTTP API works, how the JSON data provided by the bots ist structured and I will introduce you to telepot, the Python module of my choice for interacting with Telegram bots using Python.

Continue reading “Create your own Telegram bot with Django on Heroku – Part 3”

Create your own Telegram bot with Django on Heroku – Part 2

Header Image showing Django, Telegram, Heroku logos
This entry is part 2 of 11 in the series Create your own Telegram bot with Django on Heroku

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

In the previous part of this series, I introduced the overall idea about what we are trying to achieve and what’s the goal of it.

Today I will show you how to register and prepare your Bot using the Telegram app.

Continue reading “Create your own Telegram bot with Django on Heroku – Part 2”

Create your own Telegram bot with Django on Heroku – Part 1

Header Image showing Django, Telegram, Heroku logos
This entry is part 1 of 11 in the series Create your own Telegram bot with Django on Heroku

⚠️ This article is outdated and discontinued since Heroku decided to no longer offer their free tiers as this article series suggests to use in August, 2022. Please see this post for details. ⚠️

Recently, I finished my first Django application ✌. Since it took me some time to find a proper starting point to wrap my head around the basics of Django well enough to actually do something with it (apart from following tutorials, which pretty much all aim for creating a polling app for any reason ?), I’d like to recap and share that journey by writing this article about that.

I will describe the project, my thoughts and considerations about it and every step which has lead to what the project has become. I will try my best to make this a guide which everybody can follow along if he wants.

Also, I will make this a series, to not end up with an article so long and boring, that even interested readers cannot afford to read it in their spare time.
In this first part of the series, I will explain what this series will be about, mainly.

Continue reading “Create your own Telegram bot with Django on Heroku – Part 1”