import streamlit as st import pandas as pd import sqlite3 import os from datetime import datetime import time # Page config st.set_page_config( page_title="Cold Email Assistant - Premium Demo", page_icon="๐Ÿ“ง", layout="wide" ) # Import components try: from scraper import scrape_company_info SCRAPER_AVAILABLE = True except ImportError as e: print(f"โš ๏ธ Scraper not available: {e}") SCRAPER_AVAILABLE = False def scrape_company_info(url_or_company): return "Company research feature requires additional setup. Please contact support for enterprise features." from email_gen import generate_cold_email from usage_tracker import UsageTracker # Initialize usage tracker tracker = UsageTracker() # CSS for better styling st.markdown(""" """, unsafe_allow_html=True) # Header with premium badge and urgency st.markdown("""

๐Ÿš€ Cold Email Assistant - Premium Demo

โœจ You're experiencing $97/month features for FREE โ€ข Limited daily usage

๐Ÿ”ฅ ALL PREMIUM FEATURES UNLOCKED
""", unsafe_allow_html=True) # Add urgency banner usage_percent = (tracker.get_emails_generated() / tracker.daily_email_limit) * 100 if usage_percent > 70: st.error(f"โš ๏ธ **{100-usage_percent:.0f}% of daily quota remaining** - Upgrade now to avoid interruption!") elif usage_percent > 40: st.warning(f"๐Ÿ“Š **{100-usage_percent:.0f}% of daily quota remaining** - Consider upgrading for unlimited access") # Show usage in sidebar tracker.show_usage_sidebar() # Sidebar with user info st.sidebar.title("๐Ÿ“‹ Navigation") page = st.sidebar.selectbox("Choose a page", ["๐ŸŽฏ Generate Emails", "๐Ÿ“Š Bulk Processing", "๐Ÿ“ˆ Analytics Preview"]) # Sender Information st.sidebar.markdown("---") st.sidebar.subheader("๐Ÿ‘ค Your Information") sender_name = st.sidebar.text_input("Your Name", value="Alex Thompson", help="Your name that will appear in email signatures") sender_title = st.sidebar.text_input("Your Title (Optional)", value="", placeholder="e.g., Sales Director", help="Your job title (optional)") sender_company = st.sidebar.text_input("Your Company (Optional)", value="", placeholder="e.g., TechSolutions Inc.", help="Your company name (optional)") # Create sender signature if sender_title and sender_company: sender_signature = f"{sender_name}\n{sender_title}, {sender_company}" elif sender_title: sender_signature = f"{sender_name}\n{sender_title}" else: sender_signature = sender_name if page == "๐ŸŽฏ Generate Emails": st.header("๐ŸŽฏ Premium Email Generation") # Check if user can generate emails if not tracker.can_generate_email(): st.error("๐Ÿšซ **Daily limit reached!** You've experienced the premium features.") col1, col2 = st.columns([2, 1]) with col1: st.markdown(""" ### ๐ŸŽฏ What you experienced today: - โœ… AI-powered email generation (normally $97/month) - โœ… Company research automation (saves 2+ hours/day) - โœ… Industry-specific templates (10x better conversion) - โœ… Premium quality scoring (proven to increase responses) """) with col2: st.markdown(""" ### ๐Ÿ’ฐ Your ROI Calculation: **Time saved:** 2 hours ร— $50/hour = **$100/day** **Responses gained:** +40% = **$500+ in deals** **Tool cost:** Only $19 one-time **ROI:** 2,500%+ ๐Ÿš€ """) st.markdown("""

๐Ÿ”ฅ Limited Time: $19 Lifetime Deal

What others charge $97/month for - you get FOREVER for just $19

Join 500+ sales professionals already using this

