Setup
After you've purchased the boilerplate, in your local terminal, unzip the .zip
file to
a directory of your choice and install the Python dependencies using uv
.
Assuming that your project will live in ~/work/awesomebot
, the following commands
should work:
$ mkdir -p ~/work/awesomebot
$ cd ~/work/awesomebot
$ mv /path/to/app.zip .
$ unzip app.zip .
$ uv sync
Next, set up the initial configuration and allow direnv
to export the environment
variables. The codebase provides a sample.envrc
file, which contains a template of
the configuration variables necessary for the application to function. Feel free to copy
this file to .envrc
and update the placeholders with actual values relevant to your
setup.
$ cp sample.envrc .envrc
$ direnv allow
Configuration
Adjust .envrc
to match your own configuration. An example .envrc
file looks as
follows:
# Environment string (either development or production)
export ENV=development
# Database settings
export POSTGRES_DB="<your database name>"
export POSTGRES_USER="<your database user>"
export POSTGRES_PASSWORD="<your database password>"
# Ngrok (for local development)
export NGROK_DOMAIN="<your ngrok domain>"
# Slack API credentials
export SLACK_CLIENT_ID="<your client ID>"
export SLACK_CLIENT_SECRET="<your client secret>"
export SLACK_SIGNING_SECRET="<your signing secret>"
# Polar API credentials
export POLAR_ACCESS_TOKEN="<your Polar access token>"
export POLAR_WEBHOOK_SECRET="<your Polar Webhook secret token>"
export POLAR_PRICE_ID="<your Polar Price ID token>"
Replace the placeholders with values relevant to your setup and run direnv allow
again. This will ensure that the changes in .envrc
file take effect within the
environment.
PostgreSQL
Make sure you have a PostgreSQL instance running, and replace the POSTGRES_DB
,
POSTGRES_USER
, and POSTGRES_PASSWORD
variables with your own credentials.
Slack API
After you've created a Slack app, copy the credentials from your Slack App's "Basic
Information Page" to fill in the SLACK_CLIENT_ID
, SLACK_CLIENT_SECRET
, and
SLACK_SIGNING_SECRET
variables.
ngrok
ngrok is a local tunneling software that makes your local server accessible over the internet, allowing the Slack platform to interact with the server running on your machine. It is primarily utilized for local development.
Once you sign up for a free account on ngrok, you can create a custom ngrok-free.app
subdomain. This subdomain can be assigned to the NGROK_DOMAIN
environment variable
inside your .envrc
.
Polar
Register for an account on Polar and copy your API key and webhook secret from your developer dashboard. Make sure that you're working in the sandbox to avoid using production values!
Run Django server
At this point you should be able to bring up the development server.
$ uv run python manage.py migrate
$ uv run python manage.py runserver
The two commands above should start an HTTP server listening to requests on port 8000, unless you specified a different port on the command line.
Run ngrok local tunnel
Now that the Django server is running, start a local tunnel using ngrok
(or something
similar) in a separate terminal window. This is needed so that your bot can listen to
events happening in the Slack workspace and respond back to the Slack API with an
appropriate response.
If you're using ngrok
, the following command should work:
ngrok http --url=<awesome-bot>.ngrok-free.app 8000
Make sure to replace <awesome-bot>
with your own custom subdomain from Ngrok.
Congratulations! π
You've now successfully set up the boilerplate. At this point you should have a running server but one that doesn't really do anything interesting yet. Let's change that by setting up an app on Slack (so the bot lives as a Slack app), setting up the payment product on Polar (so your customers can pay you) and putting everything together.