SMS Marketing Campaign Builder
Run ID: 69c94f32a17964d77e86d9502026-03-29Marketing
PantheraHive BOS
BOS Dashboard

Design SMS marketing campaigns with opt-in flows, drip sequences, segmentation, and compliance (TCPA).

As a professional AI assistant within PantheraHive, I have executed step 1 of 2: "gemini → generate" for your "SMS Marketing Campaign Builder" workflow. This output provides a comprehensive, detailed, and actionable design for your SMS marketing campaigns, covering opt-in flows, drip sequences, segmentation, and critical TCPA compliance requirements.


SMS Marketing Campaign Design & Strategy

This document outlines a robust framework for designing effective and compliant SMS marketing campaigns. It covers the essential components from initial opt-in to advanced segmentation and automated drip sequences, all while ensuring adherence to TCPA guidelines.


1. Campaign Objectives & Key Performance Indicators (KPIs)

Before designing the specifics, clearly define what you aim to achieve with your SMS campaign.

  • Objective Examples:

* Increase website traffic by X%.

* Drive X% increase in sales for a specific product/category.

* Improve customer retention by X%.

* Increase engagement with new product launches.

* Generate X leads for a specific service.

  • Key Performance Indicators (KPIs):

* Opt-in Rate: Percentage of visitors/customers who subscribe.

* Click-Through Rate (CTR): Percentage of recipients who click a link in your SMS.

* Conversion Rate: Percentage of recipients who complete the desired action (e.g., purchase, form submission).

* Opt-out Rate: Percentage of subscribers who unsubscribe.

* Return on Investment (ROI): Revenue generated versus campaign cost.

* Customer Lifetime Value (CLV): Impact on long-term customer value.


2. TCPA Compliance: The Foundation of SMS Marketing

Adherence to the Telephone Consumer Protection Act (TCPA) and other relevant regulations (e.g., CTIA guidelines, GDPR, CCPA where applicable) is paramount to avoid legal penalties and maintain brand trust.

2.1. Explicit Consent (Opt-in)

  • Requirement: You must obtain clear, explicit, written consent from every subscriber before sending any marketing SMS messages.
  • Methods for Obtaining Consent:

* Web Forms: Clearly state what users are opting into (e.g., "Receive promotional SMS messages from [Your Brand Name]"). Include frequency expectations and a link to your privacy policy.

* Keyword Opt-in: Users text a specific keyword (e.g., "JOIN") to a short code or long code. The auto-response must confirm opt-in and provide necessary disclosures.

* Point-of-Sale (POS) Opt-in: In-store sign-ups where customers provide their number and explicitly check a box or sign to consent.

* QR Codes: Scan a QR code that directs to an opt-in web form.

  • Key Disclosure Requirements (at point of opt-in):

* Clear Call to Action: "Text [KEYWORD] to [SHORT CODE] to receive [NUMBER] messages per month from [BRAND NAME]."

* Message and Data Rates May Apply: Explicitly state this.

* Opt-out Instructions: "Text STOP to cancel."

* Help Instructions: "Text HELP for assistance."

* Link to Terms & Conditions / Privacy Policy: Always provide these.

2.2. Opt-out Mechanism

  • Requirement: Provide a simple, clear, and always-available method for subscribers to opt out.
  • Standard Practice: "Reply STOP to unsubscribe."
  • Automatic Unsubscription: Your SMS platform must automatically remove subscribers who text "STOP," "END," "CANCEL," "QUIT," or "UNSUBSCRIBE" from your list and send a confirmation message (e.g., "You have been unsubscribed from [Your Brand Name] messages. Reply START to resubscribe.").
  • No Further Messages: Once opted out, no more marketing messages should be sent to that number unless they explicitly re-opt-in.

