by bobflyers225
PackAPunch b4u Bot
from utils import telegram
from utils import print_setup_instructions
import os
import logging
import traceback
from flask import Flask, render_template, request, jsonify, session
from telegram import Update, ParseMode
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
from abilities import apply_sqlite_migrations
from models import db, StoreStatus, Order
from datetime import datetime
import uuid
TELEGRAM_API_TOKEN = os.getenv('TELEGRAM_API_TOKEN')
OWNER_ID = int(os.getenv('OWNER_ID', 0)) # Default to 0 if not set
logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.DEBUG, # Changed to DEBUG for more detailed logging
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(), # Console output
logging.FileHandler('telegram_bot.log') # Log to file for persistent debugging
Created: | Last Updated:
PackAPunch b4u Bot Template Guide
This template creates a Telegram bot for managing a store's operations, including order processing, store hours, and status management.
Getting Started
- Click "Start with this Template" to begin
- Set up your environment secrets in the Environment Secrets tab:
TELEGRAM_API_TOKEN
: Your Telegram bot API tokenOWNER_ID
: Your Telegram user ID
Setting Up Your Telegram Bot
- Create a new bot with BotFather:
- Open Telegram and search for @BotFather
- Send
/newbot
command - Follow prompts to name your bot
-
Copy the API token provided by BotFather
-
Get your Telegram User ID:
- Message @userinfobot on Telegram
-
Copy the ID number it provides
-
Add these values to Environment Secrets:
- Add
TELEGRAM_API_TOKEN
with your bot token - Add
OWNER_ID
with your Telegram user ID
Testing the Bot
- Click the "Test" button
- The bot will start and provide a link to chat with it
- Click the link to start interacting with your bot
Using the Bot
Available commands:
* /start
- Initiates the bot
* /help
- Shows all available commands
* /hours
- Displays store hours and owner status
* /active
- Toggles store status (owner only)
The bot also includes a checkout system accessible via web interface at the provided server URL + /checkout
.
Store Management Features
- Toggle active/inactive status using
/active
- Process orders through the checkout system
- Monitor store hours and status
- Handle customer interactions via Telegram
The template includes both a Telegram bot interface and a web-based checkout system, allowing for comprehensive store management and order processing.
Template Benefits
- Automated Order Management
- Streamlines the order processing workflow through a Telegram bot interface
- Reduces manual intervention and human error in order handling
-
Provides real-time order status updates to both customers and owners
-
Multi-Channel Sales Integration
- Combines web-based checkout with Telegram bot functionality
- Supports multiple payment methods (Apple Pay, Zelle, Cryptocurrencies)
-
Creates a seamless experience across different platforms
-
Business Availability Control
- Allows owner to easily toggle store active status via Telegram commands
- Provides transparent store hours and availability information to customers
-
Maintains clear communication about service availability 24/7
-
Enhanced Customer Service
- Offers immediate automated responses to common customer queries
- Provides clear command structure for customer interactions
-
Enables direct communication channel between customers and business owner
-
Secure Transaction Processing
- Implements secure database storage for order information
- Maintains detailed transaction records with unique order IDs
- Supports multiple payment options with built-in verification systems
Technologies