๐Ÿš€ Get Lifetime Access Now
""", unsafe_allow_html=True) st.stop() col1, col2 = st.columns([2, 1]) with col1: st.subheader("๐Ÿ“ Lead Information") # Input fields name = st.text_input("๐Ÿ‘ค Contact Name", placeholder="e.g., Sarah Johnson (Director of Sales)") email = st.text_input("๐Ÿ“ง Email Address", placeholder="e.g., sarah.johnson@company.com") company = st.text_input("๐Ÿข Company Name", placeholder="e.g., TechFlow Solutions (B2B SaaS, 50-200 employees)") linkedin_url = st.text_input("๐Ÿ”— LinkedIn URL (Optional)", placeholder="https://linkedin.com/company/techflow-solutions") # Company details with premium badge st.markdown("### ๐Ÿ’ผ Company Research **โœจ PREMIUM**") company_details = st.text_area("Company Details", placeholder="AI will enhance this with premium research...", height=100, help="๐Ÿš€ Premium feature: Enhanced company research and personalization") # Premium tone options st.markdown("### ๐ŸŽญ Email Tone **โœจ PREMIUM**") tone_options = { "Professional": "Formal, executive-level", "Friendly": "Warm, relationship-building", "Direct": "Straight to the point", "Consultative": "Expert advisor approach โœจ", "Enthusiastic": "High-energy, excited โœจ" } tone_labels = [f"{tone} - {desc}" for tone, desc in tone_options.items()] selected_tone = st.selectbox("Choose tone", tone_labels) tone = selected_tone.split(" - ")[0] # Premium industry templates st.markdown("### ๐Ÿญ Industry Intelligence **โœจ PREMIUM**") industry_options = { "SaaS/Tech": "Software, AI, Digital platforms", "E-commerce": "Online retail, DTC brands", "Manufacturing": "Industrial, Production", "Healthcare": "Medical, Pharma, Clinical", "Financial Services": "FinTech, Banking โœจ", "Real Estate": "PropTech, Commercial โœจ", "Generic B2B": "General business approach" } industry_labels = [f"{ind} - {desc}" for ind, desc in industry_options.items()] selected_industry = st.selectbox("Industry template", industry_labels, index=6) industry_template = selected_industry.split(" - ")[0] # Call to action cta_type = st.selectbox("๐Ÿ“ž Call-to-Action Type", ["Meeting/Call", "Demo", "Information", "Partnership", "Custom"]) if cta_type == "Custom": custom_cta = st.text_input("โœ๏ธ Custom CTA", placeholder="e.g., Schedule a consultation") else: custom_cta = None with col2: st.subheader("๐ŸŽฏ Premium Actions") # LinkedIn scraping with limits scraper_button_text = "๐Ÿ” Auto-Research Company" if SCRAPER_AVAILABLE else "๐Ÿ” Auto-Research Company (Setup Required)" if st.button(scraper_button_text, use_container_width=True): if not SCRAPER_AVAILABLE: st.warning("๐Ÿ”ง **Company research requires additional setup**") st.info("๐Ÿ’ก **Premium Feature Preview:** This would normally scrape LinkedIn/company websites for detailed information to personalize your emails.") st.markdown("**Value:** Manual research = 30 min ร— $50/hr = $25. This tool = $0.06 per research!") st.success("โœจ **Upgrade to get:** Automated LinkedIn scraping, company website analysis, and industry insights!") elif not tracker.can_scrape_linkedin(): st.warning("๐Ÿšซ **Research limit reached!** This premium feature saves 30+ minutes per lead.") st.markdown("**๐Ÿ’ก Upgrade for unlimited company research** - [Get it here โ†’](https://gumroad.com/l/cold-email-assistant)") elif linkedin_url or company: with st.spinner("๐Ÿ•’ Researching company (Premium feature)..."): try: scraped_info = scrape_company_info(linkedin_url if linkedin_url else company) if scraped_info and "requires additional setup" not in scraped_info: company_details = scraped_info tracker.increment_linkedin_scrape() tracker.add_premium_feature_used("LinkedIn Research") st.success("โœ… Premium research completed! (Saved you 30+ minutes)") st.text_area("๐Ÿ“‹ Research Results", value=scraped_info, height=150, disabled=True) # Show value st.info("๐Ÿ’ฐ **Value delivered:** Manual research = 30 min ร— $50/hr = $25. This tool = $0.06 per research!") else: st.warning("โš ๏ธ Could not research this company. Try manual details.") except Exception as e: st.error(f"โŒ Research failed: {str(e)}") else: st.error("Please provide LinkedIn URL or company name") # A/B testing preview st.markdown("### ๐Ÿ“Š A/B Testing **โœจ PREMIUM**") if st.button("๐Ÿงช Generate A/B Variants", use_container_width=True): tracker.add_premium_feature_used("A/B Testing") st.success("โœจ **A/B Testing unlocked!** Generate 3 different email variants:") variants = [ "๐Ÿ“ง **Variant A:** Direct approach - 'Quick question about [company]'", "๐Ÿ“ง **Variant B:** Value-first - 'Helping [industry] companies save [pain point]'", "๐Ÿ“ง **Variant C:** Social proof - 'How [similar company] achieved [result]'" ] for variant in variants: st.info(variant) st.warning("๐Ÿšซ **Full A/B testing with metrics requires upgrade** - Track which emails get 3x better responses!") st.caption("๐Ÿ’ฐ **Value:** A/B testing typically increases response rates by 40-60%") # Quality insights st.markdown("### ๐Ÿ“ˆ Quality Insights **โœจ PREMIUM**") st.info("๐ŸŽฏ **Premium Quality Scoring**\n\nโ€ข Personalization analysis\nโ€ข Industry benchmarking\nโ€ข Conversion predictors\nโ€ข Improvement suggestions") # Usage warning remaining = tracker.get_remaining_emails() if remaining <= 2: st.warning(f"โš ๏ธ Only {remaining} emails left today!") # Generate email button if st.button("๐Ÿš€ Generate Premium Email", use_container_width=True, type="primary"): if name and company: if not tracker.can_generate_email(): tracker.show_upgrade_prompt("email generation") else: try: with st.spinner("๐Ÿค– AI is crafting your premium personalized email..."): # Generate email with premium features result = generate_cold_email( name=name, company=company, company_details=company_details or "", tone=tone.lower(), cta_type=cta_type.lower().replace("/", "_") if cta_type != "Custom" else custom_cta, industry_template=industry_template, sender_signature=sender_signature ) if result: subject, body, quality_score = result # Check if this is a setup error if subject == "Setup Required": st.error("๐Ÿ”ง **Premium AI Features Need Setup**") st.markdown(body) # This contains the setup instructions # Show what users are missing st.info("๐Ÿš€ **What you're missing without AI setup:**") st.markdown(""" - ๐Ÿค– **Advanced AI Personalization** (40% better conversion) - ๐ŸŽฏ **Industry-Specific Intelligence** (10x more relevant) - ๐Ÿ“Š **AI Quality Scoring** (proven metrics) - ๐Ÿ” **Smart Company Analysis** (saves 30+ min research) """) st.success("โœจ **Good News:** All premium features work perfectly once set up!") st.markdown("**๐Ÿ’ฐ Value Unlocked:** $97/month worth of AI features for just $19 lifetime") # Still show upgrade CTA st.markdown("""

