-
Message @BotFather on Telegram to create a new Telegram bot. You will need the bot token later.
-
Sign up to get an OpenAI API key. It may be wise to set spending limits at this time.
-
Create a GCP project. Enable the Cloud Functions API and Cloud Build API for your new project.
-
Message
/startto @userinfobot on Telegram to get your Telegram user ID. -
In the main directory, create a file
terraform.tfvarswith the following format:
project = "your-project"
region = "us-west1"
zone = "us-west1-a"
user_email = "your-google-email@example.com"
telegram_bot_token = "your:bot-token"
openai_api_key = "your-api-key"
admin_id = "your-telegram-user-id"
allow_public = falseYou may set allow_public to true if you would like anyone to be able to message the bot without approval.
-
Install Terraform and run
terraform initandterraform apply. When the command finishes running, your bot should be ready to message! -
If you would ever like to clean up the created resources, run
terraform destroy.
-
Run
pip install -r requirements.txt && pip install pytest>=7.4.01. -
Run
$(terraform output -raw environment_variables). Additionally runexport LOCAL_MODE=1if you would like to run in polling mode. -
If you would like to run the webhook test suite, run
pytest -s test.py. If you would like to run locally with polling, runpython main.py.
-
Run
python generate_test_terraform.py. -
Run
cp terraform.tfvars .test_env/terraform.tfvars. -
Create a new bot with BotFather and replace the bot token in
.test_env/terraform.tfvarswith the test bot token. -
Run
terraform initandterraform apply. -
This will create and run a separate copy of the bot.