Setup

  1. Message the Telegram bot father, create a new bot, remember the bot token
  2. create a new group and add you bot as admin
  3. send a message in the group
  4. https://api.telegram.org/bot<YourBOTToken>/getUpdates insert your bot token in this url and paste it in your browser
  5. search for the message, that you sent in the group, find and remember the chatid this message belongs to
    • chatid = request["results"][]["message"]["chat"]["id"]
  6. Go to https://beta.openai.com/account/api-keys, login, create and remember your api key, remember you organization identifier
  7. create a config.yml that looks like that, enter your data
    open_ai:
        api_key: <your api key>
        organization: <your organziation identifier> # feel free to choose another model, if you want
        model: "text-davinci-003" # determines the maximimum answer length, the bigger this number is the faster your free apikey trial is over
        max_tokens_per_request: 100 
    telegram:
        bot_key: <your bot key>
        chat_id: <your chat id> # the smaller the interval the faster you will get a response, but also the more processing power is required over time
        polling_interval_in_seconds: 3
  1. Host the script: Suggestion pythonanywhere.com (free), go on their website, create a free account
  2. From the Pythonanwhere dashboard go to "File" (top right) and upload the run.py file as well as the config.yml
  3. Create a new Bash Console and run the commands pip3 install openai and pip3 install pyyaml, if you uploaded the requirements.txt you can also run pip install -r requirements.txt
  4. start the script by running python run.py, done, your bot should work now