๐Ÿ”ฅ Skip Setup - Get Pre-Configured Version

Get the fully-configured app with all AI features ready to use

๐Ÿš€ Get Lifetime Access Now
""", unsafe_allow_html=True) st.stop() # Track usage for successful generation tracker.increment_email_generation() tracker.add_premium_feature_used("Premium Email Generation") # Display results with premium features st.success("โœ… Premium email generated successfully!") col_result1, col_result2 = st.columns([3, 1]) with col_result1: st.subheader("๐Ÿ“ง Generated Premium Email") # Subject line st.markdown("**๐Ÿ“‹ Subject Line:**") st.code(subject, language="text") # Email body st.markdown("**โœ‰๏ธ Email Body:**") st.text_area("", value=body, height=300, key="generated_email") # Premium copy buttons col_copy1, col_copy2 = st.columns(2) with col_copy1: if st.button("๐Ÿ“‹ Copy Subject", use_container_width=True): st.code(f"Subject copied: {subject}") with col_copy2: if st.button("๐Ÿ“‹ Copy Email Body", use_container_width=True): st.code("Email body copied to clipboard!") with col_result2: st.markdown("### ๐Ÿ“Š Premium Quality Score") score_color = "๐ŸŸข" if quality_score >= 8 else "๐ŸŸก" if quality_score >= 6 else "๐Ÿ”ด" st.markdown(f"## {score_color} {quality_score}/10") # Premium quality insights if quality_score >= 8: st.success("๐Ÿš€ Premium Quality!") st.caption("โœ… AI-optimized personalization\nโœ… Industry-specific messaging\nโœ… Conversion-tested format") elif quality_score >= 6: st.warning("๐Ÿ“ˆ Good Quality") st.caption("โœ… Decent personalization\nโš ๏ธ Could be more specific") else: st.error("โšก Needs Premium Boost") st.caption("๐Ÿ’ก Try premium research features") st.markdown("### ๐ŸŽฏ Premium Features Used") features_used = tracker.get_premium_features_used() for feature in features_used: st.caption(f"โœจ {feature}") # Remaining usage remaining_after = tracker.get_remaining_emails() if remaining_after > 0: st.info(f"๐Ÿ“ง {remaining_after} emails left today") else: st.error("๐Ÿ“ง Daily limit reached!") st.markdown("**[๐Ÿš€ Get Unlimited โ†’](https://gumroad.com/l/cold-email-assistant)**") except Exception as e: st.error(f"โŒ Error generating email: {str(e)}") else: st.error("โŒ Please fill in at least Name and Company fields") elif page == "๐Ÿ“Š Bulk Processing": st.header("๐Ÿ“Š Premium Bulk Processing") # Check bulk export limit if not tracker.can_bulk_export(): tracker.show_upgrade_prompt("bulk processing") st.stop() st.info("๐Ÿš€ **Premium Bulk Processing** - Process up to 10 leads in demo mode") # File upload uploaded_file = st.file_uploader("๐Ÿ“ Upload CSV file", type=['csv']) if uploaded_file: try: df = pd.read_csv(uploaded_file) # Limit to 10 rows in demo if len(df) > 10: st.warning(f"โš ๏ธ Demo limited to 10 leads. Uploaded {len(df)} leads.") df = df.head(10) st.info("๐Ÿš€ Upgrade for unlimited bulk processing!") st.success(f"โœ… File uploaded! Processing {len(df)} leads in demo mode.") # Show preview st.subheader("๐Ÿ‘€ Data Preview") st.dataframe(df.head()) # Processing options col1, col2 = st.columns(2) with col1: tone = st.selectbox("๐ŸŽญ Email Tone for All", ["Professional", "Friendly", "Direct", "Consultative โœจ"]) industry_template = st.selectbox("๐Ÿญ Industry Template", ["SaaS/Tech", "E-commerce", "Healthcare", "Generic B2B"], index=3) with col2: st.markdown("**โœจ Premium Features:**") st.caption("โ€ข AI-powered personalization") st.caption("โ€ข Industry-specific templates") st.caption("โ€ข Quality scoring") st.caption("โ€ข Bulk export") # Process button if st.button("๐Ÿš€ Process All Leads (Premium Demo)", use_container_width=True, type="primary"): progress_bar = st.progress(0) status_text = st.empty() results = [] for idx, row in df.iterrows(): status_text.text(f"Processing {idx + 1}/{len(df)}: {row['name']} at {row['company']}") try: # Generate email result = generate_cold_email( name=row['name'], company=row['company'], company_details="", tone=tone.lower(), cta_type="meeting_call", industry_template=industry_template, sender_signature=sender_signature ) # Check if result is an error/setup message if isinstance(result, str) and any(error_type in result for error_type in ["Setup Required", "AI Model Error", "Generation Error"]): results.append({ 'name': row['name'], 'company': row['company'], 'email': row.get('email', ''), 'subject': '', 'body': '', 'quality_score': 0, 'status': f'Setup Required: {result[:100]}...' }) elif result and isinstance(result, tuple) and len(result) == 3: subject, body, quality_score = result results.append({ 'name': row['name'], 'company': row['company'], 'email': row.get('email', ''), 'subject': subject, 'body': body, 'quality_score': quality_score, 'status': 'Success' }) else: results.append({ 'name': row['name'], 'company': row['company'], 'email': row.get('email', ''), 'subject': '', 'body': '', 'quality_score': 0, 'status': 'Error: Invalid response from email generator' }) except Exception as e: results.append({ 'name': row['name'], 'company': row['company'], 'email': row.get('email', ''), 'subject': '', 'body': '', 'quality_score': 0, 'status': f'Error: {str(e)}' }) # Update progress progress_bar.progress((idx + 1) / len(df)) time.sleep(0.5) # Track usage tracker.increment_bulk_export() tracker.add_premium_feature_used("Bulk Processing") # Show results status_text.text("โœ… Premium processing complete!") results_df = pd.DataFrame(results) # Display summary successful = len(results_df[results_df['status'] == 'Success']) col1, col2, col3 = st.columns(3) with col1: st.metric("๐Ÿ“ง Processed", len(results_df)) with col2: st.metric("โœ… Successful", successful) with col3: avg_quality = results_df['quality_score'].mean() st.metric("โญ Avg Quality", f"{avg_quality:.1f}/10") # Show results table st.subheader("๐Ÿ“Š Results") st.dataframe(results_df) # Download option csv = results_df.to_csv(index=False) st.download_button( "๐Ÿ“ฅ Download Results (Premium)", csv, f"premium_emails_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv", "text/csv", use_container_width=True ) st.success("โœจ Premium bulk processing complete! Upgrade for unlimited processing.") except Exception as e: st.error(f"โŒ Error processing file: {str(e)}") elif page == "๐Ÿ“ˆ Analytics Preview": st.header("๐Ÿ“ˆ Premium Analytics Preview") st.info("๐Ÿš€ **Premium Analytics Dashboard** - Get insights on your email performance") # Mock analytics data col1, col2, col3, col4 = st.columns(4) with col1: st.metric("๐Ÿ“ง Total Emails", "127", "+23 this week") with col2: st.metric("๐Ÿ“ˆ Avg Quality", "8.3/10", "+0.5 improvement") with col3: st.metric("๐Ÿข Companies", "45", "+12 this week") with col4: st.metric("โญ Top Score", "9.2/10", "Healthcare emails") # Charts preview st.subheader("๐Ÿ“Š Performance Insights") col1, col2 = st.columns(2) with col1: st.markdown("**๐Ÿ“ˆ Quality Trends**") st.line_chart(pd.DataFrame({ 'Day': range(7), 'Quality Score': [7.2, 7.8, 8.1, 8.3, 8.5, 8.2, 8.7] }).set_index('Day')) with col2: st.markdown("**๐Ÿญ Industry Performance**") st.bar_chart(pd.DataFrame({ 'SaaS': [8.5], 'Healthcare': [9.2], 'Manufacturing': [7.8], 'E-commerce': [8.1] })) # Premium features preview st.subheader("โœจ Premium Analytics Features") features = [ "๐Ÿ“Š Conversion tracking integration", "๐Ÿ“ˆ A/B testing results dashboard", "๐ŸŽฏ Industry benchmarking", "๐Ÿ“ง Email performance heatmaps", "๐Ÿ” Competitor analysis", "๐Ÿ“ฑ Mobile-optimized reports", "๐Ÿ”” Performance alerts", "๐Ÿ“Š Export to PowerBI/Tableau" ] for i, feature in enumerate(features): if i % 2 == 0: col1, col2 = st.columns(2) with col1 if i % 2 == 0 else col2: st.info(feature) st.markdown("---") st.success("๐Ÿš€ **Ready to unlock full analytics?** Get unlimited access + advanced reporting!") if st.button("๐Ÿš€ Upgrade to Premium Analytics", use_container_width=True, type="primary"): st.markdown("**[๐Ÿ”— Get Cold Email Assistant Pro โ†’](https://gumroad.com/l/cold-email-assistant)**") # Footer with upgrade CTA st.markdown("---") st.markdown("""

๐Ÿš€ Ready for Unlimited Access?

You've experienced the premium features - now get unlimited access!

โœ… Unlimited emails โœ… Unlimited research โœ… Advanced analytics โœ… Priority support

Get Lifetime Access for $19 โ†’

""", unsafe_allow_html=True)