2.3. Message Content & Frequency

  • Identify Your Brand: Clearly state who is sending the message.
  • Purpose: Messages should align with the consent given during opt-in.
  • Frequency: Manage expectations set during opt-in (e.g., "max 4 msg/month"). Avoid excessive messaging, which leads to high opt-out rates.
  • Timing: Send messages during reasonable hours (e.g., 9 AM - 8 PM recipient's local time) to avoid disturbing subscribers.

2.4. Record Keeping

  • Requirement: Maintain detailed records of all opt-ins and opt-outs, including timestamps, methods of consent, and any disclosures provided. This is crucial for demonstrating compliance if challenged.

3. Opt-in Flow Design

The opt-in flow is the first interaction and sets the tone for the subscriber relationship.

3.1. Opt-in Entry Points & Messaging

  • Keyword Opt-in (e.g., Text "DEALS" to 12345):

* Initial Auto-Response: "Thanks for joining [Your Brand Name]! You'll receive [NUMBER] messages/month with exclusive deals. Msg&data rates may apply. Reply HELP for info, STOP to cancel. [Link to T&C/Privacy Policy]"

* Double Opt-in (Recommended): After the initial response, send: "Reply YES to confirm your subscription to [Your Brand Name] deals." (This adds an extra layer of consent and reduces spam complaints).

  • Web Form Opt-in:

* Form Field: Clearly labeled "Mobile Phone Number."

* Checkbox/Statement: "Yes, I agree to receive promotional SMS messages from [Your Brand Name]. Msg&data rates may apply. Reply STOP to cancel. [Link to T&C/Privacy Policy]"

* Post-Submission: Display a confirmation message on the website and/or send an immediate SMS confirmation.

3.2. Welcome Message (Post-Confirmation)

Once a user has confirmed their subscription (especially with double opt-in), send a warm welcome message.

  • Purpose: Reiterate value, set expectations, and provide an initial offer.
  • Content Example: "Welcome to the [Your Brand Name] VIP Club! Thanks for joining. Here's 15% off your first order: [Discount Code/Link]. We'll send you exclusive offers & updates. Reply HELP for info, STOP to cancel."

4. Segmentation Strategy

Segmentation allows you to send highly relevant and personalized messages, increasing engagement and conversion rates.

4.1. Key Segmentation Criteria

  • Demographics: Age, gender, location (e.g., for local promotions).
  • Purchase History:

* First-time buyers vs. repeat customers.

* High-value customers vs. average spenders.

* Customers who purchased specific product categories.

* Date of last purchase.

  • Website/App Behavior:

* Browsed specific products/categories.

* Abandoned cart.

* Viewed product but didn't add to cart.

* Visited specific pages (e.g., pricing, support).

  • Engagement Level:

* Recently active (clicked links, opened emails).

* Inactive/Lapsed subscribers (haven't engaged in X days/months).

  • Opt-in Source: Segment based on how they opted in (e.g., website, in-store, specific campaign).
  • Preferences (Self-Declared): Allow users to choose what type of messages they want to receive (e.g., "deals," "new arrivals," "events").

4.2. Example Segments & Use Cases

  • "New Subscribers": For welcome series.
  • "Abandoned Cart": For recovery messages.
  • "High-Value Customers": For exclusive loyalty rewards or early access.
  • "Category Browsers (e.g., 'Shoes')": For promotions on new shoe arrivals.
  • "Inactive Subscribers": For re-engagement campaigns.
  • "Local Customers (within 5 miles of Store A)": For in-store events or local-specific offers.

5. Drip Sequence Design (Automated Messaging)

Drip sequences are automated series of messages triggered by specific user actions or time intervals.

5.1. Welcome Series (Trigger: New Subscriber Opt-in)

  • Goal: Onboard new subscribers, introduce your brand, and drive first conversion.
  • Message 1 (Immediate): Welcome message + initial discount/offer (as described in Section 3.2).
  • Message 2 (24-48 hours later): Highlight a key product/service benefit, popular product, or brand story. "Did you know [Your Brand] offers [unique benefit]? Explore our bestsellers: [Link]"
  • Message 3 (3-5 days later): Address a common pain point your product solves, or showcase social proof (e.g., customer testimonial). "See why customers love us! Check out our reviews: [Link]"
  • Message 4 (7 days later, if no purchase): Gentle reminder of the initial offer or a limited-time bonus. "Don't miss out on your 15% off! Offer ends soon: [Link]"

5.2. Abandoned Cart Series (Trigger: Item left in cart for X hours)

  • Goal: Recover lost sales.
  • Message 1 (30-60 minutes after abandonment): Gentle reminder. "Hey [Customer Name], you left some items in your cart! Complete your order before they're gone: [Cart Link]"
  • Message 2 (4-6 hours later): Add a sense of urgency or social proof. "Still thinking about those items? They're popular! Finish your purchase now: [Cart Link]"
  • Message 3 (24 hours later): Offer a small incentive (e.g., free shipping, small discount). "Here's 5% off to help you complete your order! Use code CART5 at checkout: [Cart Link]"

5.3. Post-Purchase Series (Trigger: Purchase Completed)

  • Goal: Enhance customer experience, encourage repeat purchases, solicit feedback.
  • Message 1 (Immediate/Shipping Confirmation): "Thanks for your order, [Customer Name]! Your order #[Order Number] is confirmed. We'll send tracking info soon. Shop again: [Link]"
  • Message 2 (Delivery Confirmation + Product Care Tips): "Your [Product Name] has been delivered! Here are some tips to get the most out of it: [Link to Blog/FAQ]"
  • Message 3 (7-14 days post-delivery): Request a review or offer a complementary product. "Loving your new [Product Name]? Share your thoughts & get 10% off your next order: [Review Link]"
  • Message 4 (30-60 days post-delivery): Reorder reminder for consumables or introduce related products. "Time to restock your [Product Name]? Order now: [Link]"

5.4. Re-engagement Series (Trigger: No activity/purchase in X days/months)

  • Goal: Reawaken inactive subscribers.
  • Message 1 (30-60 days of inactivity): "We miss you, [Customer Name]! Here's what's new at [Your Brand Name]: [Link]"
  • Message 2 (90 days of inactivity): Offer a significant incentive. "Still there? Here's 20% off your next purchase to say hello! Code: COMEBACK20. [Link]"
  • Message 3 (120 days of inactivity): Last chance/preference update. "Want to keep hearing from us? Reply YES to stay subscribed, or we'll remove you from our list. Reply STOP to cancel."

5.5. Event-Triggered Series (e.g., Birthday, Anniversary)

  • Goal: Personalize experience, build loyalty.
  • Message 1 (Birthday/Anniversary): "Happy Birthday, [Customer Name]! Enjoy a special treat on us: [Discount Code/Gift Link] (Valid for X days)."

6. Message Content Best Practices

Crafting compelling SMS messages is key to driving action.

  • Be Concise: SMS has character limits (typically 160 characters per segment, though modern phones handle longer messages). Get to the point quickly.
  • Clear Call to Action (CTA): What do you want the recipient to do? (e.g., "Shop Now," "Get Your Discount," "Learn More," "Reply YES").
  • Personalization: Use subscriber names ([Customer Name]) and tailor offers based on segments.
  • Value Proposition: Clearly state the benefit to the customer.
  • Brand Voice: Maintain consistency with your brand's tone.
  • URL Shorteners: Use reliable, trackable URL shorteners (e.g., Bitly, Rebrandly) to save characters and monitor clicks.
  • Emojis (Use Judiciously): Emojis can add personality but ensure they are relevant and professional for your brand. Be aware that some older phones or carriers might not display them correctly, or they might take up more characters.
  • Incentives: Discounts, free shipping, exclusive access, early bird offers.
  • Scarcity/Urgency: "Limited stock," "Offer ends tonight," "X hours left."

7. Pre-Launch Campaign Checklist

Before going live, ensure everything is in order.

  • Compliance Review: Double-check all opt-in mechanisms, disclosures, and opt-out instructions for TCPA and other relevant regulations.
  • Message Proofreading: Review all SMS copy for typos, grammatical errors, and clarity.
  • Link Testing: Verify all URLs are correct, functional, and lead to the intended destination.
  • A/B Testing Plan: Decide which elements you'll test (e.g., CTA, offer, timing) to optimize performance.
  • Integration Check: Ensure your SMS platform is correctly integrated with your CRM, e-commerce platform, or other relevant systems.
  • Segmentation Accuracy: Confirm that your audience segments are correctly defined and populated.
  • Drip Sequence Logic: Test all triggers, delays, and message flows within your automated sequences.
  • Opt-out Functionality: Test the "STOP" command to ensure it unsubscribes users correctly and sends the confirmation message.
  • Internal Testing: Send test messages to internal team members to experience the full customer journey.

8. Next Steps & Optimization

Once your campaign is live, continuous monitoring and optimization are crucial.

  • Monitor KPIs: Regularly track your opt-in rates, CTR, conversion rates, and opt-out rates.
  • A/B Testing: Continuously test different message elements (CTAs, offers, timing) to identify what resonates best with your audience.
  • Analyze Opt-out Reasons: If possible, gather feedback on why users are opting out
gemini Output

SMS Marketing Campaign Design & Implementation Guide

This document provides a comprehensive, detailed framework for designing and implementing your SMS marketing campaigns, ensuring compliance, effectiveness, and a positive customer experience.


1. Campaign Objective & Strategy Definition

Before drafting any messages, clearly define what you want your SMS campaign to achieve.

  • Campaign Name: (e.g., "Welcome Series - New Subscribers," "Flash Sale Alert - Spring Collection," "Abandoned Cart Recovery")
  • Primary Objective:

* Increase sales/conversions (e.g., drive 15% more purchases for specific products).

* Boost engagement (e.g., increase website visits by 10%).

* Improve customer retention/loyalty (e.g., reduce churn by 5%).

* Collect customer feedback/data (e.g., achieve 20% survey completion rate).

  • Target Audience: Who are you trying to reach with this specific campaign? (e.g., new website visitors, existing customers who purchased X, users with abandoned carts).
  • Key Performance Indicators (KPIs):

* Opt-in Rate: Percentage of visitors who subscribe.

* Click-Through Rate (CTR): Percentage of recipients who click a link in your SMS.

* Conversion Rate: Percentage of recipients who complete the desired action (e.g., purchase, sign-up).

* Redemption Rate: For promotions, percentage of offers used.

* Opt-Out Rate: Percentage of subscribers who unsubscribe.

* Return on Investment (ROI): Revenue generated vs. campaign cost.

2. TCPA Compliant Opt-In Flow Design

Building your SMS list requires explicit consent, adhering strictly to TCPA (Telephone Consumer Protection Act) regulations.

  • Initial Call to Action (CTA):

* Placement: Website banners, pop-ups, checkout pages, in-store signage, social media.

* Example CTA: "Get 15% OFF your first order! Text JOIN to 1-800-XXX-XXXX to subscribe to exclusive deals & updates."

* Disclosure at CTA: Clearly state what subscribers can expect (e.g., "By texting JOIN, you agree to receive recurring automated promotional and personalized marketing text messages from [Your Company Name] at the cell number used when signing up. Consent is not a condition of any purchase. Reply HELP for help and STOP to cancel. Msg & Data rates may apply. View our Privacy Policy: [Link] & Terms of Service: [Link].").

  • Double Opt-In Mechanism (Highly Recommended for Best Practice):

* Step 1 (User Initiates): User texts a keyword (e.g., "JOIN") to your short code/toll-free number.

* Step 2 (System Response - Confirmation Request): Your system immediately sends a message back asking for confirmation.

* Example: "Welcome to [Your Company Name]! Reply YES to confirm your subscription for exclusive deals & updates. Msg & Data rates may apply. Text STOP to cancel, HELP for help. [Link to Privacy/Terms]"

* Step 3 (User Confirms): User replies "YES".

* Step 4 (System Response - Final Confirmation & Welcome):

* Example: "Thanks for confirming! You're in! Your 15% OFF code is WELCOME15. Shop now: [Link]. Up to 4 Msgs/month. Text STOP to cancel, HELP for help. [Your Company Name]"

  • Single Opt-In (If Double Opt-In is not used - less recommended):

* Step 1 (User Initiates): User texts a keyword to your number.

* Step 2 (System Response - Welcome & Disclosure):

* Example: "Welcome to [Your Company Name]! Your 15% OFF code is WELCOME15. Shop now: [Link]. You'll receive [Frequency, e.g., 2-4] texts/month with exclusive offers. Msg & Data rates may apply. Text STOP to cancel, HELP for help. [Link to Privacy/Terms]"

  • Essential Opt-Out Instructions:

* Must be included in the initial confirmation message and periodically within campaigns.

* Standard Keywords: "STOP", "END", "CANCEL", "UNSUBSCRIBE", "QUIT".

* System Response to Opt-Out: "You have been unsubscribed from [Your Company Name] alerts. You will no longer receive messages. Reply START to resubscribe."

  • Privacy Policy & Terms of Service: Always link to these documents clearly in your opt-in disclosures.

3. Segmentation Strategy

Tailoring messages to specific customer groups dramatically increases engagement and conversion rates.

  • Common Segmentation Criteria:

* Demographics: Age, gender, location (if collected and relevant).

* Purchase History: First-time buyers, repeat customers, high-value customers, product categories purchased, last purchase date.

* Website Behavior: Pages viewed, products added to cart (abandoned cart), search queries.

* Engagement Level: Active subscribers, inactive subscribers, clickers vs. non-clickers.

* Opt-In Source: How they subscribed (e.g., website pop-up, in-store, specific promotion).

* Customer Lifecycle Stage: New lead, active customer, lapsed customer.

  • Example Segments & Use Cases:

* "New Subscribers (Last 30 Days)": Welcome series, introductory offers.

* "Abandoned Cart (Last 24 Hours)": Reminder messages, incentive to complete purchase.

* "High-Value Customers (Purchased >$500)": Exclusive early access to sales, VIP offers, loyalty program updates.

* "Viewed Product X but Didn't Buy (Last 7 Days)": Follow-up with a related offer or product benefits.

* "Lapsed Customers (No Purchase in 90+ Days)": Re-engagement campaigns, special discounts.

  • Actionable Tip: Integrate your SMS platform with your CRM, e-commerce platform, or data warehouse to automatically update segments based on real-time customer actions.

4. Drip Sequence Development

Drip campaigns (automated series of messages) are highly effective for nurturing subscribers through the customer journey.

  • Campaign Type Examples:

* Welcome Series: Onboarding new subscribers.

* Abandoned Cart Recovery: Reminding users of items left in their cart.

* Post-Purchase Follow-up: Thank you, order updates, product care tips, cross-sell/upsell.

* Promotional Series: Highlighting new products, sales, seasonal offers.

* Re-engagement Series: Aimed at inactive subscribers.

* Event Promotion: Reminders and details for webinars, sales, or in-store events.

  • General Drip Sequence Structure:

* Trigger: What action initiates the sequence (e.g., new opt-in, cart abandonment, purchase).

* Message 1: Initial message, immediate value.

* Delay 1: Time between Message 1 and Message 2 (e.g., 24 hours, 3 days).

* Message 2: Follow-up, addressing potential objections, adding value.

* Delay 2: Time between Message 2 and Message 3.

* Message 3: Final nudge, urgency, last chance.

* Exit Conditions: What action removes the subscriber from the sequence (e.g., makes a purchase, replies STOP).

  • Example: Abandoned Cart Recovery Drip Sequence

* Trigger: Customer adds items to cart but does not complete purchase within 30 minutes.

* Message 1 (30 minutes after abandonment):

* Content: "Hey [Customer Name], don't forget your items! Your cart is waiting at [Link to Cart]. Complete your order now before they sell out!"

* CTA: Link to cart.

* Message 2 (24 hours after Message 1, if no purchase):

* Content: "Still thinking about those items in your cart? Here's 10% OFF to help you decide! Use code CART10 at checkout: [Link to Cart]. Ends in 24 hrs!"

* CTA: Link to cart, discount code.

* Message 3 (48 hours after Message 2, if no purchase):

* Content: "Last chance! Your 10% OFF code CART10 expires soon! Don't miss out on your [Product Name/Category]! Finish your order: [Link to Cart]. [Your Company Name]"

* CTA: Link to cart, urgency.

* Exit Condition: Customer completes purchase at any point during the sequence.

  • Content Best Practices for SMS:

* Concise: SMS is short-form. Get to the point quickly.

* Clear CTA: Tell recipients exactly what you want them to do (e.g., "Shop Now," "Get Your Code," "Learn More").

* Personalization: Use subscriber names or other relevant data points.

* Value-Driven: Offer discounts, exclusive content, helpful information.

* Urgency/Scarcity: (Use sparingly) "Limited time," "While supplies last."

* Branding: Include your company name in messages.

* Emojis: Use judiciously to convey tone and emotion, but don't overdo it.

* Links: Use shortened, branded links (e.g., bit.ly, yourcompany.co/link).

5. Compliance & Best Practices (Beyond TCPA)

Maintaining compliance and adhering to industry best practices is crucial for long-term success and avoiding penalties.

  • CTIA Guidelines: The Cellular Telecommunications Industry Association (CTIA) provides guidelines that carriers enforce.

* Consent: Reiterate the need for explicit, verifiable consent.

* Opt-Out: Must be free, easy, and always honored promptly.

* Identification: Clearly identify your brand in every message.

* Content Restrictions: Avoid illegal, illicit, hateful, or harmful content. No profanity, sexually explicit content, or promoting illegal substances/activities.

* No Phishing/Spam: Do not send unsolicited messages or attempt to deceive recipients.

  • Sender Identification:

* Use a dedicated short code (5-6 digits) or toll-free number (1-8XX) for consistent branding and higher deliverability.

* Always include your company name in the message body.

  • Frequency Management:

* Set Expectations: Disclose frequency during opt-in (e.g., "Max 4 messages/month").

* Don't Overdo It: Sending too many messages leads to high opt-out rates. Prioritize high-value content.

* Consider Time Zones: Schedule messages to arrive during reasonable hours in the recipient's local time zone. Avoid late-night or early-morning sends.

  • Value Proposition: Every message should offer clear value to the subscriber. Don't just send messages for the sake of it.
  • Testing:

* A/B Test: Experiment with different CTAs, message copy, offers, and timing to see what resonates best with your audience.

* Internal Testing: Send test messages to your own phone to check formatting, links, and overall appearance before sending to your list.

6. Measurement, Reporting & Optimization

Continuously monitor your campaigns and iterate based on performance data.

  • Key Metrics to Track (as defined in Section 1):

* Opt-in Rate

* CTR

* Conversion Rate

* Redemption Rate

* Opt-Out Rate

* ROI

  • Reporting Frequency:

* Weekly/Bi-Weekly: Review performance for active campaigns, identify immediate issues.

* Monthly: Comprehensive review, compare against objectives, identify trends.

* Quarterly: Strategic review, evaluate overall SMS program health, plan future initiatives.

  • Optimization Strategies:

* A/B Testing:

* Message Copy: Short vs. long, different tone.

* CTAs: "Shop Now" vs. "Get My Discount."

* Offers: 10% off vs. Free Shipping.

* Timing: Different days of the week, times of day.

* Segmentation: Test different messages for different segments.

* Adjust Drip Sequence Delays: Optimize the time between messages.

* Refine Segmentation: Create more granular segments for better personalization.

* Review Opt-Out Reasons (if collected): Understand why subscribers are leaving and address common complaints.

* Integrate Feedback: Use survey results or direct customer feedback to improve content and strategy.


By meticulously following this guide, you will be well-equipped to design, launch, and optimize highly effective, compliant, and customer-centric SMS marketing campaigns.

Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
\n\n\n"); var hasSrcMain=Object.keys(extracted).some(function(k){return k.indexOf("src/main")>=0;}); if(!hasSrcMain) zip.file(folder+"src/main."+ext,"import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport App from './App'\nimport './index.css'\n\nReactDOM.createRoot(document.getElementById('root')!).render(\n \n \n \n)\n"); var hasSrcApp=Object.keys(extracted).some(function(k){return k==="src/App."+ext||k==="App."+ext;}); if(!hasSrcApp) zip.file(folder+"src/App."+ext,"import React from 'react'\nimport './App.css'\n\nfunction App(){\n return(\n
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n
\n )\n}\nexport default App\n"); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e}\n.app{min-height:100vh;display:flex;flex-direction:column}\n.app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px}\nh1{font-size:2.5rem;font-weight:700}\n"); zip.file(folder+"src/App.css",""); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/pages/.gitkeep",""); zip.file(folder+"src/hooks/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\n## Open in IDE\nOpen the project folder in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- Vue (Vite + Composition API + TypeScript) --- */ function buildVue(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "type": "module",\n "scripts": {\n "dev": "vite",\n "build": "vue-tsc -b && vite build",\n "preview": "vite preview"\n },\n "dependencies": {\n "vue": "^3.5.13",\n "vue-router": "^4.4.5",\n "pinia": "^2.3.0",\n "axios": "^1.7.9"\n },\n "devDependencies": {\n "@vitejs/plugin-vue": "^5.2.1",\n "typescript": "~5.7.3",\n "vite": "^6.0.5",\n "vue-tsc": "^2.2.0"\n }\n}\n'); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport { resolve } from 'path'\n\nexport default defineConfig({\n plugins: [vue()],\n resolve: { alias: { '@': resolve(__dirname,'src') } }\n})\n"); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]}\n'); zip.file(folder+"tsconfig.app.json",'{\n "compilerOptions":{\n "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"],\n "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true,\n "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue",\n "strict":true,"paths":{"@/*":["./src/*"]}\n },\n "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"]\n}\n'); zip.file(folder+"env.d.ts","/// \n"); zip.file(folder+"index.html","\n\n\n \n \n "+slugTitle(pn)+"\n\n\n
\n \n\n\n"); var hasMain=Object.keys(extracted).some(function(k){return k==="src/main.ts"||k==="main.ts";}); if(!hasMain) zip.file(folder+"src/main.ts","import { createApp } from 'vue'\nimport { createPinia } from 'pinia'\nimport App from './App.vue'\nimport './assets/main.css'\n\nconst app = createApp(App)\napp.use(createPinia())\napp.mount('#app')\n"); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue","\n\n\n\n\n"); zip.file(folder+"src/assets/main.css","*{margin:0;padding:0;box-sizing:border-box}body{font-family:system-ui,sans-serif;background:#fff;color:#213547}\n"); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/views/.gitkeep",""); zip.file(folder+"src/stores/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\nOpen in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- Angular (v19 standalone) --- */ function buildAngular(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var sel=pn.replace(/_/g,"-"); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "scripts": {\n "ng": "ng",\n "start": "ng serve",\n "build": "ng build",\n "test": "ng test"\n },\n "dependencies": {\n "@angular/animations": "^19.0.0",\n "@angular/common": "^19.0.0",\n "@angular/compiler": "^19.0.0",\n "@angular/core": "^19.0.0",\n "@angular/forms": "^19.0.0",\n "@angular/platform-browser": "^19.0.0",\n "@angular/platform-browser-dynamic": "^19.0.0",\n "@angular/router": "^19.0.0",\n "rxjs": "~7.8.0",\n "tslib": "^2.3.0",\n "zone.js": "~0.15.0"\n },\n "devDependencies": {\n "@angular-devkit/build-angular": "^19.0.0",\n "@angular/cli": "^19.0.0",\n "@angular/compiler-cli": "^19.0.0",\n "typescript": "~5.6.0"\n }\n}\n'); zip.file(folder+"angular.json",'{\n "$schema": "./node_modules/@angular/cli/lib/config/schema.json",\n "version": 1,\n "newProjectRoot": "projects",\n "projects": {\n "'+pn+'": {\n "projectType": "application",\n "root": "",\n "sourceRoot": "src",\n "prefix": "app",\n "architect": {\n "build": {\n "builder": "@angular-devkit/build-angular:application",\n "options": {\n "outputPath": "dist/'+pn+'",\n "index": "src/index.html",\n "browser": "src/main.ts",\n "tsConfig": "tsconfig.app.json",\n "styles": ["src/styles.css"],\n "scripts": []\n }\n },\n "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"}\n }\n }\n }\n}\n'); zip.file(folder+"tsconfig.json",'{\n "compileOnSave": false,\n "compilerOptions": {"baseUrl":"./","outDir":"./dist/out-tsc","forceConsistentCasingInFileNames":true,"strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"paths":{"@/*":["src/*"]},"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","useDefineForClassFields":false,"lib":["ES2022","dom"]},\n "references":[{"path":"./tsconfig.app.json"}]\n}\n'); zip.file(folder+"tsconfig.app.json",'{\n "extends":"./tsconfig.json",\n "compilerOptions":{"outDir":"./dist/out-tsc","types":[]},\n "files":["src/main.ts"],\n "include":["src/**/*.d.ts"]\n}\n'); zip.file(folder+"src/index.html","\n\n\n \n "+slugTitle(pn)+"\n \n \n \n\n\n \n\n\n"); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser';\nimport { appConfig } from './app/app.config';\nimport { AppComponent } from './app/app.component';\n\nbootstrapApplication(AppComponent, appConfig)\n .catch(err => console.error(err));\n"); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; }\nbody { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; }\n"); var hasComp=Object.keys(extracted).some(function(k){return k.indexOf("app.component")>=0;}); if(!hasComp){ zip.file(folder+"src/app/app.component.ts","import { Component } from '@angular/core';\nimport { RouterOutlet } from '@angular/router';\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [RouterOutlet],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css'\n})\nexport class AppComponent {\n title = '"+pn+"';\n}\n"); zip.file(folder+"src/app/app.component.html","
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n \n
\n"); zip.file(folder+"src/app/app.component.css",".app-header{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:60vh;gap:16px}h1{font-size:2.5rem;font-weight:700;color:#6366f1}\n"); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';\nimport { provideRouter } from '@angular/router';\nimport { routes } from './app.routes';\n\nexport const appConfig: ApplicationConfig = {\n providers: [\n provideZoneChangeDetection({ eventCoalescing: true }),\n provideRouter(routes)\n ]\n};\n"); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router';\n\nexport const routes: Routes = [];\n"); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nng serve\n# or: npm start\n\`\`\`\n\n## Build\n\`\`\`bash\nng build\n\`\`\`\n\nOpen in VS Code with Angular Language Service extension.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n.angular/\n"); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/m,"").trim(); var reqMap={"numpy":"numpy","pandas":"pandas","sklearn":"scikit-learn","tensorflow":"tensorflow","torch":"torch","flask":"flask","fastapi":"fastapi","uvicorn":"uvicorn","requests":"requests","sqlalchemy":"sqlalchemy","pydantic":"pydantic","dotenv":"python-dotenv","PIL":"Pillow","cv2":"opencv-python","matplotlib":"matplotlib","seaborn":"seaborn","scipy":"scipy"}; var reqs=[]; Object.keys(reqMap).forEach(function(k){if(src.indexOf("import "+k)>=0||src.indexOf("from "+k)>=0)reqs.push(reqMap[k]);}); var reqsTxt=reqs.length?reqs.join("\n"):"# add dependencies here\n"; zip.file(folder+"main.py",src||"# "+title+"\n# Generated by PantheraHive BOS\n\nprint(title+\" loaded\")\n"); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n\`\`\`\n\n## Run\n\`\`\`bash\npython main.py\n\`\`\`\n"); zip.file(folder+".gitignore",".venv/\n__pycache__/\n*.pyc\n.env\n.DS_Store\n"); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/m,"").trim(); var depMap={"mongoose":"^8.0.0","dotenv":"^16.4.5","axios":"^1.7.9","cors":"^2.8.5","bcryptjs":"^2.4.3","jsonwebtoken":"^9.0.2","socket.io":"^4.7.4","uuid":"^9.0.1","zod":"^3.22.4","express":"^4.18.2"}; var deps={}; Object.keys(depMap).forEach(function(k){if(src.indexOf(k)>=0)deps[k]=depMap[k];}); if(!deps["express"])deps["express"]="^4.18.2"; var pkgJson=JSON.stringify({"name":pn,"version":"1.0.0","main":"src/index.js","scripts":{"start":"node src/index.js","dev":"nodemon src/index.js"},"dependencies":deps,"devDependencies":{"nodemon":"^3.0.3"}},null,2)+"\n"; zip.file(folder+"package.json",pkgJson); var fallback="const express=require(\"express\");\nconst app=express();\napp.use(express.json());\n\napp.get(\"/\",(req,res)=>{\n res.json({message:\""+title+" API\"});\n});\n\nconst PORT=process.env.PORT||3000;\napp.listen(PORT,()=>console.log(\"Server on port \"+PORT));\n"; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000\n"); zip.file(folder+".gitignore","node_modules/\n.env\n.DS_Store\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\n\`\`\`\n\n## Run\n\`\`\`bash\nnpm run dev\n\`\`\`\n"); } /* --- Vanilla HTML --- */ function buildVanillaHtml(zip,folder,app,code){ var title=slugTitle(app); var isFullDoc=code.trim().toLowerCase().indexOf("=0||code.trim().toLowerCase().indexOf("=0; var indexHtml=isFullDoc?code:"\n\n\n\n\n"+title+"\n\n\n\n"+code+"\n\n\n\n"; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */\n*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e}\n"); zip.file(folder+"script.js","/* "+title+" — scripts */\n"); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Open\nDouble-click \`index.html\` in your browser.\n\nOr serve locally:\n\`\`\`bash\nnpx serve .\n# or\npython3 -m http.server 3000\n\`\`\`\n"); zip.file(folder+".gitignore",".DS_Store\nnode_modules/\n.env\n"); } /* ===== MAIN ===== */ var sc=document.createElement("script"); sc.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"; sc.onerror=function(){ if(lbl)lbl.textContent="Download ZIP"; alert("JSZip load failed — check connection."); }; sc.onload=function(){ var zip=new JSZip(); var base=(_phFname||"output").replace(/\.[^.]+$/,""); var app=base.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; var folder=app+"/"; var vc=document.getElementById("panel-content"); var panelTxt=vc?(vc.innerText||vc.textContent||""):""; var lang=detectLang(_phCode,panelTxt); if(_phIsHtml){ buildVanillaHtml(zip,folder,app,_phCode); } else if(lang==="flutter"){ buildFlutter(zip,folder,app,_phCode,panelTxt); } else if(lang==="react-native"){ buildReactNative(zip,folder,app,_phCode,panelTxt); } else if(lang==="swift"){ buildSwift(zip,folder,app,_phCode,panelTxt); } else if(lang==="kotlin"){ buildKotlin(zip,folder,app,_phCode,panelTxt); } else if(lang==="react"){ buildReact(zip,folder,app,_phCode,panelTxt); } else if(lang==="vue"){ buildVue(zip,folder,app,_phCode,panelTxt); } else if(lang==="angular"){ buildAngular(zip,folder,app,_phCode,panelTxt); } else if(lang==="python"){ buildPython(zip,folder,app,_phCode); } else if(lang==="node"){ buildNode(zip,folder,app,_phCode); } else { /* Document/content workflow */ var title=app.replace(/_/g," "); var md=_phAll||_phCode||panelTxt||"No content"; zip.file(folder+app+".md",md); var h=""+title+""; h+="

"+title+"

"; var hc=md.replace(/&/g,"&").replace(//g,">"); hc=hc.replace(/^### (.+)$/gm,"

$1

"); hc=hc.replace(/^## (.+)$/gm,"

$1

"); hc=hc.replace(/^# (.+)$/gm,"

$1

"); hc=hc.replace(/\*\*(.+?)\*\*/g,"$1"); hc=hc.replace(/\n{2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\nFiles:\n- "+app+".md (Markdown)\n- "+app+".html (styled HTML)\n"); } zip.generateAsync({type:"blob"}).then(function(blob){ var a=document.createElement("a"); a.href=URL.createObjectURL(blob); a.download=app+".zip"; a.click(); URL.revokeObjectURL(a.href); if(lbl)lbl.textContent="Download ZIP"; }); }; document.head.appendChild(sc); } function phShare(){navigator.clipboard.writeText(window.location.href).then(function(){var el=document.getElementById("ph-share-lbl");if(el){el.textContent="Link copied!";setTimeout(function(){el.textContent="Copy share link";},2500);}});}function phEmbed(){var runId=window.location.pathname.split("/").pop().replace(".html","");var embedUrl="https://pantherahive.com/embed/"+runId;var code='';navigator.clipboard.writeText(code).then(function(){var el=document.getElementById("ph-embed-lbl");if(el){el.textContent="Embed code copied!";setTimeout(function(){el.textContent="Get Embed Code";},2500);}});}