App represents telegram bot for customers of imagined "Pizza Shop". "Pizza shop" is a test online shop with data hosted on Elasticpath e-commerce platform.
Bot allows to user to:
- list all available items
- go into product details
- add them to the cart
- delete items from the cart
- find the nearest pizzeria according to provided address or coordinates
- calculate delivery cost based on the distance to the nearest pizzeria
- process to checkout with the test payment method
Link to telegram bot: Bot
At least Python 3.8 and Git should be already installed.
- Clone the repository
git clone https://github.com/balancy/pizza-bot
- Go inside cloned repository, create and activate virtal environment:
python -m venv .venv
source .venv/bin/activate (.venv\scripts\activate for Windows)
- Install dependecies:
pip install -r requirements.txt
- Rename
.env.example
to.env
and define your environment variables
CLIENT_ID
- client id of your elasticpath accountCLIENT_SECRET
- client secret of your elasticpath accountTG_BOT_TOKEN
- token of your telegram pizza shop bot. Could be acquired via BotFather.YANDEX_API_TOKEN
- token of your yandex account. Could by acquired via yandex.PAYMENT_PROVIDER_TOKEN
- token of payment provider for your telegram bot. Could be acquired via BotFather.
python bot.py
docker build -t pizza-bot .
- You can use the following command if you want to use the same setup of environment variables we used locally:
docker run --env-file ./.env pizza-bot
- If you want to use different setup of environment variables:
Make a copy of .env file:
cp .env .env.prod
Define your proper production environment variables in .env.prod
CLIENT_ID
- client id of your elasticpath accountCLIENT_SECRET
- client secret of your elasticpath accountTG_BOT_TOKEN
- token of your telegram pizza shop bot. Could be acquired via BotFather.YANDEX_API_TOKEN
- token of your yandex account. Could by acquired via yandex.PAYMENT_PROVIDER_TOKEN
- token of payment provider for your telegram bot. Could be acquired via BotFather.
Run container:
docker run --env-file ./.env.dev pizza-bot
4242 4242 4242 4242
-
Configure webhook for fb
-
Create redis db
-
Rename
.env.example
to.env
and define your environment variables
CLIENT_ID
- client id of your elasticpath accountCLIENT_SECRET
- client secret of your elasticpath accountPAGE_ACCESS_TOKEN
- fb web hook page access tokenVERIFY_TOKEN
- fb web hook verify tokenREDIS_HOST
- redis dbREDIS_PORT
- redis portREDIS_PASSWORD
- redis password
- Launch app
gunicorn fb_bot:app