Skip to content

balancy/pizza-bot

Repository files navigation

PIZZA SHOP BOT

gif

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

Install

At least Python 3.8 and Git should be already installed.

  1. Clone the repository
git clone https://github.com/balancy/pizza-bot
  1. Go inside cloned repository, create and activate virtal environment:
python -m venv .venv
source .venv/bin/activate (.venv\scripts\activate for Windows)
  1. Install dependecies:
pip install -r requirements.txt
  1. Rename .env.example to .env and define your environment variables
  • CLIENT_ID - client id of your elasticpath account
  • CLIENT_SECRET - client secret of your elasticpath account
  • TG_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.

Launch telegram bot via console

python bot.py

Launch telegram bot via docker

Create docker image

docker build -t pizza-bot .

Launch docker container

  1. 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
  1. 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 account
  • CLIENT_SECRET - client secret of your elasticpath account
  • TG_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

Test payment card for telegram bot

  • 4242 4242 4242 4242

Launch fb bot via console locally

  1. Configure webhook for fb

  2. Create redis db

  3. Rename .env.example to .env and define your environment variables

  • CLIENT_ID - client id of your elasticpath account
  • CLIENT_SECRET - client secret of your elasticpath account
  • PAGE_ACCESS_TOKEN - fb web hook page access token
  • VERIFY_TOKEN - fb web hook verify token
  • REDIS_HOST - redis db
  • REDIS_PORT - redis port
  • REDIS_PASSWORD - redis password
  1. Launch app
gunicorn fb_bot:app

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages