"Building a simple Telegram bot using Python, Flask and Heroku" by Billy Einkamerer

"Building a simple Telegram bot using Python, Flask and Heroku" by Billy Einkamerer

A Lightning Talk at PyCon ZA 2020

7b0645f018c0bddc8ce3900ccc3ba70c?s=128

Pycon ZA

October 09, 2020
Tweet

Transcript

  1. BUILDING A TELEGRAM BOT WITH PYTHON & FLASK @billybobza

  2. Janine is using WhatsApp, she’s feeling a bit overwhelmed.. she’s

    part of 27 active groups. Jackie is using Telegram, she knows her data is safer and life is good… Harold is using Signal. His data is very safe but he only has 2 people to talk to… He likes to be alone, so it’s fine.
  3. Bots can add great usability to customers, stakeholders and other

    users of your products. They save time and money, and can replace expensive call-centre solutions under the right circumstances if done correctly. Relatively cheap to set up. WHY? BECAUSE IT’S USEFUL, FUN AND EASY!
  4. SOURCE: https://bit.ly/2SEJwz7

  5. STEP ONE SET UP TELEGRAM, PYTHON & FLASK • Set

    up your new bot on the Telegram platform • Create a new account, contact a user called “BotFather” • /newbot and name your bot and bot-user • Collect your token from BotFather, you’ll need this later • Build your Bot “engine” • Setup your Python env • Do your pip’s: install flask, python-telegram-bot, requests, gunicorn
  6. STEP TWO BUILD THE FLASK ENGINE • Create your (Flask)

    files: • app.py telebot/credentials.py telebot/__init__.py Procfile • Setup your configuration in credentials, and code your engine into app.py
  7. STEP THREE SETUP AND USE HEROKU - DEPLOY! • Login

    or Register a Heroku account • Download and install the Heroku CLI • Download and install git (if you don’t have it) • Once that is setup, update your config and do some git: • git add • git commit -m “this will actually work” • git push heroku master
  8. BOOM IT WORKED!

  9. THE END WE DID THIS LAST NIGHT IN OUR LEARN

    TO CODE USING PYTHON WEEKLY MEETUP: CODEWARSACADEMY: HTTPS://WWW.MEETUP.COM/CODENAME_THURSDAY-PY/ EVERY THURSDAY @7PM, ON DISCORD. @billybobza