Building a NFT minting bot with Cardano, Telegram, and Python - Part 1

Part 1: Building a simple bot with Python 3

Building a simple bot with Python 3

Outline

OK, after reading the intro you are probably ready to go.  Let's figure out how to build a simple bot that will use some of the features in python-telegram-bot.

Step 1 - Get a bot api key from the BotFather

To get an API token you need to hit up the BotFather.

type /newbot, enter the name you'd like the bot to be called.  Needs _bot at the end of the name.

The BotFather will respond with your API token, save this to a .env file

# Telegram Bot API Key
export BOT_API_TOKEN=YOUR_SECRET_KEY

Step 2 - Build a simple bot from the examples folder

We will need a virtual environment and python-telegram-bot installed.

mkdir my_bot
cd my_bot
virtualenv -p python3 venv
pip install python-telegram-bot
source .env

OK we have our project setup, now to go get an example script from the projects example repo:

https://github.com/python-telegram-bot/python-telegram-bot/tree/master/examples

Since our bot will be a bit complex, we will use the conversationbot.py
file.  Feel free to use any example that interests you.

Copy that code in to a file called app.py

Scroll to line 129 and replace TOKEN with the API key the bot father gave you.

save and run the app.py

python app.py

You will notice no output, but the bot is ready.

Go chat with it.

Step 3 - Chat with your bot

Open up your Telegram app and start a conversation with your creepy bot as it will ask you a bunch of personal questions.

As you can see the bot responds with questions after each response, you might want to call this version of the bot the "creepy Mark Zuckerberg" version  ;)


Awesome, you have the basic bot setup, now let's go over the basic data storage for the bot.

Part 2: Our data storage backend for the bot