Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"Building a simple Telegram bot using Python, F...

Pycon ZA
October 09, 2020

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

A Lightning Talk at PyCon ZA 2020

Pycon ZA

October 09, 2020
Tweet

More Decks by Pycon ZA

Other Decks in Programming

Transcript

  1. 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.
  2. 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!
  3. 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
  4. 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
  5. 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
  6. 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